serhii.net

In the middle of the desert you can say anything you want

31 Jan 2024

Connecting to a Rancher pod with kubectl terminal

  • Put new config in ~/.kube/config if needed.
  • kubectl describe nodes as a sanity-check that it works

To run stuff

kubectl exec -it pod-name -n namespace -- bash

The namespace bit is critical, otherwise one may get errors like

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Error from server (Forbidden): pods "podname" is forbidden: User "user" cannot get resource "pods" in API group "" in the namespace "default"

If screen CLI is bad, it’s because it’s sh, run bash and everything will work. screen -R screenname bash


To run a pod w/ CLI:

kubectl apply -f pod.yaml

To view logs:

kubectl logs podname -n namespace

To copy files:

kubectl cp [LOCAL_FILE_PATH] [NAMESPACE]/[POD_NAME]:[REMOTE_FILE_PATH]


kubectl cp [LOCAL_FILE_PATH] [NAMESPACE]/[POD_NAME]:[REMOTE_FILE_PATH]
Nel mezzo del deserto posso dire tutto quello che voglio.