Skip to content

Instantly share code, notes, and snippets.

@bjethwan
Last active April 13, 2019 00:32
Show Gist options
  • Save bjethwan/12c7e56c1cb2c096d6fcb282307ae324 to your computer and use it in GitHub Desktop.
Save bjethwan/12c7e56c1cb2c096d6fcb282307ae324 to your computer and use it in GitHub Desktop.
Dump client k8s certificates from your kubeconf for use in remote k8s with Kubernetai CoreDNS Plugin
# Dump certs (client.crt, client.key, & ca.crt) in a directory called c3certs
export KUBECONFIG_PATH=/home/ec2-user/.kube/config
sudo cat $KUBECONFIG_PATH | grep client-certificate-data | cut -f2 -d : | tr -d ' ' | base64 -d > c3certs/client.crt
sudo cat $KUBECONFIG_PATH | grep client-key-data | cut -f2 -d : | tr -d ' ' | base64 -d > c3certs/client.key
sudo cat $KUBECONFIG_PATH | grep certificate-authority-data | cut -f2 -d : | tr -d ' ' | base64 -d > c3certs/ca.crt
# Load the above certificates as ConfigMap in Kubernetes running with CoreNS Kubernetai plugin
kubectl -n kube-system create cm c3certs --from-file=/home/ec2-user/c3certs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment