Skip to content

Instantly share code, notes, and snippets.

@canhnt
Created September 23, 2020 13:43
Show Gist options
  • Save canhnt/939c01e0d5a4b8410e7b1cf50635382f to your computer and use it in GitHub Desktop.
Save canhnt/939c01e0d5a4b8410e7b1cf50635382f to your computer and use it in GitHub Desktop.
Rancher tips & tricks

Access K8s cluster directly

Get kubeconfig from secret

CLUSTERID='c-1234'
kubectl get secret c-$CLUSTERID -n cattle-system -o json | jq -r .data.cluster | base64 -D | jq -r .metadata.state > kubeconfig-direct

Change endpoint to https://localhost:6443

Open SSH tunnel to master node via jump server

ssh -L 6443:$master_ip:6443 $jump_server

Access k8s cluster directly

export KUBECONFIG=$(pwd)/kubeconfig-direct
k get nodes -o wide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment