Skip to content

Instantly share code, notes, and snippets.

@DrPsychick
Created December 30, 2020 23:38
Show Gist options
  • Save DrPsychick/b0a858e94fd4be0da20d9b466e99d8d5 to your computer and use it in GitHub Desktop.
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
#!/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