Skip to content

Commit 365807c

Browse files
authored
Merge pull request ceph#328 from black-dragon74/add-img-pull-secrets
Allow user to specify `imagePullSecrets` for csi-operator deployments
2 parents dfba7b6 + 7623c8a commit 365807c

File tree

9 files changed

+86
-1
lines changed

9 files changed

+86
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ build-helm-installer: manifests generate kustomize helmify ## Generate helm char
203203
mkdir -p build deploy
204204
cd build && echo "$$BUILD_INSTALLER_OVERLAY" > kustomization.yaml
205205
cd build && $(KUSTOMIZE) edit add resource ../config/default/
206-
$(KUSTOMIZE) build build | $(HELMIFY) deploy/charts/ceph-csi-operator
206+
$(KUSTOMIZE) build build | $(HELMIFY) -image-pull-secrets deploy/charts/ceph-csi-operator
207+
hack/patch-sa-with-imgpullsecrets.sh deploy/charts/ceph-csi-operator
207208
rm -rf build
208209

209210
.PHONY: build-multifile-installer

deploy/charts/ceph-csi-drivers/templates/serviceaccount.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ kind: ServiceAccount
88
metadata:
99
name: {{ $normalizedDriverName }}-ctrlplugin-sa
1010
namespace: {{ $root.Release.Namespace }}
11+
{{- with $root.Values.imagePullSecrets }}
12+
imagePullSecrets:
13+
{{ toYaml . | indent 2 }}
14+
{{- end }}
1115
---
1216
apiVersion: v1
1317
kind: ServiceAccount
1418
metadata:
1519
name: {{ $normalizedDriverName }}-nodeplugin-sa
1620
namespace: {{ $root.Release.Namespace }}
21+
{{- with $root.Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{ toYaml . | indent 2 }}
24+
{{- end }}
1725
{{- end }}
1826
{{- end }}

deploy/charts/ceph-csi-drivers/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,6 @@ drivers:
474474

475475
# List of tolerations for the controller plugin
476476
tolerations: []
477+
478+
# List of pull secret names that will be added to all serviceaccounts
479+
imagePullSecrets: []

deploy/charts/ceph-csi-operator/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ spec:
5454
}}
5555
securityContext: {{- toYaml .Values.controllerManager.manager.containerSecurityContext
5656
| nindent 10 }}
57+
imagePullSecrets: {{ .Values.imagePullSecrets | default list | toJson }}
5758
securityContext: {{- toYaml .Values.controllerManager.podSecurityContext | nindent
5859
8 }}
5960
serviceAccountName: {{ include "ceph-csi-operator.fullname" . }}-controller-manager

deploy/charts/ceph-csi-operator/templates/serviceaccount.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ metadata:
66
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
77
annotations:
88
{{- toYaml .Values.cephfsCtrlpluginSa.serviceAccount.annotations | nindent 4 }}
9+
{{- with .Values.imagePullSecrets }}
10+
imagePullSecrets:
11+
{{ toYaml . | indent 2 }}
12+
{{- end }}
913
---
1014
apiVersion: v1
1115
kind: ServiceAccount
@@ -15,6 +19,10 @@ metadata:
1519
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
1620
annotations:
1721
{{- toYaml .Values.cephfsNodepluginSa.serviceAccount.annotations | nindent 4 }}
22+
{{- with .Values.imagePullSecrets }}
23+
imagePullSecrets:
24+
{{ toYaml . | indent 2 }}
25+
{{- end }}
1826
---
1927
apiVersion: v1
2028
kind: ServiceAccount
@@ -24,6 +32,10 @@ metadata:
2432
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
2533
annotations:
2634
{{- toYaml .Values.controllerManager.serviceAccount.annotations | nindent 4 }}
35+
{{- with .Values.imagePullSecrets }}
36+
imagePullSecrets:
37+
{{ toYaml . | indent 2 }}
38+
{{- end }}
2739
---
2840
apiVersion: v1
2941
kind: ServiceAccount
@@ -33,6 +45,10 @@ metadata:
3345
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
3446
annotations:
3547
{{- toYaml .Values.nfsCtrlpluginSa.serviceAccount.annotations | nindent 4 }}
48+
{{- with .Values.imagePullSecrets }}
49+
imagePullSecrets:
50+
{{ toYaml . | indent 2 }}
51+
{{- end }}
3652
---
3753
apiVersion: v1
3854
kind: ServiceAccount
@@ -42,6 +58,10 @@ metadata:
4258
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
4359
annotations:
4460
{{- toYaml .Values.nfsNodepluginSa.serviceAccount.annotations | nindent 4 }}
61+
{{- with .Values.imagePullSecrets }}
62+
imagePullSecrets:
63+
{{ toYaml . | indent 2 }}
64+
{{- end }}
4565
---
4666
apiVersion: v1
4767
kind: ServiceAccount
@@ -51,6 +71,10 @@ metadata:
5171
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
5272
annotations:
5373
{{- toYaml .Values.rbdCtrlpluginSa.serviceAccount.annotations | nindent 4 }}
74+
{{- with .Values.imagePullSecrets }}
75+
imagePullSecrets:
76+
{{ toYaml . | indent 2 }}
77+
{{- end }}
5478
---
5579
apiVersion: v1
5680
kind: ServiceAccount
@@ -60,3 +84,7 @@ metadata:
6084
{{- include "ceph-csi-operator.labels" . | nindent 4 }}
6185
annotations:
6286
{{- toYaml .Values.rbdNodepluginSa.serviceAccount.annotations | nindent 4 }}
87+
{{- with .Values.imagePullSecrets }}
88+
imagePullSecrets:
89+
{{ toYaml . | indent 2 }}
90+
{{- end }}

deploy/charts/ceph-csi-operator/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ controllerManager:
3232
replicas: 1
3333
serviceAccount:
3434
annotations: {}
35+
imagePullSecrets: []
3536
kubernetesClusterDomain: cluster.local
3637
nfsCtrlpluginSa:
3738
serviceAccount:

docs/helm-charts/drivers-chart.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ The following table lists the configurable parameters of the ceph-csi-drivers ch
156156
| `drivers.rbd.nodePlugin.tolerations` | | `[]` |
157157
| `drivers.rbd.nodePlugin.volumes` | | `[]` |
158158
| `drivers.rbd.snapshotPolicy` | | `"none"` |
159+
| `imagePullSecrets` | | `[]` |
159160
| `operatorConfig.create` | | `true` |
160161
| `operatorConfig.driverSpecDefaults.attachRequired` | | `true` |
161162
| `operatorConfig.driverSpecDefaults.cephFsClientType` | | `"kernel"` |

docs/helm-charts/operator-chart.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The following table lists the configurable parameters of the ceph-csi-operator c
6161
| `controllerManager.podSecurityContext.runAsNonRoot` | | `true` |
6262
| `controllerManager.replicas` | | `1` |
6363
| `controllerManager.serviceAccount.annotations` | | `{}` |
64+
| `imagePullSecrets` | | `[]` |
6465
| `kubernetesClusterDomain` | | `"cluster.local"` |
6566
| `nfsCtrlpluginSa.serviceAccount.annotations` | | `{}` |
6667
| `nfsNodepluginSa.serviceAccount.annotations` | | `{}` |
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# DO NOT run this script on its own
3+
# It will append the required template multiple times
4+
# It is intended to be ran as a part of generating heml charts using helmify
5+
6+
set -e
7+
8+
CHART_DIR=$1
9+
SA_FILE="${CHART_DIR}/templates/serviceaccount.yaml"
10+
11+
if [ ! -f "$SA_FILE" ]; then
12+
echo "No serviceaccount.yaml template in $CHART_DIR, nothing to do!"
13+
exit 1
14+
fi
15+
16+
TEMPLATE_SNIPPET=$(
17+
cat <<'EOF'
18+
{{- with .Values.imagePullSecrets }}
19+
imagePullSecrets:
20+
{{ toYaml . | indent 2 }}
21+
{{- end }}
22+
EOF
23+
)
24+
25+
echo "Patching $SA_FILE for imagePullSecrets"
26+
27+
awk -v snippet="$TEMPLATE_SNIPPET" '
28+
# Before printing a separator, print the snippet
29+
/^---/ { print snippet }
30+
31+
# Print the current line
32+
{ print }
33+
34+
# At the end of the file, print the snippet for the last section
35+
END { print snippet }
36+
' "$SA_FILE" >"${SA_FILE}.tmp"
37+
38+
mv "${SA_FILE}.tmp" "$SA_FILE"
39+
40+
echo "Patched $SA_FILE successfully"
41+
exit 0

0 commit comments

Comments
 (0)