Tidbits | April 29, 2018

Pro-Tip – Copying Kubernetes Secrets Between Namespaces

by Stephen Spencer

The secret resource-type is unique--it cannot be accessed from pods outside of its namespace. A simple way of copying common secret data (e.g.: docker registry credentials) between namespaces is provided by the --export flag of kubectl get. Pipe its output to kubectl apply -n <target namespace> -f -, and you are done!

kubectl get secret gitlab-registry --namespace=revsys-com --export -o yaml |\
   kubectl apply --namespace=devspectrum-dev -f -

easy-mode, cross-namespace object copy

2018-04-29T14:19:01.391724 2018-04-29T14:19:01.339590 2018 ops,namespaces,namespace,secrets,kubernetes,k8s