Repository navigation
Expand file tree
/
Copy pathdeployment.yaml
More file actions
224 lines (215 loc) · 8.09 KB
/
Copy pathdeployment.yaml
File metadata and controls
224 lines (215 loc) · 8.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
{{- include "hyperfleet-api.validateValues" . }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "hyperfleet-api.fullname" . }}
labels:
{{- include "hyperfleet-api.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- with .Values.strategy }}
strategy:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "hyperfleet-api.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
# Force pod restart when ConfigMap changes
{{- if .Values.config.existingConfigMap }}
# Checksum of external ConfigMap (via lookup)
checksum/config: {{ (lookup "v1" "ConfigMap" .Release.Namespace .Values.config.existingConfigMap).data | toYaml | sha256sum }}
{{- else }}
# Checksum of generated ConfigMap
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.validationSchema.enabled }}
{{- if .Values.validationSchema.existingConfigMap }}
checksum/validation-schema: {{ (lookup "v1" "ConfigMap" .Release.Namespace .Values.validationSchema.existingConfigMap).data | toYaml | sha256sum }}
{{- else }}
checksum/validation-schema: {{ include (print $.Template.BasePath "/validation-schema-configmap.yaml") . | sha256sum }}
{{- end }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "hyperfleet-api.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "hyperfleet-api.serviceAccountName" . }}
{{- if .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if and .Values.nativeSidecars (not (semverCompare ">=1.28.0-0" .Capabilities.KubeVersion.Version)) }}
{{- fail "nativeSidecars requires Kubernetes >= 1.28 (SidecarContainers feature gate). Remove nativeSidecars or upgrade your cluster." }}
{{- end }}
{{- if or .Values.nativeSidecars (or .Values.database.postgresql.enabled .Values.database.external.enabled) }}
initContainers:
{{- range .Values.nativeSidecars }}
- {{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.database.postgresql.enabled .Values.database.external.enabled }}
{{- if .Values.database.postgresql.enabled }}
- name: wait-for-db
image: busybox:1.36
command: ['sh', '-c', 'until nc -z {{ include "hyperfleet-api.fullname" . }}-postgresql {{ .Values.database.postgresql.port }}; do echo waiting for postgresql; sleep 2; done']
{{- end }}
- name: db-migrate
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/app/hyperfleet-api", "migrate"]
env:
# Config file from ConfigMap
- name: HYPERFLEET_CONFIG
value: /etc/hyperfleet/config.yaml
# Database credentials from Secret (using secretKeyRef)
{{- include "hyperfleet-api.databaseEnvVars" . | nindent 8 }}
volumeMounts:
- name: config
mountPath: /etc/hyperfleet
readOnly: true
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
workingDir: /app
# Simple command - configuration via ConfigMap and environment variables
args:
- serve
ports:
- name: http
containerPort: {{ .Values.ports.api | default 8000 }}
protocol: TCP
- name: health
containerPort: {{ .Values.ports.health | default 8080 }}
protocol: TCP
- name: metrics
containerPort: {{ .Values.ports.metrics | default 9090 }}
protocol: TCP
env:
# Config file from ConfigMap (generated from values)
- name: HYPERFLEET_CONFIG
value: /etc/hyperfleet/config.yaml
{{- with .Values.monitoring.tracing }}
- name: HYPERFLEET_TRACING_ENABLED
value: {{ .enabled | quote }}
{{- if .enabled }}
- name: OTEL_SERVICE_NAME
value: {{ .serviceName | quote }}
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: {{ .otlpEndpoint | quote }}
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: {{ .otlpProtocol | quote }}
- name: OTEL_TRACES_SAMPLER
value: {{ .sampler | quote }}
- name: OTEL_TRACES_SAMPLER_ARG
value: {{ .samplerArg | quote }}
- name: OTEL_PROPAGATORS
value: {{ .propagators | quote }}
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: OTEL_RESOURCE_ATTRIBUTES
value: "k8s.namespace.name=$(K8S_NAMESPACE)"
{{- end }}
{{- end }}
# Database credentials from Secret (using secretKeyRef)
{{- include "hyperfleet-api.databaseEnvVars" . | nindent 8 }}
# Extra environment variables (escape hatch for overrides)
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 8 }}
{{- end }}
livenessProbe:
httpGet:
path: /healthz
port: health
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /readyz
port: health
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
resources:
{{- toYaml .Values.resources | nindent 10 }}
{{- with .Values.lifecycle }}
lifecycle:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
# ConfigMap mount - generated from values or existingConfigMap
- name: config
mountPath: /etc/hyperfleet
readOnly: true
{{- if .Values.validationSchema.enabled }}
- name: validation-schema
mountPath: /etc/hyperfleet/validation-schema
readOnly: true
{{- end }}
# Temp directory for writable filesystem
- name: tmp
mountPath: /tmp
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- range .Values.sidecars }}
- {{- toYaml . | nindent 8 }}
{{- end }}
volumes:
# ConfigMap volume - use existing or generated from values
- name: config
configMap:
{{- if .Values.config.existingConfigMap }}
name: {{ .Values.config.existingConfigMap }}
{{- else }}
name: {{ include "hyperfleet-api.fullname" . }}-config
{{- end }}
- name: tmp
emptyDir: {}
{{- if .Values.validationSchema.enabled }}
- name: validation-schema
configMap:
{{- if .Values.validationSchema.existingConfigMap }}
name: {{ .Values.validationSchema.existingConfigMap }}
{{- else }}
name: {{ include "hyperfleet-api.fullname" . }}-validation-schema
{{- end }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}