@catladder/cli 0.0.0-next-1cd29c1f → 0.0.0-next-52feb889

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.
Files changed (112) hide show
  1. package/dist/bundles/catenv/index.js +45 -9
  2. package/dist/bundles/cli/index.js +125 -11
  3. package/dist/bundles/runner-images/agent-claude/Dockerfile +5 -0
  4. package/dist/bundles/runner-images/docker-build/Dockerfile +26 -0
  5. package/dist/bundles/runner-images/docker-build/scripts/ensureMeteorDockerfile +55 -0
  6. package/dist/bundles/runner-images/docker-build/scripts/ensureNginxDockerfile +85 -0
  7. package/dist/bundles/runner-images/docker-build/scripts/ensureNodeDockerfile +50 -0
  8. package/dist/bundles/runner-images/gcloud/Dockerfile +3 -0
  9. package/dist/bundles/runner-images/jobs-default/Dockerfile +22 -0
  10. package/dist/bundles/runner-images/jobs-meteor/Dockerfile +7 -0
  11. package/dist/bundles/runner-images/jobs-testing-chrome/Dockerfile +15 -0
  12. package/dist/bundles/runner-images/kubernetes/Dockerfile +26 -0
  13. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.lock +9 -0
  14. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.yaml +14 -0
  15. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/README.md +24 -0
  16. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mailhog-5.0.1.tgz +0 -0
  17. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mongodb-12.1.27.tgz +0 -0
  18. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/myvalues.yaml +15 -0
  19. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/_helpers.tpl +202 -0
  20. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cloudsql-proxy-credentials.yml +10 -0
  21. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cronjobs.yml +69 -0
  22. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.autoscaler.yml +19 -0
  23. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.yml +103 -0
  24. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.configmap.yml +27 -0
  25. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.secrets.yml +10 -0
  26. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.redirects.yaml +91 -0
  27. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.yaml +48 -0
  28. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.jobs.yml +70 -0
  29. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.service.yaml +31 -0
  30. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.volumes.yml +20 -0
  31. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.deployment.yml +104 -0
  32. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.service.yaml +34 -0
  33. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mailhog.ingress.yaml +35 -0
  34. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.deployment.yml +45 -0
  35. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.service.yml +24 -0
  36. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mongodb.backup.cronjob.yml +120 -0
  37. package/dist/bundles/runner-images/kubernetes/helm-charts/the-panter-chart/values.yaml +154 -0
  38. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesCreateSecret +11 -0
  39. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesDelete +5 -0
  40. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesDeploy +57 -0
  41. package/dist/bundles/runner-images/kubernetes/scripts/kubernetesRollback +5 -0
  42. package/dist/bundles/runner-images/semantic-release/Dockerfile +24 -0
  43. package/dist/bundles/runner-images/semantic-release/scripts/semanticRelease +67 -0
  44. package/dist/cli/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.d.ts +12 -0
  45. package/dist/cli/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.js +64 -0
  46. package/dist/cli/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.js.map +1 -0
  47. package/dist/cli/src/apps/cli/commands/project/setup/index.js +3 -0
  48. package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
  49. package/dist/cli/src/config/getProjectConfig.d.ts +6 -0
  50. package/dist/cli/src/config/getProjectConfig.js +10 -1
  51. package/dist/cli/src/config/getProjectConfig.js.map +1 -1
  52. package/dist/cli/src/gcloud/cloudSql/copyDb.js +6 -2
  53. package/dist/cli/src/gcloud/cloudSql/copyDb.js.map +1 -1
  54. package/dist/pipeline/src/constants.js +1 -1
  55. package/dist/pipeline/src/context/index.d.ts +1 -0
  56. package/dist/pipeline/src/context/index.js +1 -0
  57. package/dist/pipeline/src/context/index.js.map +1 -1
  58. package/dist/pipeline/src/customImages/shippedImages.js +3 -1
  59. package/dist/pipeline/src/customImages/shippedImages.js.map +1 -1
  60. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +18 -3
  61. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -1
  62. package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +5 -1
  63. package/dist/pipeline/src/store/index.d.ts +4 -0
  64. package/dist/pipeline/src/store/index.js +12 -3
  65. package/dist/pipeline/src/store/index.js.map +1 -1
  66. package/dist/runner-images/agent-claude/Dockerfile +5 -0
  67. package/dist/runner-images/docker-build/Dockerfile +26 -0
  68. package/dist/runner-images/docker-build/scripts/ensureMeteorDockerfile +55 -0
  69. package/dist/runner-images/docker-build/scripts/ensureNginxDockerfile +85 -0
  70. package/dist/runner-images/docker-build/scripts/ensureNodeDockerfile +50 -0
  71. package/dist/runner-images/gcloud/Dockerfile +3 -0
  72. package/dist/runner-images/jobs-default/Dockerfile +22 -0
  73. package/dist/runner-images/jobs-meteor/Dockerfile +7 -0
  74. package/dist/runner-images/jobs-testing-chrome/Dockerfile +15 -0
  75. package/dist/runner-images/kubernetes/Dockerfile +26 -0
  76. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.lock +9 -0
  77. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/Chart.yaml +14 -0
  78. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/README.md +24 -0
  79. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mailhog-5.0.1.tgz +0 -0
  80. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/charts/mongodb-12.1.27.tgz +0 -0
  81. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/myvalues.yaml +15 -0
  82. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/_helpers.tpl +202 -0
  83. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cloudsql-proxy-credentials.yml +10 -0
  84. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.cronjobs.yml +69 -0
  85. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.autoscaler.yml +19 -0
  86. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.deployment.yml +103 -0
  87. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.configmap.yml +27 -0
  88. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.env.secrets.yml +10 -0
  89. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.redirects.yaml +91 -0
  90. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.ingress.yaml +48 -0
  91. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.jobs.yml +70 -0
  92. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.service.yaml +31 -0
  93. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.volumes.yml +20 -0
  94. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.deployment.yml +104 -0
  95. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/app.worker.service.yaml +34 -0
  96. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mailhog.ingress.yaml +35 -0
  97. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.deployment.yml +45 -0
  98. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/maintenance.service.yml +24 -0
  99. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/templates/mongodb.backup.cronjob.yml +120 -0
  100. package/dist/runner-images/kubernetes/helm-charts/the-panter-chart/values.yaml +154 -0
  101. package/dist/runner-images/kubernetes/scripts/kubernetesCreateSecret +11 -0
  102. package/dist/runner-images/kubernetes/scripts/kubernetesDelete +5 -0
  103. package/dist/runner-images/kubernetes/scripts/kubernetesDeploy +57 -0
  104. package/dist/runner-images/kubernetes/scripts/kubernetesRollback +5 -0
  105. package/dist/runner-images/semantic-release/Dockerfile +24 -0
  106. package/dist/runner-images/semantic-release/scripts/semanticRelease +67 -0
  107. package/dist/tsconfig.tsbuildinfo +1 -1
  108. package/package.json +3 -2
  109. package/src/apps/cli/commands/project/setup/ensureGcloudProjectNumbers.ts +61 -0
  110. package/src/apps/cli/commands/project/setup/index.ts +3 -0
  111. package/src/config/getProjectConfig.ts +9 -0
  112. package/src/gcloud/cloudSql/copyDb.ts +7 -2
@@ -0,0 +1,9 @@
1
+ dependencies:
2
+ - name: mongodb
3
+ repository: https://charts.bitnami.com/bitnami
4
+ version: 12.1.27
5
+ - name: mailhog
6
+ repository: https://codecentric.github.io/helm-charts
7
+ version: 5.0.1
8
+ digest: sha256:8963e4182d88c519cf73b6c1e18f9993827b7bf7b54432f56b7b8c5d758bcf8e
9
+ generated: "2022-07-25T19:15:40.334548+02:00"
@@ -0,0 +1,14 @@
1
+ apiVersion: v2
2
+ description: a chart to rule them all
3
+ name: the-panter-chart
4
+ version: 1.0.0 # should not matter
5
+
6
+ dependencies:
7
+ - name: mongodb
8
+ version: 12.1.27
9
+ condition: mongodb.enabled
10
+ repository: https://charts.bitnami.com/bitnami
11
+ - name: mailhog
12
+ version: 5.0.1
13
+ condition: mailhog.enabled
14
+ repository: https://codecentric.github.io/helm-charts
@@ -0,0 +1,24 @@
1
+ # The panter chart
2
+
3
+ **Main chart used in https://git.panter.ch/catladder/gitlab-ci/ **
4
+
5
+ Developing helm charts can be complex and they tend to be very verbose.
6
+ Our goal is therefore to provide a common chart that provides all functionalities that you might need
7
+ and make it configurable by values.yml files in your project.
8
+
9
+ This way we avoid having complexity in the projects and make it easier to share innovations and improvements.
10
+
11
+ ## Features
12
+
13
+ - scalable stateless webapplications, supports any technology
14
+ - ready-to-use but configurable ingress with optional redirects
15
+ - 1 optional worker pod (uses same image as webapp) for continuous background jobs
16
+ - configurable cronjobs
17
+ - configurable helm-hooks (post-install, post-uninstall, etc.)
18
+ - optional in-namespace mongodb. _kindof deprecated, We recommend to use google cloud dbs if possible._
19
+ - optional cloud-sql proxy that is available in webapp, worker, cronjobs and helm-hooks
20
+ - a lot of useful predefined env-vars in all pods.
21
+ - support for namespace secrets and custom env-vars (using catladder-shell and gitlab-ci)
22
+ - optional prisam1 (_deprecated, prisma2 does not need a separate instance anymore_)
23
+
24
+ See https://git.panter.ch/catladder/catladder/ for usage information
@@ -0,0 +1,15 @@
1
+ application:
2
+ command: main foo.js
3
+
4
+ env:
5
+ public:
6
+ FOO: bar
7
+ fromComponents:
8
+ api:
9
+ API_URL: ROOT_URL
10
+
11
+ cloudsql:
12
+ enabled: true
13
+
14
+ mailhog:
15
+ enabled: true
@@ -0,0 +1,202 @@
1
+ {{/* vim: set filetype=mustache: */}}
2
+ {{/*
3
+ Expand the name of the chart.
4
+ */}}
5
+ {{- define "name" -}}
6
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7
+ {{- end -}}
8
+
9
+
10
+ {{- define "appImage" -}}
11
+ {{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}
12
+ {{- end -}}
13
+
14
+
15
+ {{/*
16
+ Create a default fully qualified app name.
17
+ We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
18
+ */}}
19
+ {{- define "fullname" -}}
20
+ {{- default .Release.Name .Values.global.appName | trunc 63 | trimSuffix "-" -}}
21
+ {{- end -}}
22
+
23
+
24
+
25
+ {{/*
26
+ create a prefix for variable names, this is useful in service discovery in review apps
27
+ */}}
28
+ {{- define "serviceVarPrefix" -}}
29
+ {{ include "fullname" . | snakecase | upper }}
30
+ {{- end -}}
31
+
32
+
33
+ {{/*
34
+ Create chart name and version as used by the chart label.
35
+ */}}
36
+ {{- define "chart" -}}
37
+ {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
38
+ {{- end -}}
39
+
40
+
41
+ {{/*
42
+ get the right host
43
+ */}}
44
+ {{- define "host" -}}
45
+ {{- default .Values.application.hostCanonical .Values.application.host -}}
46
+ {{- end -}}
47
+
48
+ {{- define "MAILHOG_SMTP_URL" -}}
49
+ {{- $namespace := .Release.Namespace -}}
50
+ {{- printf "smtp://%s.%s.svc.cluster.local:1025" .Values.mailhog.fullnameOverride $namespace -}}
51
+ {{- end -}}
52
+
53
+ {{- define "DB_NAME" -}}
54
+ {{ .Values.cloudsql.fullDbName }}
55
+ {{- end -}}
56
+
57
+ {{- define "POSTGRESQL_URL" -}}
58
+ postgresql://{{ .Values.cloudsql.dbUser }}:$(POSTGRESQL_PASSWORD)@localhost/{{ .Values.cloudsql.fullDbName }}?schema=public
59
+ {{- end -}}
60
+
61
+ {{- define "POSTGRESQL_HOST" -}}
62
+ localhost
63
+ {{- end -}}
64
+
65
+ {{- define "DB_USERNAME" -}}
66
+ {{ .Values.cloudsql.dbUser }}
67
+ {{- end -}}
68
+
69
+
70
+ {{- define "DB_PASSWORD" -}}
71
+ $(POSTGRESQL_PASSWORD)
72
+ {{- end -}}
73
+
74
+
75
+ {{- define "cloudSqlContainer" -}}
76
+ name: cloudsql-proxy
77
+ image: eu.gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.0-alpine
78
+ # see https://github.com/kubernetes/kubernetes/issues/25908#issuecomment-308569672
79
+ # and https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/753-sidecar-containers
80
+ command: ["/bin/sh", "-c"]
81
+ args:
82
+ - |
83
+ /cloud-sql-proxy --auto-ip --credentials-file /secrets/cloudsql/credentials.json "{{ .Values.cloudsql.instanceConnectionName }}" &
84
+ CHILD_PID=$!
85
+ (while true; do if [[ -f "/tmp/pod/main-terminated" ]]; then kill $CHILD_PID; fi; sleep 1; done) &
86
+ wait $CHILD_PID
87
+ if [[ -f "/tmp/pod/main-terminated" ]]; then exit 0; fi
88
+ securityContext:
89
+ runAsUser: 2 # non-root user
90
+ allowPrivilegeEscalation: false
91
+ resources: # each container needs requests, or the auto load balancer does not work
92
+ requests:
93
+ cpu: 50m
94
+ memory: 150Mi
95
+ volumeMounts:
96
+ - name: cloudsql-proxy-credentials
97
+ mountPath: /secrets/cloudsql
98
+ readOnly: true
99
+
100
+ - mountPath: /tmp/pod
101
+ name: tmp-pod
102
+ readOnly: true
103
+ {{- end -}}
104
+
105
+ {{- define "cloudSqlCredentialsVolume" -}}
106
+ name: cloudsql-proxy-credentials
107
+ secret:
108
+ secretName: {{ template "fullname" $ }}-cloudsql-proxy-credentials
109
+ {{- end -}}
110
+ {{/*
111
+ Generate prisma-URL
112
+ */}}
113
+ {{- define "PRISMA_ENDPOINT" -}}
114
+ {{- $appName := default .Release.Name .Values.global.appName -}}
115
+ {{- $namespace := .Release.Namespace -}}
116
+ {{- printf "http://%s-prisma.%s:4466/default/default" $appName $namespace -}}
117
+ {{- end -}}
118
+
119
+
120
+
121
+
122
+ {{/*
123
+ convert value to json-string if its an object
124
+ */}}
125
+ {{- define "envValue" -}}
126
+ {{- if (kindIs "map" .) -}}
127
+ {{ toJson . | quote}}
128
+ {{- else -}}
129
+ {{ quote . }}
130
+ {{- end -}}
131
+ {{- end -}}
132
+
133
+
134
+ {{- define "env" -}}
135
+ {{ $context := . }}
136
+
137
+
138
+
139
+ envFrom:
140
+ - configMapRef:
141
+ name: {{ template "fullname" $ }}-app-env
142
+ env:
143
+ {{- range $key, $val := .Values.env.secret }}
144
+ - name: {{ $key }}
145
+ valueFrom:
146
+ secretKeyRef:
147
+ name: {{ template "fullname" $ }}-app-secrets
148
+ key: {{ $key }}
149
+ {{- end }}
150
+
151
+ {{- range $key, $val := .Values.secretsFromOtherComponent }}
152
+
153
+ - name: {{ $key }}
154
+ valueFrom:
155
+ secretKeyRef:
156
+ name: {{ $.Values.global.appPrefix}}{{ $val }}-app-secrets
157
+ key: {{ $key }}
158
+ optional: true
159
+ {{- end }}
160
+
161
+ {{- range $key, $val := .Values.mapServiceUrlToEnv }}
162
+ {{- $otherServiceFullName := (printf "%s%s" $.Values.global.appPrefix $val) }}
163
+ {{- $variablePrefix := $otherServiceFullName | snakecase | upper }}
164
+ - name: {{ $key }}
165
+ value: "http://$({{ $variablePrefix }}_SERVICE_HOST):$({{ $variablePrefix }}_SERVICE_PORT)"
166
+ {{- end }}
167
+
168
+ # can't have these in app.env.configmap as some values contain $(OTHER_ENV_VAR)
169
+ {{ if .Values.cloudsql.enabled }}
170
+ - name: POSTGRESQL_URL
171
+ value: "{{- template "POSTGRESQL_URL" . -}}"
172
+ - name: DATABASE_URL
173
+ value: "{{- template "POSTGRESQL_URL" . -}}"
174
+
175
+ - name: POSTGRESQL_HOST
176
+ value: "{{- template "POSTGRESQL_HOST" . -}}"
177
+ - name: DB_HOST # alias
178
+ value: "{{- template "POSTGRESQL_HOST" . -}}"
179
+ - name: DB_NAME
180
+ value: "{{- template "DB_NAME" . -}}"
181
+ - name: DB_USERNAME #alias
182
+ value: "{{- template "DB_USERNAME" . -}}"
183
+ - name: DB_PASSWORD #alias
184
+ value: "{{- template "DB_PASSWORD" . -}}"
185
+ - name: POSTGRESQL_DBNAME # alias
186
+ value: "{{- template "DB_NAME" . -}}"
187
+ {{- end -}}
188
+
189
+ {{- end -}}
190
+
191
+
192
+
193
+ {{- define "visualReviewSnippet" -}}
194
+ <script
195
+ data-project-id='{{.Values.gitlab.projectId}}'
196
+ data-merge-request-id='{{.Values.gitlab.mergeRequestId}}'
197
+ data-mr-url='https://git.panter.ch'
198
+ data-project-path='{{.Values.gitlab.projectPath}}'
199
+ id='review-app-toolbar-script'
200
+ src='https://git.panter.ch/assets/webpack/visual_review_toolbar.js'>
201
+ </script>
202
+ {{- end -}}
@@ -0,0 +1,10 @@
1
+ {{- if .Values.cloudsql.enabled -}}
2
+ apiVersion: v1
3
+ kind: Secret
4
+ metadata:
5
+ name: {{ template "fullname" . }}-cloudsql-proxy-credentials
6
+ labels:
7
+ app: {{ .Release.Name }}
8
+ data:
9
+ credentials.json: {{ .Values.cloudsql.proxyCredentials | b64enc}}
10
+ {{- end }}
@@ -0,0 +1,69 @@
1
+
2
+ {{ $jobs := .Values.cronjobs }}
3
+ {{ if $jobs }}
4
+ {{ $context := . }}
5
+ {{ range $key, $job := $jobs -}}
6
+
7
+ {{- $name := (kindIs "map" $jobs) | ternary $key $job.name -}}
8
+
9
+ apiVersion: batch/v1
10
+ kind: CronJob
11
+
12
+ metadata:
13
+ name: {{ include "fullname" $context | trunc 24}}-{{ $name | trunc 35 | lower }}
14
+ namespace: {{ $context.Release.Namespace }}
15
+ labels:
16
+ app: {{ $context.Release.Name }}
17
+ app.kubernetes.io/managed-by: {{$context.Release.Service | quote }}
18
+ app.kubernetes.io/instance: {{$context.Release.Name | quote }}
19
+ helm.sh/chart: "{{$context.Chart.Name}}-{{$context.Chart.Version}}"
20
+
21
+ spec:
22
+ schedule: {{ $job.schedule | quote}}
23
+ {{if $job.timeZone -}}
24
+ timeZone: {{ $job.timeZone | quote }}
25
+ {{end}}
26
+ # concerning concurreny we also set it to allow as default like in kubernetes i
27
+ # see https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#concurrency-policy
28
+ concurrencyPolicy: "{{- default "Allow" $job.concurrencyPolicy -}}"
29
+ jobTemplate:
30
+ spec:
31
+ template:
32
+ spec:
33
+ {{- if $context.Values.image.pullSecret }}
34
+ imagePullSecrets:
35
+ - name: {{ $context.Values.image.pullSecret }}
36
+ {{- end }}
37
+ restartPolicy: Never
38
+ containers:
39
+ - name: {{ $name }}-cronjob
40
+ {{include "env" $context | nindent 12}}
41
+ {{if $job.image -}}
42
+ image: "{{ $job.image }}"
43
+ {{else}}
44
+ image: "{{ template "appImage" $context}}"
45
+ {{end}}
46
+ imagePullPolicy: {{ $context.Values.image.pullPolicy }}
47
+ # see https://github.com/kubernetes/kubernetes/issues/25908#issuecomment-308569672
48
+ command: ["/bin/sh", "-c"]
49
+ args:
50
+ - |
51
+ trap "touch /tmp/pod/main-terminated" EXIT
52
+ {{$job.command}}
53
+ volumeMounts:
54
+ - mountPath: /tmp/pod
55
+ name: tmp-pod
56
+ resources:
57
+ {{ toYaml $context.Values.jobDefaults.resources | indent 14 }}
58
+ {{if $context.Values.cloudsql.enabled}}
59
+ - {{- include "cloudSqlContainer" $context | nindent 12 }}
60
+ {{- end }}
61
+ volumes:
62
+ - name: tmp-pod
63
+ emptyDir: {}
64
+ {{if $context.Values.cloudsql.enabled}}
65
+ - {{- include "cloudSqlCredentialsVolume" $context | nindent 14 }}
66
+ {{- end }}
67
+ ---
68
+ {{- end }}
69
+ {{- end }}
@@ -0,0 +1,19 @@
1
+
2
+ {{- if .Values.application.enabled -}}
3
+ {{- if .Values.application.autoscale -}}
4
+ {{ $context := . }}
5
+
6
+ apiVersion: autoscaling/v2
7
+ kind: HorizontalPodAutoscaler
8
+ metadata:
9
+ name: {{ template "fullname" $context }}-app-autoscaler
10
+ spec:
11
+ scaleTargetRef:
12
+ apiVersion: apps/v1
13
+ kind: Deployment
14
+ name: {{ template "fullname" $context }}-app
15
+ {{ toYaml .Values.application.autoscale | indent 2 }}
16
+
17
+ {{- end }}
18
+ {{- end }}
19
+
@@ -0,0 +1,103 @@
1
+
2
+ {{- if .Values.application.enabled -}}
3
+ {{ $context := . }}
4
+
5
+ apiVersion: apps/v1
6
+ kind: Deployment
7
+ metadata:
8
+ name: {{ template "fullname" $context }}-app
9
+ annotations:
10
+ "cluster-autoscaler.kubernetes.io/safe-to-evict": "true"
11
+ {{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
12
+ {{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
13
+ labels:
14
+ app: {{ .Release.Name }}
15
+ namespace: {{ .Release.Namespace }}
16
+ spec:
17
+ replicas: {{ .Values.application.replicas }}
18
+ revisionHistoryLimit: 2
19
+ selector:
20
+ matchLabels:
21
+ app: {{ template "fullname" $context }}-app
22
+ release: {{ .Release.Name }}
23
+ strategy:
24
+ {{ toYaml .Values.application.updateStrategy | indent 4 }}
25
+ template:
26
+ metadata:
27
+ annotations:
28
+ {{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
29
+ {{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
30
+ labels:
31
+ app: {{ template "fullname" $context }}-app
32
+ release: {{ .Release.Name }}
33
+ spec:
34
+ {{- if .Values.image.pullSecret }}
35
+ imagePullSecrets:
36
+ - name: {{ .Values.image.pullSecret }}
37
+ {{- end }}
38
+ dnsPolicy: ClusterFirst
39
+ restartPolicy: Always
40
+ schedulerName: default-scheduler
41
+ securityContext: {}
42
+ terminationGracePeriodSeconds: 30
43
+ tolerations:
44
+ {{- if and .Values.global.ENV_SHORT (eq .Values.global.ENV_SHORT "review")}}
45
+ - key: "stage"
46
+ operator: "Equal"
47
+ value: "review"
48
+ effect: "NoSchedule"
49
+ {{- end }}
50
+
51
+ containers:
52
+ - name: {{ template "fullname" $context }}-app
53
+ image: "{{ template "appImage" .}}"
54
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
55
+ {{ if .Values.application.command }}
56
+
57
+ command: ["/bin/sh", "-c"]
58
+ args:
59
+ - |
60
+ {{(kindIs "slice" .Values.application.command) | ternary (join " " .Values.application.command) .Values.application.command}}
61
+
62
+ {{- end }}
63
+ {{include "env" $context | nindent 8}}
64
+ startupProbe:
65
+ {{ toYaml .Values.application.startupProbe | indent 10 }}
66
+ livenessProbe:
67
+ {{ toYaml .Values.application.livenessProbe | indent 10 }}
68
+ readinessProbe:
69
+ {{ toYaml .Values.application.readinessProbe | indent 10 }}
70
+ ports:
71
+ - containerPort: 8080
72
+ protocol: TCP
73
+ resources:
74
+ {{ toYaml .Values.application.resources | indent 10 }}
75
+ terminationMessagePath: /dev/termination-log
76
+ terminationMessagePolicy: File
77
+ volumeMounts:
78
+
79
+ {{- range $key, $volume := .Values.application.volumes }}
80
+ - mountPath: {{$volume.mountPath}}
81
+ name: {{ template "fullname" $context }}-{{$volume.name}}
82
+ {{- end }}
83
+
84
+
85
+ {{if .Values.cloudsql.enabled}}
86
+ - {{- include "cloudSqlContainer" $context | nindent 8 }}
87
+ {{- end }}
88
+ volumes:
89
+
90
+ {{if .Values.cloudsql.enabled}}
91
+ - name: tmp-pod # required for a hack
92
+ emptyDir: {}
93
+ {{- end }}
94
+ {{- range $key, $volume := .Values.application.volumes }}
95
+ - name: {{ template "fullname" $context }}-{{$volume.name}}
96
+ persistentVolumeClaim:
97
+ claimName: {{ template "fullname" $context }}-{{$volume.name}}
98
+ {{- end }}
99
+ {{if .Values.cloudsql.enabled}}
100
+ - {{- include "cloudSqlCredentialsVolume" $context | nindent 10 }}
101
+ {{- end }}
102
+ {{- end }}
103
+
@@ -0,0 +1,27 @@
1
+
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: {{ template "fullname" . }}-app-env
6
+ labels:
7
+ app: {{ .Release.Name }}
8
+ namespace: {{ .Release.Namespace }}
9
+ data:
10
+ PORT: "8080"
11
+ TZ: Europe/Zurich
12
+ ENV_SHORT: {{ .Values.global.ENV_SHORT }}
13
+ SERVICE_VAR_PREFIX: "{{- template "serviceVarPrefix" . -}}"
14
+
15
+ {{ if .Values.mailhog.enabled }}
16
+ MAILHOG_SMTP_URL: "{{- template "MAILHOG_SMTP_URL" . -}}"
17
+ MAIL_URL: "{{- template "MAILHOG_SMTP_URL" . -}}"
18
+ {{- end -}}
19
+
20
+ {{- range $key, $val := .Values.env.public }}
21
+ {{ $key }}: {{ template "envValue" $val }}
22
+ {{- end -}}
23
+
24
+
25
+
26
+
27
+
@@ -0,0 +1,10 @@
1
+ apiVersion: v1
2
+ kind: Secret
3
+ metadata:
4
+ name: {{ template "fullname" . }}-app-secrets
5
+ labels:
6
+ app: {{ .Release.Name }}
7
+ data:
8
+ {{- range $key, $val := .Values.env.secret }}
9
+ {{ $key }}: {{ $val | b64enc }}
10
+ {{- end}}
@@ -0,0 +1,91 @@
1
+ {{- if .Values.application -}}
2
+ {{ $app := .Values.application }}
3
+ {{ $serviceName := include "fullname" . }}
4
+ {{ $servicePort := .Values.service.externalPort }}
5
+
6
+ {{ $hastCustomHost := ne $app.hostCanonical (default $app.hostCanonical $app.host) }}
7
+ # if it has a custom host, add a redirect from canonical to custom host
8
+ {{if $hastCustomHost -}}
9
+ apiVersion: networking.k8s.io/v1
10
+ kind: Ingress
11
+ metadata:
12
+ name: {{ template "fullname" . }}-{{ $app.hostCanonical }}-redirect
13
+ labels:
14
+ app: {{ template "name" . }}
15
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
16
+ release: {{ .Release.Name }}
17
+ heritage: {{ .Release.Service }}
18
+ annotations:
19
+ {{- range $key, $value := .Values.ingress.annotations }}
20
+ {{ $key }}: {{ $value | quote }}
21
+ {{- end }}
22
+ nginx.ingress.kubernetes.io/configuration-snippet: |
23
+ return 301 $scheme://{{ template "host" . }}$request_uri;
24
+ spec:
25
+ rules:
26
+ - host: {{ $app.hostCanonical}}
27
+ http:
28
+ paths:
29
+ - path: /
30
+ pathType: ImplementationSpecific
31
+ backend:
32
+ service:
33
+ name: {{ template "fullname" . }}-app
34
+ port:
35
+ number: {{ $servicePort }}
36
+ tls:
37
+ - secretName: {{ $app.hostCanonical | trunc 59 | trimSuffix "." }}-tls
38
+ hosts:
39
+ - {{ $app.hostCanonical }}
40
+ ---
41
+ {{- end }}
42
+
43
+ {{ if $app.redirects }}
44
+ {{ $context := . }}
45
+ {{ range $index, $redirect := $app.redirects -}}
46
+
47
+ apiVersion: networking.k8s.io/v1
48
+ kind: Ingress
49
+ metadata:
50
+ {{- if $redirect.path }}
51
+ name: {{ template "fullname" $context }}-{{ $redirect.host }}-{{ $index }}-redirect
52
+ {{- else }}
53
+ name: {{ template "fullname" $context }}-{{ $redirect.host }}-redirect
54
+ {{- end }}
55
+ labels:
56
+ app: {{ template "name" $context }}
57
+ chart: {{$context.Chart.Name }}-{{$context.Chart.Version | replace "+" "_" }}
58
+ release: {{$context.Release.Name }}
59
+ heritage: {{$context.Release.Service }}
60
+ annotations:
61
+ {{- range $key, $value := $context.Values.ingress.annotations }}
62
+ {{ $key }}: {{ $value | quote }}
63
+ {{- end }}
64
+ {{- if $redirect.rule}}
65
+ nginx.ingress.kubernetes.io/configuration-snippet: |
66
+ {{ $redirect.rule }}
67
+ {{ else }}
68
+ nginx.ingress.kubernetes.io/configuration-snippet: |
69
+ return 301 $scheme://{{ template "host" $context }}$request_uri;
70
+ {{- end }}
71
+
72
+ spec:
73
+ rules:
74
+ - host: {{ $redirect.host}}
75
+ http:
76
+ paths:
77
+ - path: {{ $redirect.path | default "/" }}
78
+ pathType: ImplementationSpecific
79
+ backend:
80
+ service:
81
+ name: {{ template "fullname" $context }}-app
82
+ port:
83
+ number: {{ $servicePort }}
84
+ tls:
85
+ - secretName: {{ $redirect.host | trunc 59 | trimSuffix "." }}-tls
86
+ hosts:
87
+ - {{ $redirect.host }}
88
+ ---
89
+ {{- end }}
90
+ {{- end }}
91
+ {{- end }}
@@ -0,0 +1,48 @@
1
+ {{- if .Values.ingress.enabled -}}
2
+ {{- if .Values.application.enabled -}}
3
+ {{- $servicePort := .Values.service.externalPort -}}
4
+ {{- $app := .Values.application -}}
5
+ {{ $hosts := without (prepend (default (list nil) $app.hostAliases) (include "host" .)) nil }}
6
+ apiVersion: networking.k8s.io/v1
7
+ kind: Ingress
8
+ metadata:
9
+ name: {{ template "fullname" . }}-app
10
+ labels:
11
+ app: {{ template "name" . }}
12
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
13
+ release: {{ .Release.Name }}
14
+ heritage: {{ .Release.Service }}
15
+ annotations:
16
+ nginx.ingress.kubernetes.io/rewrite-target: /$1
17
+ nginx.ingress.kubernetes.io/configuration-snippet: |
18
+ more_set_headers "x-build-id: {{ .Values.global.BUILD_ID }}";
19
+ {{- if and .Values.gitlab.visualReviewEnabled (and .Values.global.ENV_SHORT (eq .Values.global.ENV_SHORT "review"))}}
20
+ proxy_set_header Accept-Encoding "";
21
+ sub_filter_once on;
22
+ sub_filter "</head>" "{{- include "visualReviewSnippet" . | nindent 8 -}}</head>";
23
+ {{- end }}
24
+ {{- range $key, $value := .Values.ingress.annotations }}
25
+ {{ $key }}: {{ $value | quote }}
26
+ {{- end }}
27
+ spec:
28
+ rules:
29
+ {{- range $hosts }}
30
+ - host: {{ . }}
31
+ http:
32
+ paths:
33
+ - path: /?(.*)
34
+ pathType: ImplementationSpecific
35
+ backend:
36
+ service:
37
+ name: {{ template "fullname" $ }}-app
38
+ port:
39
+ number: {{ $servicePort }}
40
+ {{- end }}
41
+ tls:
42
+ - secretName: {{ include "host" . | trunc 59 | trimSuffix "." }}-tls
43
+ hosts:
44
+ {{- range $hosts }}
45
+ - {{ . }}
46
+ {{- end }}
47
+ {{- end -}}
48
+ {{- end -}}