Last active
September 17, 2019 06:20
-
-
Save imixtron/7e097d99ca67f8e2431375db90cea7ea to your computer and use it in GitHub Desktop.
Copy secret between k8s namespaces
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 | |
kubectl get <resource-type> <resource-name> -n <source-namespace-name> -o yaml |\ | |
sed 's/namespace: <source-namespace-name>/namespace: <target-namespace-name>/' |\ | |
kubectl create -f - | |
> Example: | |
kubectl get secret auth-token -n web-dev -o yaml |\ | |
sed 's/namespace: web-dev/namespace: web-qa/' |\ | |
kubectl create -f - | |
=== DEPRECATED === | |
since `--export` flag has been deprecated, we will be using `sed` to achieve our goal | |
ref: | |
- https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.14.md#deprecations | |
- https://medium.com/@jonathan.johnson/export-has-been-deprecated-in-1-14-51cfef5a0cb7 | |
kubectl get secret gitlab-registry --namespace=revsys-com --export -o yaml |\ | |
kubectl apply --namespace=devspectrum-dev -f - | |
# thanks to | |
# https://www.revsys.com/tidbits/copying-kubernetes-secrets-between-namespaces/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment