Skip to content

Instantly share code, notes, and snippets.

@gpr
Last active May 17, 2021 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpr/3bda2659e917371321e7bbd6f98f1835 to your computer and use it in GitHub Desktop.
Save gpr/3bda2659e917371321e7bbd6f98f1835 to your computer and use it in GitHub Desktop.
[Copy secrets among different namespaces] #kubernetes #k8s #secrets
#!/bin/bash
#
# Example: ./kubectl-copy-secret.sh s3access default gitlab-runnner
SECRET_NAME=${1:?}
NS_SRC=${2:?}
NS_SRC=${3:?}
kubectl get secret $SECRET_NAME \
--namespace=$NS_SRC \
-o yaml | \
yq r - 'metadata.annotations."kubectl.kubernetes.io/last-applied-configuration"' \
kubectl apply --namespace=$NS_SRC -f -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment