Skip to content

Commit

Permalink
Merge pull request #3653 from Monokaix/chart
Browse files Browse the repository at this point in the history
Update volcano-admission secret when it already exists
  • Loading branch information
volcano-sh-bot authored Aug 16, 2024
2 parents 7ee32cc + 6bb31fa commit c016909
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
30 changes: 23 additions & 7 deletions installer/dockerfile/webhook-manager/gen-admission-secret.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,29 @@ function createSecret() {
-n ${NAMESPACE}
}

ret=0
kubectl get secret ${SECRET} -n ${NAMESPACE} > /dev/null || ret=$?
if [[ ${ret} -eq 0 ]]; then
echo -e "The secret ${SECRET} -n ${NAMESPACE} already exists. Do not create it again."
exit 0
fi
function patchSecret() {
TLS_KEY=$(base64 < ${CERTDIR}/server.key | tr -d '\n')
TLS_CRT=$(base64 < ${CERTDIR}/server.crt | tr -d '\n')
CA_CRT=$(base64 < ${CERTDIR}/ca.crt | tr -d '\n')

cat <<EOF > patch.json
[
{"op": "replace", "path": "/data/tls.key", "value": "$TLS_KEY"},
{"op": "replace", "path": "/data/tls.crt", "value": "$TLS_CRT"},
{"op": "replace", "path": "/data/ca.crt", "value": "$CA_CRT"},
]
EOF

kubectl patch secret ${SECRET} -n ${NAMESPACE} --type=json -p="$(cat patch.json)"
}

createCerts

createSecret
ret=0
kubectl get secret ${SECRET} -n ${NAMESPACE} > /dev/null || ret=$?
if [[ ${ret} -eq 0 ]];then
echo -e "The secret ${SECRET} -n ${NAMESPACE} already exists. Will update it."
patchSecret
else
createSecret
fi
2 changes: 1 addition & 1 deletion installer/helm/chart/volcano/templates/admission-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ metadata:
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get"]
verbs: ["create", "patch", "get"]

---
kind: RoleBinding
Expand Down
2 changes: 1 addition & 1 deletion installer/volcano-development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ metadata:
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get"]
verbs: ["create", "patch", "get"]
---
# Source: volcano/templates/admission-init.yaml
kind: RoleBinding
Expand Down
2 changes: 1 addition & 1 deletion installer/volcano-monitoring-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ spec:
k8s-app: kube-state-metrics
spec:
containers:
- image: volcanosh/kube-state-metrics:v2.0.0-beta
- image: docker.io/volcanosh/kube-state-metrics:v2.0.0-beta
imagePullPolicy: Always
name: kube-state-metrics
ports:
Expand Down

0 comments on commit c016909

Please sign in to comment.