Skip to content

Commit 7be14dd

Browse files
committed
fix: refactory deployment + add values for tests
1 parent 77b0cc3 commit 7be14dd

File tree

7 files changed

+92
-66
lines changed

7 files changed

+92
-66
lines changed

.github/workflows/lint-test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ jobs:
3838
run: |
3939
namespace=authentik-$(uuidgen)
4040
kubectl create ns $namespace
41-
kubectl apply -n $namespace -f charts/authentik/ci/manfiests/
41+
kubectl apply -n $namespace -f charts/authentik/ci/manifests/
4242
ct install --namespace=$namespace --config ct.yaml

charts/authentik/ci/ct-values.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,12 @@ redis:
3636
enabled: true
3737
password: au7h3n71k
3838

39+
serviceAccount:
40+
create: true
41+
42+
sidecar:
43+
blueprints:
44+
enabled: true
45+
3946
blueprints:
4047
- authentik-ci-blueprint
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: authentik-ci-blueprint-sidecar
6+
labels:
7+
goauthentik_blueprint: "1"
8+
data:
9+
test.yaml: |-
10+
version: 1
11+
metadata:
12+
name: sidecar-test
13+
entries: []

charts/authentik/templates/deployment.yaml

+69-58
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
{{- range list "server" "worker" }}
1+
{{- range $component := list "server" "worker" }}
22
---
33
apiVersion: apps/v1
44
kind: Deployment
55
metadata:
66
name: {{ printf "%s-%s" (include "common.names.fullname" $) . }}
77
labels:
88
{{- include "common.labels" $ | nindent 4 }}
9-
app.kubernetes.io/component: "{{ . }}"
9+
app.kubernetes.io/component: "{{ $component }}"
1010
spec:
11-
{{ if eq . "server" -}}
11+
{{- if eq . "server" }}
1212
replicas: {{ $.Values.replicas }}
13-
{{- else -}}
13+
{{- else }}
1414
replicas: {{ $.Values.worker.replicas }}
1515
{{- end }}
1616
selector:
1717
matchLabels:
1818
{{- include "common.labels.selectorLabels" $ | nindent 6 }}
19-
app.kubernetes.io/component: "{{ . }}"
19+
app.kubernetes.io/component: "{{ $component }}"
2020
template:
2121
metadata:
2222
labels:
2323
{{- include "common.labels.selectorLabels" $ | nindent 8 }}
24-
app.kubernetes.io/component: "{{ . }}"
24+
app.kubernetes.io/component: "{{ $component }}"
2525
app.kubernetes.io/version: "{{ $.Values.image.tag }}"
26-
{{- if $.Values.podAnnotations }}
26+
{{- with $.Values.podAnnotations }}
2727
annotations:
28-
{{- toYaml $.Values.podAnnotations | nindent 8 }}
28+
{{- toYaml . | nindent 8 }}
2929
{{- end }}
3030
spec:
31-
{{- if $.Values.image.pullSecrets }}
31+
{{- with $.Values.image.pullSecrets }}
3232
imagePullSecrets:
33-
{{- toYaml $.Values.image.pullSecrets | nindent 8 }}
33+
{{- toYaml . | nindent 8 }}
3434
{{- end }}
3535
{{- if $.Values.serviceAccount.create }}
3636
serviceAccountName: {{ include "common.names.fullname" $ }}
@@ -60,20 +60,25 @@ spec:
6060
{{- end }}
6161
{{- tpl (toYaml $initContainers) $ | nindent 8 }}
6262
{{- end }}
63-
{{ if eq . "server" -}}
63+
{{- if eq $component "server" }}
6464
priorityClassName: {{ $.Values.priorityClassName }}
65+
{{- with $.Values.securityContext }}
6566
securityContext:
66-
{{- toYaml $.Values.securityContext | nindent 8 }}
67-
{{- else -}}
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- else }}
6870
priorityClassName: {{ $.Values.worker.priorityClassName }}
71+
{{- with $.Values.worker.securityContext }}
6972
securityContext:
70-
{{- toYaml $.Values.worker.securityContext | nindent 8 }}
73+
{{- toYaml . | nindent 8 }}
74+
{{- end }}
7175
{{- end }}
7276
containers:
7377
- name: {{ $.Chart.Name }}
7478
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}{{- if $.Values.image.digest -}}@{{ $.Values.image.digest }}{{- end -}}"
7579
imagePullPolicy: "{{ $.Values.image.pullPolicy }}"
76-
args: [{{ quote . }}]
80+
args:
81+
- {{ $component | quote }}
7782
env:
7883
{{- range $k, $v := $.Values.env }}
7984
- name: {{ quote $k }}
@@ -85,31 +90,34 @@ spec:
8590
valueFrom:
8691
{{- toYaml $val | nindent 16 }}
8792
{{- end }}
88-
{{- with $.Values.envFrom }}
93+
{{- with $.Values.envFrom }}
8994
envFrom:
90-
{{- toYaml . | nindent 12 }}
91-
{{- end }}
95+
{{- toYaml . | nindent 12 }}
96+
{{- end }}
97+
9298
volumeMounts:
93-
{{- if $.Values.geoip.enabled }}
99+
{{- if $.Values.geoip.enabled }}
94100
- name: geoip-db
95101
mountPath: /geoip
96-
{{- end }}
102+
{{- end }}
103+
104+
{{- if eq $component "worker" -}}
97105
{{- if $.Values.sidecar.blueprints.enabled }}
98106
- name: sidecar-blueprints
99107
mountPath: /blueprints/sidecar
100108
{{- end }}
101-
{{- with $.Values.volumeMounts }}
102-
{{- toYaml . | nindent 12 }}
103-
{{- end }}
104-
{{ if eq . "worker" -}}
105-
{{- with $.Values.blueprints }}
106-
{{- range $name := . }}
109+
110+
{{- range $name := $.Values.blueprints }}
107111
- name: blueprints-{{ $name }}
108112
mountPath: /blueprints/mounted/{{ $name }}
109-
{{- end }}
110113
{{- end }}
111-
{{- end }}
112-
{{- if eq . "server" }}
114+
{{- end }}{{/* end worker */}}
115+
116+
{{- with $.Values.volumeMounts }}
117+
{{- toYaml . | nindent 12 }}
118+
{{- end }}
119+
120+
{{- if eq $component "server" }}
113121
ports:
114122
- name: http
115123
containerPort: 9000
@@ -120,24 +128,25 @@ spec:
120128
- name: https
121129
containerPort: 9443
122130
protocol: TCP
123-
{{- if $.Values.livenessProbe.enabled }}
124-
{{- with omit $.Values.livenessProbe "enabled" }}
131+
{{- with $.Values.livenessProbe }}
132+
{{- if .enabled }}
125133
livenessProbe:
126-
{{- toYaml . | nindent 12 }}
127-
{{- end }}
128-
{{- end }}
129-
{{- if $.Values.readinessProbe.enabled }}
130-
{{- with omit $.Values.readinessProbe "enabled" }}
134+
{{- toYaml . | nindent 12 }}
135+
{{- end }}
136+
{{- end }}
137+
{{- with $.Values.readinessProbe }}
138+
{{- if .enabled }}
131139
readinessProbe:
132-
{{- toYaml . | nindent 12 }}
133-
{{- end }}
134-
{{- end }}
135-
{{- end }}
136-
{{- with index $.Values.resources . }}
140+
{{- toYaml . | nindent 12 }}
141+
{{- end }}
142+
{{- end }}
143+
{{- end }}{{/* end server */}}
144+
145+
{{- with (get $.Values.resources $component) }}
137146
resources:
138-
{{- toYaml . | nindent 12 }}
139-
{{- end }}
140-
{{- if $.Values.geoip.enabled }}
147+
{{- toYaml . | nindent 12 }}
148+
{{- end }}
149+
{{- if $.Values.geoip.enabled }}
141150
- name: geoip-sidecar
142151
image: "{{ $.Values.geoip.image }}"
143152
env:
@@ -154,7 +163,8 @@ spec:
154163
volumeMounts:
155164
- name: geoip-db
156165
mountPath: /usr/share/GeoIP
157-
{{- end }}
166+
{{- end }}
167+
{{- if eq $component "worker" }}
158168
{{- with $.Values.sidecar.blueprints }}
159169
{{- if .enabled }}
160170
- name: sidecar-blueprints
@@ -183,7 +193,8 @@ spec:
183193
mountPath: /blueprints/sidecar
184194
{{- end }}
185195
{{- end }}
186-
{{- with $.Values.additionalContainers }}
196+
{{- end }}{{/* end worker */}}
197+
{{- with $.Values.additionalContainers }}
187198
{{- $additionalContainers := list }}
188199
{{- range $name, $container := . }}
189200
{{- if not $container.name -}}
@@ -194,24 +205,24 @@ spec:
194205
{{- tpl (toYaml $additionalContainers) $ | nindent 8 }}
195206
{{- end }}
196207
volumes:
197-
{{- if $.Values.geoip.enabled }}
208+
{{- if $.Values.geoip.enabled }}
198209
- name: geoip-db
199210
emptyDir: {}
200-
{{- end }}
201-
{{- if $.Values.sidecar.blueprints.enabled }}
211+
{{- end }}
212+
{{- if eq $component "worker" }}
213+
{{- if $.Values.sidecar.blueprints.enabled }}
202214
- name: sidecar-blueprints
203215
emptyDir: {}
204-
{{- end }}
205-
{{- with $.Values.volumes }}
206-
{{- toYaml . | nindent 8 }}
207-
{{- end }}
208-
{{ if eq . "worker" -}}
209-
{{- with $.Values.blueprints }}
210-
{{- range $name := . }}
216+
{{- end }}
217+
{{- range $name := $.Values.blueprints }}
211218
- name: blueprints-{{ $name }}
212219
configMap:
213220
name: {{ $name }}
214221
{{- end }}
215-
{{- end }}
216-
{{- end }}
222+
{{- end }}{{/* end worker */}}
223+
224+
{{- with $.Values.volumes }}
225+
{{- toYaml . | nindent 8 }}
226+
{{- end }}
227+
217228
{{- end }}

charts/authentik/templates/service-account.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
{{- if .Values.serviceAccount.create }}
2-
3-
{{ include "common.serviceAccount" . }}
4-
5-
{{- if .Values.sidecar.blueprints.enabled }}
1+
{{- if and .Values.serviceAccount.create .Values.sidecar.blueprints.enabled }}
62
---
73
apiVersion: rbac.authorization.k8s.io/v1
84
kind: ClusterRole
@@ -25,5 +21,4 @@ subjects:
2521
- kind: ServiceAccount
2622
name: {{ include "common.names.fullname" . }}
2723
namespace: {{ .Release.Namespace }}
28-
{{- end }}
2924
{{- end }}

charts/authentik/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ readinessProbe:
166166
periodSeconds: 10
167167

168168
serviceAccount:
169-
# -- Service account is needed for managed outposts
169+
# -- Service account is needed for managed outposts and sidecar for blueprints
170170
create: true
171171
annotations: {}
172172

0 commit comments

Comments
 (0)