Created
December 30, 2020 23:38
-
-
Save DrPsychick/b0a858e94fd4be0da20d9b466e99d8d5 to your computer and use it in GitHub Desktop.
backup and restore certificates of your kubernetes cluster to avoid running into letsencrypt issuing limits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" -o -z "$2" ]; then | |
echo "Usage: $0 backup|restore <cluster-name> [certificates.yml]" | |
exit 1 | |
fi | |
kube_context="kind-$2" | |
secrets="$3" | |
if [ "$1" == "backup" ]; then | |
kubectl --context=$kube_context get secret --field-selector type=kubernetes.io/tls -A -o yaml > ${kube_context}-certificates.yml | |
chmod go-rw ${kube_context}-certificates.yml | |
fi | |
if [ "$1" == "restore" -a -r "$secrets" ]; then | |
kubectl --context=$kube_context apply -f $secrets | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment