Skip to content

Instantly share code, notes, and snippets.

@mauriballes
Created May 17, 2022 00:36
Show Gist options
  • Save mauriballes/72684433dcd98541bde9261d1bf1ff2c to your computer and use it in GitHub Desktop.
Save mauriballes/72684433dcd98541bde9261d1bf1ff2c to your computer and use it in GitHub Desktop.
Fix Rancher terminating namespace problem

Fix Rancher terminating namespace problem

Requirements

  • jq
  • kubectl

Config your terminal for access rancher cluster

  • Download kubeconfig file

kubeconfig

  • Config your terminal, export your new kubeconfig
KUBECONFIG=<kubeconfig-downloaded>.yaml
  • Enable proxy, when you do it, you will get an out similar to this: Your kube context contains a server path /k8s/clusters/<cluster-code> save that code from the path for later
kubectl proxy

Delete terminating namespace

  • Config some env variables in another terminal
NAMESPACE=<namespace-for-eliminating>
CLUSTER=<cluster-code>
KUBECONFIG=<kubeconfig-downloaded>.yaml
  • Update namespace config in a file
kubectl get namespace $NAMESPACE -o json | jq '.spec = {"finalizers":[]}' > temp.json
  • Apply new config
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/k8s/clusters/$CLUSTER/api/v1/namespaces/$NAMESPACE/finalize

After these commands, the terminating namespace will disappear

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