Skip to content

Instantly share code, notes, and snippets.

@pratikbin
Last active July 13, 2021 05:45
Show Gist options
  • Save pratikbin/82ca2a0d82aaf73434987e3ace35b1ab to your computer and use it in GitHub Desktop.
Save pratikbin/82ca2a0d82aaf73434987e3ace35b1ab to your computer and use it in GitHub Desktop.
## Delete namespace from terminating state
kubectl get namespace "stucked-namespace" -o json \
| tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \
| kubectl replace --raw /api/v1/namespaces/stucked-namespace/finalize -f -
## Delete cascade in sts
kc delete sts --cascade=false
## Secret decode
kc -n <namespace-name> get secret <secret-name> -o go-template='
{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
## copy secret to different namespace
kc get secret <secret-name> --namespace=<namespace-name-where-secret-resides> -o yaml | grep -v '^\s*namespace:\s' | kc apply --namespace=<namespace-name-in-which-to-create-secret> -f -
@shyamvyas5
Copy link

Please add this command which will create or copy secret from one namespace to another,

kc get secret <secret-name> --namespace=<namespace-name-where-secret-resides> -o yaml | grep -v '^\s*namespace:\s' | kc apply --namespace=<namespace-name-in-which-to-create-secret> -f -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment