tpt-rails 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +127 -0
- data/Rakefile +32 -0
- data/app/assets/config/tpt_rails_manifest.js +1 -0
- data/app/assets/stylesheets/tpt/rails/application.css +15 -0
- data/app/controllers/tpt/rails/application_controller.rb +5 -0
- data/app/controllers/tpt/rails/error_tests_controller.rb +21 -0
- data/app/controllers/tpt/rails/health_checks_controller.rb +18 -0
- data/app/helpers/tpt/rails/application_helper.rb +4 -0
- data/app/jobs/tpt/rails/application_job.rb +4 -0
- data/app/mailers/tpt/rails/application_mailer.rb +6 -0
- data/app/models/tpt/rails/application_record.rb +5 -0
- data/app/views/layouts/tpt/rails/application.html.erb +15 -0
- data/config/routes.rb +6 -0
- data/lib/generators/tpt_rails/configuration/configuration_generator.rb +10 -0
- data/lib/generators/tpt_rails/configuration/templates/config/initializers/tpt_rails.rb +10 -0
- data/lib/generators/tpt_rails/continuous_integration/continuous_integration_generator.rb +17 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/Dockerfile.tt +31 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/docker-compose.yaml.tt +26 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/tasks/project.test.unit +12 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/test.Jenkinsfile.tt +40 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/test.config.xml.tt +76 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/tptcd.Jenkinsfile.tt +7 -0
- data/lib/generators/tpt_rails/continuous_integration/templates/ci/tptci.Jenkinsfile.tt +7 -0
- data/lib/generators/tpt_rails/kubernetes/kubernetes_generator.rb +156 -0
- data/lib/generators/tpt_rails/kubernetes/templates/Dockerfile.tt +41 -0
- data/lib/generators/tpt_rails/kubernetes/templates/entrypoint.sh +13 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/Chart.yaml.tt +16 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/README.md +142 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/requirements.yaml.tt +8 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/NOTES.txt.tt +8 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/_env.yaml +15 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/_helpers.tpl.tt +63 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/autoscaler.yaml.tt +21 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/deployment.yaml.tt +96 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/hooks/db-migrate.yaml.tt +59 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/service.yaml.tt +52 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/values.prod.yaml.tt +52 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/values.staging.yaml.tt +52 -0
- data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/values.yaml.tt +171 -0
- data/lib/generators/tpt_rails/postman/postman.yaml.tt +2 -0
- data/lib/tasks/tpt/rails_tasks.rake +23 -0
- data/lib/tpt/rails.rb +65 -0
- data/lib/tpt/rails/config.rb +77 -0
- data/lib/tpt/rails/engine.rb +7 -0
- data/lib/tpt/rails/internal.rb +3 -0
- data/lib/tpt/rails/internal/datadog.rb +66 -0
- data/lib/tpt/rails/internal/error_reporter.rb +68 -0
- data/lib/tpt/rails/internal/health_checks.rb +32 -0
- data/lib/tpt/rails/version.rb +5 -0
- metadata +153 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= Tpt::Rails.app_name %> can be accessed via port {{ .Values.environment.APP_PORT }} on the
|
2
|
+
following DNS name from within your cluster:
|
3
|
+
{{ template "<%= Tpt::Rails.app_name %>.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
|
4
|
+
|
5
|
+
For local development:
|
6
|
+
# Execute the following commands to route the connection:
|
7
|
+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "<%= Tpt::Rails.app_name %>.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
|
8
|
+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME {{ .Values.environment.APP_PORT }}:{{ .Values.environment.APP_PORT }}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{{ define "env" }}
|
2
|
+
{{- range $key, $val := .Values.environment }}
|
3
|
+
- name: {{ $key }}
|
4
|
+
{{- if hasPrefix "valueFrom:" $val }}
|
5
|
+
{{- tpl $val $ | nindent 2 }}
|
6
|
+
{{- else }}
|
7
|
+
value: {{ tpl $val $ | quote }}
|
8
|
+
{{- end }}
|
9
|
+
{{- end}}
|
10
|
+
# This is in this file because we can't have conditionals in `values.yaml`.
|
11
|
+
{{- if .Values.redis.enabled }}
|
12
|
+
- name: REDIS_URL
|
13
|
+
value: "redis://{{ .Release.Name }}-redis-master:{{ .Values.redis.redisPort }}"
|
14
|
+
{{- end }}
|
15
|
+
{{ end }}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
{{/* vim: set filetype=mustache: */}}
|
2
|
+
|
3
|
+
{{/*
|
4
|
+
Expand the name of the chart.
|
5
|
+
*/}}
|
6
|
+
{{- define "<%= Tpt::Rails.app_name %>.name" -}}
|
7
|
+
{{- if .Values.fullnameOverride -}}
|
8
|
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
9
|
+
{{- else -}}
|
10
|
+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
11
|
+
{{- end -}}
|
12
|
+
{{- end -}}
|
13
|
+
|
14
|
+
{{/*
|
15
|
+
Create a default fully qualified app name.
|
16
|
+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
17
|
+
If release name contains chart name it will be used as a full name.
|
18
|
+
*/}}
|
19
|
+
{{- define "<%= Tpt::Rails.app_name %>.fullname" -}}
|
20
|
+
{{- if .Values.fullnameOverride -}}
|
21
|
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
22
|
+
{{- else -}}
|
23
|
+
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
24
|
+
{{- if contains $name .Release.Name -}}
|
25
|
+
{{- printf .Release.Name | trunc 63 | trimSuffix "-" -}}
|
26
|
+
{{- else -}}
|
27
|
+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
28
|
+
{{- end -}}
|
29
|
+
{{- end -}}
|
30
|
+
{{- end -}}
|
31
|
+
|
32
|
+
{{/*
|
33
|
+
Get domain name of ode
|
34
|
+
*/}}
|
35
|
+
{{- define "<%= Tpt::Rails.app_name %>.domain" -}}
|
36
|
+
{{- printf "%s.%s" .Release.Namespace .Values.app.ingress_dns_name -}}
|
37
|
+
{{- end -}}
|
38
|
+
|
39
|
+
{{/*
|
40
|
+
Get service.
|
41
|
+
*/}}
|
42
|
+
{{- define "<%= Tpt::Rails.app_name %>.service" -}}
|
43
|
+
{{- $trimPath := .service.path | trimPrefix "/" -}}
|
44
|
+
{{- if eq .service.useIngress true -}}
|
45
|
+
{{- printf "%s://%s-%s:%v/%s" .service.protocol .service.hostName .domain .service.port $trimPath -}}
|
46
|
+
{{- else -}}
|
47
|
+
{{- printf "%s://%s:%v/%s" .service.protocol .service.hostName .service.port $trimPath -}}
|
48
|
+
{{- end -}}
|
49
|
+
{{- end -}}
|
50
|
+
|
51
|
+
{{/*
|
52
|
+
Get services.
|
53
|
+
*/}}
|
54
|
+
{{- define "<%= Tpt::Rails.app_name %>.services" -}}
|
55
|
+
{{- $domain := (include "<%= Tpt::Rails.app_name %>.domain" .) -}}
|
56
|
+
{{- range $key, $serviceDefinition := .Values.app.services }}
|
57
|
+
{{- if ne (hasKey $.Values.environment $serviceDefinition.envVarName) true }}
|
58
|
+
{{- $service := dict "domain" $domain "service" $serviceDefinition | include "<%= Tpt::Rails.app_name %>.service" }}
|
59
|
+
- name: {{ $serviceDefinition.envVarName }}
|
60
|
+
value: {{ printf "%s" $service | trimSuffix "/" | quote }}
|
61
|
+
{{- end }}
|
62
|
+
{{- end }}
|
63
|
+
{{- end -}}
|
data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/autoscaler.yaml.tt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
apiVersion: autoscaling/v1
|
2
|
+
kind: HorizontalPodAutoscaler
|
3
|
+
metadata:
|
4
|
+
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
5
|
+
labels:
|
6
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.name" . }}
|
7
|
+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
8
|
+
release: "{{ .Release.Name }}"
|
9
|
+
heritage: "{{ .Release.Service }}"
|
10
|
+
tpt/project: "{{ .Chart.Name }}"
|
11
|
+
tpt/owner: {{ .Values.annotations.owner }}
|
12
|
+
tpt/creator: {{ .Values.annotations.creator | default "UNKNOWN" | quote }}
|
13
|
+
tpt/release: "{{ .Release.Name }}"
|
14
|
+
spec:
|
15
|
+
scaleTargetRef:
|
16
|
+
apiVersion: apps/v1
|
17
|
+
kind: Deployment
|
18
|
+
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
19
|
+
minReplicas: {{ .Values.autoscaler.minimumPods }}
|
20
|
+
maxReplicas: {{ .Values.autoscaler.maximumPods }}
|
21
|
+
targetCPUUtilizationPercentage: {{ .Values.autoscaler.targetCPUUtilizationPercentage }}
|
data/lib/generators/tpt_rails/kubernetes/templates/kubernetes/helm/templates/deployment.yaml.tt
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Kube information about the deployment
|
2
|
+
# For documentation on these properties, see:
|
3
|
+
# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment
|
4
|
+
|
5
|
+
apiVersion: apps/v1
|
6
|
+
kind: Deployment
|
7
|
+
metadata:
|
8
|
+
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
9
|
+
labels:
|
10
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.name" . }}
|
11
|
+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
12
|
+
release: "{{ .Release.Name }}"
|
13
|
+
heritage: "{{ .Release.Service }}"
|
14
|
+
tpt/project: "{{ .Chart.Name }}"
|
15
|
+
tpt/owner: {{ .Values.annotations.owner }}
|
16
|
+
tpt/creator: {{ .Values.annotations.creator | default "UNKNOWN" | quote }}
|
17
|
+
tpt/release: "{{ .Release.Name }}"
|
18
|
+
spec:
|
19
|
+
strategy:
|
20
|
+
type: RollingUpdate
|
21
|
+
rollingUpdate:
|
22
|
+
{{ toYaml .Values.rollingUpdate | indent 6 | trim }}
|
23
|
+
selector:
|
24
|
+
matchLabels:
|
25
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
26
|
+
replicas: {{ .Values.replicas }}
|
27
|
+
# Max number of replicat sets to retain.
|
28
|
+
# Sets exceeding this limit will get deleted
|
29
|
+
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
|
30
|
+
template:
|
31
|
+
metadata:
|
32
|
+
labels:
|
33
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
34
|
+
release: "{{ .Release.Name }}"
|
35
|
+
track: stable
|
36
|
+
language: ruby
|
37
|
+
tpt/project: "{{ .Chart.Name }}"
|
38
|
+
tpt/creator: {{ .Values.annotations.creator | default "UNKNOWN" | quote }}
|
39
|
+
annotations:
|
40
|
+
buildID: "{{ .Values.buildID }}"
|
41
|
+
sidecar.istio.io/inject: "true"
|
42
|
+
spec:
|
43
|
+
# Specifies where our Kube secrets are coming from
|
44
|
+
imagePullSecrets:
|
45
|
+
- name: {{ .Values.imagePullSecrets.name }}
|
46
|
+
containers:
|
47
|
+
- name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
48
|
+
# This references our images on Docker hub
|
49
|
+
{{- if .Values.revision }}
|
50
|
+
# If a different container version has been specified, use it
|
51
|
+
image: "teacherspayteachers/{{ .Values.image.name }}:{{ .Values.revision }}"
|
52
|
+
{{- else }}
|
53
|
+
image: "teacherspayteachers/{{ .Values.image.name }}:{{ .Values.image.tag }}"
|
54
|
+
{{- end }}
|
55
|
+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
56
|
+
# Specifies provisioning requests & limits (memory and CPU)
|
57
|
+
resources:
|
58
|
+
limits:
|
59
|
+
memory: {{ .Values.resources.limits.memory }}
|
60
|
+
cpu: {{ .Values.resources.limits.cpu }}
|
61
|
+
requests:
|
62
|
+
memory: {{ .Values.resources.requests.memory }}
|
63
|
+
cpu: {{ .Values.resources.requests.cpu }}
|
64
|
+
env:
|
65
|
+
{{- include "env" . | indent 10 }}
|
66
|
+
{{- include "<%= Tpt::Rails.app_name %>.services" . | nindent 10 }}
|
67
|
+
{{- if .Values.secrets }}
|
68
|
+
{{ toYaml .Values.secrets | trim | nindent 10 }}
|
69
|
+
{{- end }}
|
70
|
+
ports:
|
71
|
+
# Where our application is listening
|
72
|
+
- containerPort: {{ .Values.environment.APP_PORT }}
|
73
|
+
# Specifies an endpoint. Kube won't mark the container as ready until
|
74
|
+
# this endpoint returns a success code
|
75
|
+
readinessProbe:
|
76
|
+
httpGet:
|
77
|
+
path: /internal/health-check
|
78
|
+
port: {{ .Values.environment.APP_PORT }}
|
79
|
+
scheme: HTTP
|
80
|
+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
81
|
+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
82
|
+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
83
|
+
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
84
|
+
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
85
|
+
# Specifies an endpoint. Kube will take the container out of circulation
|
86
|
+
# if it fails the health check for too long
|
87
|
+
livenessProbe:
|
88
|
+
httpGet:
|
89
|
+
path: /internal/health-check
|
90
|
+
port: {{ .Values.environment.APP_PORT }}
|
91
|
+
scheme: HTTP
|
92
|
+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
93
|
+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
94
|
+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
95
|
+
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
|
96
|
+
successThreshold: {{ .Values.livenessProbe.successThreshold }}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{{- if .Values.migrateCommand -}}
|
2
|
+
apiVersion: batch/v1
|
3
|
+
kind: Job # runs once and then stops
|
4
|
+
metadata:
|
5
|
+
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}-db-migrate
|
6
|
+
labels:
|
7
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.name" . }}
|
8
|
+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
9
|
+
release: "{{ .Release.Name }}"
|
10
|
+
heritage: "{{ .Release.Service }}"
|
11
|
+
tpt/project: "{{ .Chart.Name }}"
|
12
|
+
tpt/owner: {{ .Values.annotations.owner }}
|
13
|
+
tpt/creator: {{ .Values.annotations.creator | default "UNKNOWN" | quote }}
|
14
|
+
tpt/release: "{{ .Release.Name }}"
|
15
|
+
annotations:
|
16
|
+
# post-install: after initial creation of stack, pre-upgrade: before deploying new code
|
17
|
+
"helm.sh/hook": "post-install,pre-upgrade"
|
18
|
+
"helm.sh/hook-delete-policy": "before-hook-creation"
|
19
|
+
"helm.sh/hook-weight": "0"
|
20
|
+
spec:
|
21
|
+
template:
|
22
|
+
metadata:
|
23
|
+
labels:
|
24
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.name" . }}
|
25
|
+
release: {{ .Release.Name }}
|
26
|
+
annotations:
|
27
|
+
buildID: "{{ .Values.buildID }}"
|
28
|
+
sidecar.istio.io/inject: "false"
|
29
|
+
spec:
|
30
|
+
restartPolicy: Never
|
31
|
+
imagePullSecrets:
|
32
|
+
- name: {{ .Values.imagePullSecrets.name }}
|
33
|
+
containers:
|
34
|
+
- name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
35
|
+
# This references our images on Docker hub
|
36
|
+
{{- if .Values.revision }}
|
37
|
+
# If a different container version has been specified, use it
|
38
|
+
image: "teacherspayteachers/{{ .Values.image.name }}:{{ .Values.revision }}"
|
39
|
+
{{- else }}
|
40
|
+
image: "teacherspayteachers/{{ .Values.image.name }}:{{ .Values.image.tag }}"
|
41
|
+
{{- end }}
|
42
|
+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
43
|
+
command: ["/bin/sh"]
|
44
|
+
# This is what causes a different command to be run for this job
|
45
|
+
args: ["-c", "{{ .Values.migrateCommand }}"]
|
46
|
+
# Specifies provisioning requests & limits (memory and CPU)
|
47
|
+
resources:
|
48
|
+
limits:
|
49
|
+
memory: {{ .Values.resources.limits.memory }}
|
50
|
+
cpu: {{ .Values.resources.limits.cpu }}
|
51
|
+
requests:
|
52
|
+
memory: {{ .Values.resources.requests.memory }}
|
53
|
+
cpu: {{ .Values.resources.requests.cpu }}
|
54
|
+
env:
|
55
|
+
{{- include "env" . | indent 10 }}
|
56
|
+
{{- if .Values.secrets }}
|
57
|
+
{{ toYaml .Values.secrets | trim | nindent 10 }}
|
58
|
+
{{- end }}
|
59
|
+
{{- end -}}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Information about the service
|
2
|
+
# For documentation on these properties, see:
|
3
|
+
# https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
|
4
|
+
|
5
|
+
apiVersion: v1
|
6
|
+
kind: Service
|
7
|
+
metadata:
|
8
|
+
# References the "<%= Tpt::Rails.app_name %>.fullname" property defined in _helpers.tpl
|
9
|
+
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
10
|
+
labels:
|
11
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
12
|
+
# References system properties from Helm
|
13
|
+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
14
|
+
release: "{{ .Release.Name }}"
|
15
|
+
heritage: "{{ .Release.Service }}"
|
16
|
+
tpt/project: "{{ .Chart.Name }}"
|
17
|
+
tpt/owner: {{ .Values.annotations.owner }}
|
18
|
+
tpt/creator: {{ .Values.annotations.creator | default "UNKNOWN" | quote }}
|
19
|
+
tpt/release: "{{ .Release.Name }}"
|
20
|
+
annotations:
|
21
|
+
getambassador.io/config: |
|
22
|
+
apiVersion: ambassador/v1
|
23
|
+
kind: Mapping
|
24
|
+
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}_{{ .Release.Namespace }}_mapping
|
25
|
+
prefix: /
|
26
|
+
host: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}.ode.tptpm.info
|
27
|
+
service: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.port }}
|
28
|
+
# retry_policy:
|
29
|
+
# retry_on: "5xx"
|
30
|
+
# num_retries: 5
|
31
|
+
# per_try_timeout: "3s"
|
32
|
+
labels:
|
33
|
+
ambassador:
|
34
|
+
- request_label:
|
35
|
+
- frontend
|
36
|
+
{{- if eq .Values.service.type "LoadBalancer" }}
|
37
|
+
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http"
|
38
|
+
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
|
39
|
+
service.beta.kubernetes.io/aws-load-balancer-internal: "0.0.0.0/0"
|
40
|
+
{{- end }}
|
41
|
+
spec:
|
42
|
+
# References the service.type property from values.yaml
|
43
|
+
type: {{ .Values.service.type }}
|
44
|
+
ports:
|
45
|
+
- name: http
|
46
|
+
# The incoming port
|
47
|
+
port: {{ .Values.service.port }}
|
48
|
+
protocol: TCP
|
49
|
+
# Port to map to. This is where the application is listening
|
50
|
+
targetPort: {{ .Values.environment.APP_PORT }}
|
51
|
+
selector:
|
52
|
+
app: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
name: <%= Tpt::Rails.app_name %>
|
2
|
+
deploy_env: production
|
3
|
+
|
4
|
+
image:
|
5
|
+
name: <%= Tpt::Rails.app_name %>
|
6
|
+
repository: <%= Tpt::Rails.app_name %>
|
7
|
+
tag: latest
|
8
|
+
pullPolicy: Always
|
9
|
+
|
10
|
+
environment:
|
11
|
+
ENVIRONMENT: production
|
12
|
+
APP_ENV: production
|
13
|
+
RAILS_ENV: production
|
14
|
+
|
15
|
+
postgresql:
|
16
|
+
enabled: false
|
17
|
+
|
18
|
+
copy-secrets:
|
19
|
+
enabled: false
|
20
|
+
|
21
|
+
redis:
|
22
|
+
enabled: false
|
23
|
+
|
24
|
+
secrets:
|
25
|
+
- name: RAILS_MASTER_KEY
|
26
|
+
valueFrom:
|
27
|
+
secretKeyRef:
|
28
|
+
name: <%= Tpt::Rails.app_name %>-secrets
|
29
|
+
key: rails-master-key
|
30
|
+
- name: DATABASE_URL
|
31
|
+
valueFrom:
|
32
|
+
secretKeyRef:
|
33
|
+
name: <%= Tpt::Rails.app_name %>-secrets
|
34
|
+
# To set up a staging/prod DB:
|
35
|
+
# - Create the DB in the TpT terraform repo
|
36
|
+
# - Use the root DB account to create an application DB user
|
37
|
+
# - Create a kube secret (e.g. prod-resource-catalog-db-url) with the DATABASE_URL
|
38
|
+
# (including the application user credentials)
|
39
|
+
# - Update the key below to reference your secret
|
40
|
+
key: 'FIXME'
|
41
|
+
|
42
|
+
autoscaler:
|
43
|
+
minimumPods: 3
|
44
|
+
maximumPods: 6
|
45
|
+
targetCPUUtilizationPercentage: 70
|
46
|
+
|
47
|
+
rollingUpdate:
|
48
|
+
maxSurge: 25%
|
49
|
+
|
50
|
+
# Create ELB
|
51
|
+
# service:
|
52
|
+
# type: LoadBalancer
|
@@ -0,0 +1,52 @@
|
|
1
|
+
name: <%= Tpt::Rails.app_name %>
|
2
|
+
deploy_env: staging
|
3
|
+
|
4
|
+
image:
|
5
|
+
name: <%= Tpt::Rails.app_name %>
|
6
|
+
repository: <%= Tpt::Rails.app_name %>
|
7
|
+
tag: latest
|
8
|
+
pullPolicy: Always
|
9
|
+
|
10
|
+
environment:
|
11
|
+
ENVIRONMENT: staging
|
12
|
+
APP_ENV: production
|
13
|
+
RAILS_ENV: production
|
14
|
+
|
15
|
+
postgresql:
|
16
|
+
enabled: false
|
17
|
+
|
18
|
+
copy-secrets:
|
19
|
+
enabled: false
|
20
|
+
|
21
|
+
redis:
|
22
|
+
enabled: false
|
23
|
+
|
24
|
+
secrets:
|
25
|
+
- name: RAILS_MASTER_KEY
|
26
|
+
valueFrom:
|
27
|
+
secretKeyRef:
|
28
|
+
name: <%= Tpt::Rails.app_name %>-secrets
|
29
|
+
key: rails-master-key
|
30
|
+
- name: DATABASE_URL
|
31
|
+
valueFrom:
|
32
|
+
secretKeyRef:
|
33
|
+
name: <%= Tpt::Rails.app_name %>-secrets
|
34
|
+
# To set up a staging/prod DB:
|
35
|
+
# - Create the DB in the TpT terraform repo
|
36
|
+
# - Use the root DB account to create an application DB user
|
37
|
+
# - Create a kube secret (e.g. prod-resource-catalog-db-url) with the DATABASE_URL
|
38
|
+
# (including the application user credentials)
|
39
|
+
# - Update the key below to reference your secret
|
40
|
+
key: 'FIXME'
|
41
|
+
|
42
|
+
autoscaler:
|
43
|
+
minimumPods: 2
|
44
|
+
maximumPods: 3
|
45
|
+
targetCPUUtilizationPercentage: 70
|
46
|
+
|
47
|
+
rollingUpdate:
|
48
|
+
maxSurge: 25%
|
49
|
+
|
50
|
+
# Create ELB
|
51
|
+
# service:
|
52
|
+
# type: LoadBalancer
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# Values to be used elsewhere in the Helm configuration
|
2
|
+
|
3
|
+
# Values in this file are the defaults. Override these values in other environments via
|
4
|
+
# `values.<some environment>.yaml` files.
|
5
|
+
name: <%= Tpt::Rails.app_name %>
|
6
|
+
# ODEs use "integration" as the deploy_env
|
7
|
+
deploy_env: integration
|
8
|
+
|
9
|
+
# There are added to Kubernetes in various ways as labels/etc
|
10
|
+
annotations:
|
11
|
+
owner: <%= config.fetch(:team_name) %>
|
12
|
+
|
13
|
+
# Docker image configuration for the pod
|
14
|
+
image:
|
15
|
+
name: <%= Tpt::Rails.app_name %>
|
16
|
+
repository: <%= Tpt::Rails.app_name %>
|
17
|
+
tag: latest # most recently pushed
|
18
|
+
pullPolicy: Always # always pull, don't use a cached version
|
19
|
+
|
20
|
+
# Used by a Helm hook that runs migration
|
21
|
+
migrateCommand: 'bin/rails db:prepare'
|
22
|
+
|
23
|
+
# Container count
|
24
|
+
replicas: 1
|
25
|
+
|
26
|
+
revisionHistoryLimit: 5
|
27
|
+
|
28
|
+
# CI changes this before deploying
|
29
|
+
buildID: 1
|
30
|
+
|
31
|
+
imagePullSecrets:
|
32
|
+
name: "tptreadonly-docker"
|
33
|
+
|
34
|
+
# Deployment params
|
35
|
+
rollingUpdate:
|
36
|
+
maxUnavailable: 25% # X% of pods are allowed to be offline at once as we deploy
|
37
|
+
maxSurge: 0 # Setting this above 0 will allow having extra pods online during deploy
|
38
|
+
|
39
|
+
mysql:
|
40
|
+
enabled: true
|
41
|
+
podAnnotations:
|
42
|
+
# istio is a service mesh. the istio sidecar interferes with how other pods connect to the MySQL
|
43
|
+
# pod.
|
44
|
+
sidecar.istio.io/inject: "false"
|
45
|
+
# mysqlRootPassword is only used in this file and is only for ODEs
|
46
|
+
mysqlRootPassword: "123456"
|
47
|
+
persistence:
|
48
|
+
enabled: false
|
49
|
+
|
50
|
+
redis:
|
51
|
+
enabled: false
|
52
|
+
# usePassword: false
|
53
|
+
# cluster:
|
54
|
+
# enabled: false
|
55
|
+
# persistence:
|
56
|
+
# enabled: true
|
57
|
+
# size: 10Gi
|
58
|
+
|
59
|
+
## Configure the service
|
60
|
+
## ref: http://kubernetes.io/docs/user-guide/services/
|
61
|
+
service:
|
62
|
+
## Specify a service type
|
63
|
+
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types
|
64
|
+
type: ClusterIP
|
65
|
+
port: 80
|
66
|
+
|
67
|
+
## Configure resource requests and limits
|
68
|
+
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
|
69
|
+
##
|
70
|
+
resources:
|
71
|
+
# requests is guaranteed. kubernetes will only put your pod on a node where it can guarantee these
|
72
|
+
# amounts.
|
73
|
+
requests:
|
74
|
+
memory: 256Mi
|
75
|
+
cpu: 200m
|
76
|
+
# limits is when your pod gets killed for using too many resources
|
77
|
+
limits:
|
78
|
+
memory: 512Mi
|
79
|
+
cpu: 1
|
80
|
+
|
81
|
+
app:
|
82
|
+
# this configures your service to be available at <%= Tpt::Rails.app_name %>.<ingress_dns_name>
|
83
|
+
ingress_dns_name: "ode.tptpm.info"
|
84
|
+
|
85
|
+
#
|
86
|
+
# Environment variables for the <%= Tpt::Rails.app_name %> service
|
87
|
+
#
|
88
|
+
# These values are used in templates/_env.yaml, with some of them (e.g. `valueFrom`, or any `{{…}}`
|
89
|
+
# templates) getting converted into other values.
|
90
|
+
# See also templates/_env.yaml for additional environment variables.
|
91
|
+
environment:
|
92
|
+
APP_PORT: '3000'
|
93
|
+
APP_NAME: <%= Tpt::Rails.app_name %>
|
94
|
+
APP_ENV: integration
|
95
|
+
DD_TRACE_DEBUG: '1'
|
96
|
+
# DATABASE_URL is only used in ODEs
|
97
|
+
DATABASE_URL: 'mysql2://root:{{ .Values.mysql.mysqlRootPassword }}@{{ template "<%= Tpt::Rails.app_name %>.fullname" . }}-mysql:3306/<%= Tpt::Rails.app_name %>_production'
|
98
|
+
RAILS_ENV: 'production'
|
99
|
+
RAILS_LOG_TO_STDOUT: '1'
|
100
|
+
RAILS_SERVE_STATIC_FILES: '1'
|
101
|
+
CLUSTER_SELECTOR: 'app={{ template "<%= Tpt::Rails.app_name %>.fullname" . }}'
|
102
|
+
APP_ENV_NAME: |-
|
103
|
+
valueFrom:
|
104
|
+
fieldRef:
|
105
|
+
fieldPath: metadata.namespace
|
106
|
+
KUBE_POD: |-
|
107
|
+
valueFrom:
|
108
|
+
fieldRef:
|
109
|
+
fieldPath: metadata.name
|
110
|
+
KUBE_NODE: |-
|
111
|
+
valueFrom:
|
112
|
+
fieldRef:
|
113
|
+
fieldPath: spec.nodeName
|
114
|
+
KUBE_POD_IP: |-
|
115
|
+
valueFrom:
|
116
|
+
fieldRef:
|
117
|
+
fieldPath: status.podIP
|
118
|
+
DATADOG_TRACE_HOST: |-
|
119
|
+
valueFrom:
|
120
|
+
fieldRef:
|
121
|
+
fieldPath: status.hostIP
|
122
|
+
DATADOG_TRACE_PORT: "8126"
|
123
|
+
DATADOG_TRACE_URL: "datadog://$(DATADOG_TRACE_HOST):$(DATADOG_TRACE_PORT)"
|
124
|
+
DOGSTATSD_HOST: |-
|
125
|
+
valueFrom:
|
126
|
+
fieldRef:
|
127
|
+
fieldPath: status.hostIP
|
128
|
+
DOGSTATSD_PORT: "8125"
|
129
|
+
DOGSTATSD_URL: "statsd://$(DOGSTATSD_HOST):$(DOGSTATSD_PORT)"
|
130
|
+
|
131
|
+
copy-secrets:
|
132
|
+
enabled: true
|
133
|
+
secrets:
|
134
|
+
- <%= config.fetch(:secrets_name) %>
|
135
|
+
|
136
|
+
secrets:
|
137
|
+
- name: RAILS_MASTER_KEY
|
138
|
+
valueFrom:
|
139
|
+
secretKeyRef:
|
140
|
+
name: <%= config.fetch(:secrets_name) %>
|
141
|
+
key: rails-master-key
|
142
|
+
|
143
|
+
# liveness: Whether the pod is up.
|
144
|
+
# After `initialDelaySeconds` if this is failing Kube will crash+restart the pod.
|
145
|
+
livenessProbe:
|
146
|
+
initialDelaySeconds: 120
|
147
|
+
timeoutSeconds: 2
|
148
|
+
periodSeconds: 15
|
149
|
+
failureThreshold: 3
|
150
|
+
successThreshold: 1
|
151
|
+
|
152
|
+
# readiness: Whether the pod is ready to receive traffic.
|
153
|
+
# If this fails Kube will take the pod out of rotation until the pod becomes ready again.
|
154
|
+
readinessProbe:
|
155
|
+
initialDelaySeconds: 5
|
156
|
+
timeoutSeconds: 2
|
157
|
+
periodSeconds: 15 # time between failures
|
158
|
+
failureThreshold: 3 # fails required before probe counts as failed
|
159
|
+
successThreshold: 1 # successes required to mark the probe as ready again
|
160
|
+
|
161
|
+
# tests:
|
162
|
+
# apiFunctional:
|
163
|
+
# postman:
|
164
|
+
# collection: 5817358-93d711ed-3181-480d-bba5-ab68b0a29eae
|
165
|
+
# environment: 5817358-dccd7905-050c-4d93-a9bf-743eae208f46
|
166
|
+
# folder: Working
|
167
|
+
|
168
|
+
autoscaler:
|
169
|
+
minimumPods: 1
|
170
|
+
maximumPods: 1
|
171
|
+
targetCPUUtilizationPercentage: 70 # no effect if minimumPods == maximumPods
|