Rancher v2 CLI with kubectl
v2.8.0
,latest
(works for older Rancher versions like v2.5.10 too)v2.4.11-k8s1.21.12
(used by Rancher v2.5.10 + newer k8s version with improved kustomize version)v2.4.11-k8s1.20.15
(used by Rancher v2.5.10)v2.4.10-k8s1.18.19
(v2.4.10-k8s1.18.19/Dockerfile)v2.4.10
(v2.4.10/Dockerfile)v2.2.0
(v2.2.0/Dockerfile)v2.0.2
(v2.0.2/Dockerfile)
If you have done a rancher login
on the host, you can map the .rancher
folder into the container to share credentials.
docker run -rm -it -v ~/.rancher:/root/.rancher mheiniger/rancher-cli-k8s:latest rancher kubectl get nodes
Otherwise, you'll need to login using an API token from your rancher gui. In a build scenario You could create a new API key from your account in the rancher2 GUI and then expose it via environment variable and then:
rancher login "$RANCHER_SERVER_URL" -t "$RANCHER_API_TOKEN"
rancher kubectl get nodes
...