|
| 1 | +{{- if .Values.separateAdminAndPublicDeploys -}} |
| 2 | +{{- include "hydra.automigration.typeVerification" . -}} |
| 3 | +{{- $deployValues := merge .Values.deployment.admin (omit .Values.deployment "admin" "public") -}} |
| 4 | +{{- $migrationExtraEnv := ternary $deployValues.automigration.extraEnv $deployValues.extraEnv (not (empty $deployValues.automigration.extraEnv )) -}} |
| 5 | + |
| 6 | +--- |
| 7 | +apiVersion: apps/v1 |
| 8 | +kind: Deployment |
| 9 | +metadata: |
| 10 | + name: {{ include "hydra.fullname" . }}-admin |
| 11 | + {{- if .Release.Namespace }} |
| 12 | + namespace: {{ .Release.Namespace }} |
| 13 | + {{- end }} |
| 14 | + labels: |
| 15 | + {{- include "hydra.labels" . | nindent 4 }} |
| 16 | + {{- with $deployValues.labels }} |
| 17 | + {{- toYaml . | nindent 4 }} |
| 18 | + {{- end }} |
| 19 | + app.kubernetes.io/component: admin |
| 20 | + annotations: |
| 21 | + {{- with $deployValues.annotations }} |
| 22 | + {{- toYaml . | nindent 4 }} |
| 23 | + {{- end }} |
| 24 | +spec: |
| 25 | +{{- if not $deployValues.autoscaling.enabled }} |
| 26 | + replicas: {{ .Values.replicaCount }} |
| 27 | +{{- end }} |
| 28 | + revisionHistoryLimit: {{ $deployValues.revisionHistoryLimit }} |
| 29 | + strategy: |
| 30 | + {{- toYaml $deployValues.strategy | nindent 4 }} |
| 31 | + selector: |
| 32 | + matchLabels: |
| 33 | + app.kubernetes.io/name: {{ include "hydra.name" . }} |
| 34 | + app.kubernetes.io/instance: {{ .Release.Name }} |
| 35 | + app.kubernetes.io/component: admin |
| 36 | + template: |
| 37 | + metadata: |
| 38 | + labels: |
| 39 | + {{- include "hydra.labels" . | nindent 8 }} |
| 40 | + {{- with $deployValues.labels }} |
| 41 | + {{- toYaml . | nindent 8 }} |
| 42 | + {{- end }} |
| 43 | + {{- with $deployValues.podMetadata.labels }} |
| 44 | + {{- toYaml . | nindent 8 }} |
| 45 | + {{- end }} |
| 46 | + app.kubernetes.io/component: admin |
| 47 | + annotations: |
| 48 | + {{- include "hydra.annotations.checksum" . | nindent 8 -}} |
| 49 | + {{- with $deployValues.annotations }} |
| 50 | + {{- toYaml . | nindent 8 }} |
| 51 | + {{- end }} |
| 52 | + {{- with $deployValues.podMetadata.annotations }} |
| 53 | + {{- toYaml . | nindent 8 }} |
| 54 | + {{- end }} |
| 55 | + spec: |
| 56 | + {{- with .Values.imagePullSecrets }} |
| 57 | + imagePullSecrets: |
| 58 | + {{- toYaml . | nindent 8 }} |
| 59 | + {{- end }} |
| 60 | + volumes: |
| 61 | + - name: {{ include "hydra.name" . }}-config-volume |
| 62 | + configMap: |
| 63 | + name: {{ include "hydra.fullname" . }} |
| 64 | + {{- if $deployValues.extraVolumes }} |
| 65 | + {{- toYaml $deployValues.extraVolumes | nindent 8 }} |
| 66 | + {{- end }} |
| 67 | + serviceAccountName: {{ include "hydra.serviceAccountName" . }} |
| 68 | + automountServiceAccountToken: {{ $deployValues.automountServiceAccountToken }} |
| 69 | + terminationGracePeriodSeconds: {{ $deployValues.terminationGracePeriodSeconds }} |
| 70 | + containers: |
| 71 | + - name: {{ .Chart.Name }}-admin |
| 72 | + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" |
| 73 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 74 | + command: {{- toYaml .Values.hydra.command | nindent 12 }} |
| 75 | + {{- if .Values.hydra.customArgs }} |
| 76 | + args: {{- toYaml .Values.hydra.customArgs | nindent 12 }} |
| 77 | + {{- else }} |
| 78 | + args: |
| 79 | + - serve |
| 80 | + - admin |
| 81 | + {{- if .Values.hydra.dev }} |
| 82 | + - "--dev" |
| 83 | + {{- end }} |
| 84 | + - --config |
| 85 | + - /etc/config/hydra.yaml |
| 86 | + {{- end }} |
| 87 | + volumeMounts: |
| 88 | + - name: {{ include "hydra.name" . }}-config-volume |
| 89 | + mountPath: /etc/config |
| 90 | + readOnly: true |
| 91 | + {{- if $deployValues.extraVolumeMounts }} |
| 92 | + {{- toYaml $deployValues.extraVolumeMounts | nindent 12 }} |
| 93 | + {{- end }} |
| 94 | + ports: |
| 95 | + - name: http-admin |
| 96 | + containerPort: {{ .Values.hydra.config.serve.admin.port }} |
| 97 | + protocol: TCP |
| 98 | + livenessProbe: |
| 99 | + {{- if $deployValues.customLivenessProbe }} |
| 100 | + {{- toYaml $deployValues.customLivenessProbe | nindent 12 }} |
| 101 | + {{- else }} |
| 102 | + httpGet: |
| 103 | + path: /health/alive |
| 104 | + port: {{ .Values.hydra.config.serve.admin.port }} |
| 105 | + httpHeaders: |
| 106 | + - name: Host |
| 107 | + value: '127.0.0.1' |
| 108 | + {{- toYaml $deployValues.livenessProbe | nindent 12 }} |
| 109 | + {{- end }} |
| 110 | + readinessProbe: |
| 111 | + {{- if $deployValues.customReadinessProbe }} |
| 112 | + {{- toYaml $deployValues.customReadinessProbe | nindent 12 }} |
| 113 | + {{- else }} |
| 114 | + httpGet: |
| 115 | + path: /health/ready |
| 116 | + port: {{ .Values.hydra.config.serve.admin.port }} |
| 117 | + httpHeaders: |
| 118 | + - name: Host |
| 119 | + value: '127.0.0.1' |
| 120 | + {{- toYaml $deployValues.readinessProbe | nindent 12 }} |
| 121 | + {{- end }} |
| 122 | + startupProbe: |
| 123 | + {{- if $deployValues.customStartupProbe }} |
| 124 | + {{- toYaml $deployValues.customStartupProbe | nindent 12 }} |
| 125 | + {{- else }} |
| 126 | + httpGet: |
| 127 | + path: /health/ready |
| 128 | + port: {{ .Values.hydra.config.serve.admin.port }} |
| 129 | + httpHeaders: |
| 130 | + - name: Host |
| 131 | + value: '127.0.0.1' |
| 132 | + {{- toYaml $deployValues.startupProbe | nindent 12 }} |
| 133 | + {{- end }} |
| 134 | + env: |
| 135 | + {{- $issuer := include "hydra.config.urls.issuer" . -}} |
| 136 | + {{- if $issuer }} |
| 137 | + - name: URLS_SELF_ISSUER |
| 138 | + value: {{ $issuer | quote }} |
| 139 | + {{- end }} |
| 140 | + {{- if not (empty ( include "hydra.dsn" . )) }} |
| 141 | + {{- if not (include "ory.extraEnvContainsEnvName" (list $deployValues.extraEnv "DSN")) }} |
| 142 | + - name: DSN |
| 143 | + valueFrom: |
| 144 | + secretKeyRef: |
| 145 | + name: {{ include "hydra.secretname" . }} |
| 146 | + key: dsn |
| 147 | + {{- end }} |
| 148 | + {{- end }} |
| 149 | + - name: SECRETS_SYSTEM |
| 150 | + valueFrom: |
| 151 | + secretKeyRef: |
| 152 | + name: {{ include "hydra.secretname" . }} |
| 153 | + key: secretsSystem |
| 154 | + - name: SECRETS_COOKIE |
| 155 | + valueFrom: |
| 156 | + secretKeyRef: |
| 157 | + name: {{ include "hydra.secretname" . }} |
| 158 | + key: secretsCookie |
| 159 | + {{- if $deployValues.extraEnv }} |
| 160 | + {{- tpl (toYaml $deployValues.extraEnv) . | nindent 12 }} |
| 161 | + {{- end }} |
| 162 | + resources: |
| 163 | + {{- toYaml $deployValues.resources | nindent 12 }} |
| 164 | + {{- if $deployValues.securityContext }} |
| 165 | + securityContext: |
| 166 | + {{- toYaml $deployValues.securityContext | nindent 12 }} |
| 167 | + {{- end }} |
| 168 | + lifecycle: |
| 169 | + {{- toYaml $deployValues.lifecycle | nindent 12 }} |
| 170 | + {{- if $deployValues.extraContainers }} |
| 171 | + {{- tpl $deployValues.extraContainers . | nindent 8 }} |
| 172 | + {{- end }} |
| 173 | + initContainers: |
| 174 | + {{- if $deployValues.extraInitContainers }} |
| 175 | + {{- tpl $deployValues.extraInitContainers . | nindent 8 }} |
| 176 | + {{- end }} |
| 177 | + {{- if and ( .Values.hydra.automigration.enabled ) ( eq .Values.hydra.automigration.type "initContainer" ) }} |
| 178 | + - name: {{ .Chart.Name }}-automigrate |
| 179 | + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" |
| 180 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 181 | + {{- if .Values.hydra.automigration.customCommand }} |
| 182 | + command: {{- toYaml .Values.hydra.automigration.customCommand | nindent 12 }} |
| 183 | + {{- else }} |
| 184 | + command: ["hydra"] |
| 185 | + {{- end }} |
| 186 | + {{- if .Values.hydra.automigration.customArgs }} |
| 187 | + args: {{- toYaml .Values.hydra.automigration.customArgs | nindent 12 }} |
| 188 | + {{- else }} |
| 189 | + args: ["migrate", "sql", "-e", "--yes", "--config", "/etc/config/hydra.yaml"] |
| 190 | + {{- end }} |
| 191 | + volumeMounts: |
| 192 | + - name: {{ include "hydra.name" . }}-config-volume |
| 193 | + mountPath: /etc/config |
| 194 | + readOnly: true |
| 195 | + {{- with $deployValues.extraVolumeMounts }} |
| 196 | + {{- toYaml . | nindent 12 }} |
| 197 | + {{- end }} |
| 198 | + env: |
| 199 | + {{- if not (empty ( include "hydra.dsn" . )) }} |
| 200 | + {{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }} |
| 201 | + - name: DSN |
| 202 | + valueFrom: |
| 203 | + secretKeyRef: |
| 204 | + name: {{ include "hydra.secretname" . }} |
| 205 | + key: dsn |
| 206 | + {{- end }} |
| 207 | + {{- end }} |
| 208 | + {{- if $migrationExtraEnv }} |
| 209 | + {{- tpl (toYaml $migrationExtraEnv) . | nindent 12 }} |
| 210 | + {{- end }} |
| 211 | + {{- if .Values.hydra.automigration.resources }} |
| 212 | + resources: |
| 213 | + {{- toYaml .Values.hydra.automigration.resources | nindent 12 }} |
| 214 | + {{- end }} |
| 215 | + {{- with $deployValues.initContainerSecurityContext }} |
| 216 | + securityContext: |
| 217 | + {{- toYaml . | nindent 12 }} |
| 218 | + {{- end }} |
| 219 | + {{- end }} |
| 220 | + {{- if .Values.priorityClassName }} |
| 221 | + priorityClassName: {{ .Values.priorityClassName }} |
| 222 | + {{- end }} |
| 223 | + {{- with $deployValues.nodeSelector }} |
| 224 | + nodeSelector: |
| 225 | + {{- toYaml . | nindent 8 }} |
| 226 | + {{- end }} |
| 227 | + {{- with $deployValues.tolerations }} |
| 228 | + tolerations: |
| 229 | + {{- toYaml . | nindent 8 }} |
| 230 | + {{- end }} |
| 231 | + {{- with .Values.affinity }} |
| 232 | + affinity: |
| 233 | + {{- toYaml . | nindent 8 }} |
| 234 | + {{- end }} |
| 235 | + {{- with $deployValues.topologySpreadConstraints }} |
| 236 | + topologySpreadConstraints: |
| 237 | + {{- toYaml . | nindent 8 }} |
| 238 | + {{- end }} |
| 239 | + {{- with $deployValues.podSecurityContext }} |
| 240 | + securityContext: |
| 241 | + {{- toYaml . | nindent 8 }} |
| 242 | + {{- end }} |
| 243 | + {{- with $deployValues.dnsConfig }} |
| 244 | + dnsConfig: |
| 245 | + {{- toYaml . | nindent 8 }} |
| 246 | + {{- end }} |
| 247 | +{{- end -}} |
0 commit comments