This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16.8k
/
statefulset.yaml
160 lines (159 loc) · 5.61 KB
/
statefulset.yaml
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
{{- $highAvailability := gt (int .Values.keycloak.replicas) 1 -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "keycloak.fullname" . }}
annotations:
checksum/config: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
app: {{ template "keycloak.name" . }}
chart: {{ template "keycloak.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
selector:
matchLabels:
app: {{ template "keycloak.name" . }}
release: "{{ .Release.Name }}"
replicas: {{ .Values.keycloak.replicas }}
serviceName: {{ template "keycloak.fullname" . }}-headless
podManagementPolicy: Parallel
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: {{ template "keycloak.name" . }}
release: "{{ .Release.Name }}"
{{- if .Values.keycloak.podLabels }}
{{ toYaml .Values.keycloak.podLabels | indent 8 }}
{{- end }}
{{- if .Values.keycloak.podAnnotations }}
annotations:
{{ toYaml .Values.keycloak.podAnnotations | indent 8 }}
{{- end }}
spec:
{{- with .Values.keycloak.hostAliases }}
hostAliases:
{{ toYaml . | indent 8 }}
{{- end }}
securityContext:
{{ toYaml .Values.keycloak.securityContext | indent 8 }}
{{- with .Values.keycloak.image.pullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if or .Values.keycloak.persistence.deployPostgres .Values.keycloak.extraInitContainers }}
initContainers:
{{- if .Values.keycloak.persistence.deployPostgres }}
- name: wait-for-postgresql
image: "{{ .Values.init.image.repository }}:{{ .Values.init.image.tag }}"
imagePullPolicy: {{ .Values.init.image.pullPolicy }}
command:
- sh
- -c
- |
until printf "." && nc -z -w 2 {{ template "keycloak.postgresql.fullname" . }} {{ .Values.postgresql.service.port }}; do
sleep 2;
done;
echo 'PostgreSQL OK ✓'
{{- end }}
{{- if .Values.keycloak.extraInitContainers }}
{{ tpl .Values.keycloak.extraInitContainers . | indent 8 }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.keycloak.image.repository }}:{{ .Values.keycloak.image.tag }}"
imagePullPolicy: {{ .Values.keycloak.image.pullPolicy }}
command:
- /scripts/keycloak.sh
{{- if .Values.keycloak.lifecycleHooks }}
lifecycle:
{{ tpl .Values.keycloak.lifecycleHooks . | indent 12 }}
{{- end }}
env:
{{- if .Release.IsInstall }}
- name: KEYCLOAK_USER
value: {{ .Values.keycloak.username }}
- name: KEYCLOAK_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.keycloak.existingSecret }}
name: {{ .Values.keycloak.existingSecret }}
{{- else }}
name: {{ template "keycloak.fullname" . }}-http
{{- end }}
key: {{ .Values.keycloak.existingSecretKey }}
{{- end }}
{{- if $highAvailability }}
- name: JGROUPS_DISCOVERY_PROTOCOL
value: "dns.DNS_PING"
- name: JGROUPS_DISCOVERY_PROPERTIES
value: "dns_query={{ template "keycloak.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
{{- end }}
{{ include "keycloak.dbEnvVars" . | indent 12 }}
{{- with .Values.keycloak.extraEnv }}
{{ tpl . $ | indent 12 }}
{{- end }}
volumeMounts:
- name: scripts
mountPath: /scripts
{{- with .Values.keycloak.extraVolumeMounts }}
{{ tpl . $ | indent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
{{- if $highAvailability }}
- name: jgroups
containerPort: 7600
protocol: TCP
{{- end }}
{{- with .Values.keycloak.extraPorts }}
{{ tpl . $ | indent 12 }}
{{- end }}
livenessProbe:
httpGet:
path: {{ if ne .Values.keycloak.basepath "" }}/{{ .Values.keycloak.basepath }}{{ end }}/
port: http
initialDelaySeconds: {{ .Values.keycloak.livenessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.keycloak.livenessProbe.timeoutSeconds }}
readinessProbe:
httpGet:
path: {{ if ne .Values.keycloak.basepath "" }}/{{ .Values.keycloak.basepath }}{{ end }}/realms/master
port: http
initialDelaySeconds: {{ .Values.keycloak.readinessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.keycloak.readinessProbe.timeoutSeconds }}
resources:
{{ toYaml .Values.keycloak.resources | indent 12 }}
{{- with .Values.keycloak.extraContainers }}
{{ tpl . $ | indent 8 }}
{{- end }}
{{- with .Values.keycloak.affinity }}
affinity:
{{ tpl . $ | indent 8 }}
{{- end }}
{{- with .Values.keycloak.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.keycloak.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- if .Values.keycloak.priorityClassName }}
priorityClassName: {{ .Values.keycloak.priorityClassName }}
{{- end }}
terminationGracePeriodSeconds: 60
volumes:
- name: scripts
configMap:
name: {{ template "keycloak.fullname" . }}
defaultMode: 0555
{{- with .Values.keycloak.extraVolumes }}
{{ tpl . $ | indent 8 }}
{{- end }}