forked from z1nkum/docker-letsencrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecreate_pods.sh
More file actions
executable file
·22 lines (18 loc) · 900 Bytes
/
Copy pathrecreate_pods.sh
File metadata and controls
executable file
·22 lines (18 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# Update the required env vars for the first pod in each Deployment.
# This will kick off a rolling update.
# Do this so that the secrets can be remounted.
if [ -z "$DEPLOYMENTS" ]; then
echo "WARNING: DEPLOYMENTS not provided. Secret changes may not be reflected."
exit
fi
DEPLOYMENTS=(${DEPLOYMENTS})
DATE=$(date)
NAMESPACE=${NAMESPACE:-default}
for DEPLOYMENT in "${DEPLOYMENTS[@]}"
do
NAME=$(kubectl get deployments --namespace $NAMESPACE $DEPLOYMENT -o=template --template='{{index .spec.template.spec.containers 0 "name"}}')
PATCH=$(NAME=$NAME DATE=$DATE echo "{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"$NAME\", \"env\": [{\"name\": \"LETSENCRYPT_CERT_REFRESH\", \"value\": \"$DATE\"}]}]}}}}")
echo "PATCHING ${DEPLOYMENT}: ${PATCH}"
kubectl patch deployment --namespace $NAMESPACE $DEPLOYMENT --type=strategic -p "$PATCH"
done