Created
January 18, 2019 11:33
-
-
Save fpytloun/98f775f2997f8114cc132c280b225e66 to your computer and use it in GitHub Desktop.
Dump kubernetes certificates
This file contains hidden or 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 -e | |
log_info() { | |
echo "INFO: $*" | |
} | |
log_info "Getting all certificates" | |
kubectl get certificate --all-namespaces --no-headers | while read cert; do | |
namespace=$(echo $cert | awk '{print $1}') | |
name=$(echo $cert | awk '{print $2}') | |
secret=$(kubectl -n ${namespace} describe certificate ${name} | grep "Secret Name" | cut -d : -f 2 | tr -d ' ') | |
log_info "Dumping certificate ${name} with secret ${secret} in namespace ${namespace}" | |
kubectl -n ${namespace} get secret ${secret} -o yaml > secret_${namespace}_${secret}.yml | |
kubectl -n ${namespace} get certificate ${name} -o yaml > certificate_${namespace}_${name}.yml | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment