Skip to main content

💻 Terminal

Sometimes you need to get inside the pod to investigate: view files, test a connection, run a command. kubectl exec opens a terminal inside the container, as if you had connected via SSH.

info

The pod terminal is opened with kubectl. The Nuvion Panel does not have a terminal for pods.


🚀 Before you start​

  • Have cluster access configured (see Cluster Access).
  • Have the web-deploy Deployment from the Deploy page.

🚀 1. Find the pod name​

kubectl get pods -l app=web-deploy

🚀 2. Open a terminal in the pod​

kubectl exec -it POD-NAME -- sh

You will be inside the container. Try a few commands:

ls /usr/share/nginx/html
cat /etc/nginx/nginx.conf

Type exit to leave.

tip

Some images have bash. If it exists, use -- bash instead of -- sh.

🚀 3. Run a single command​

Without opening a terminal:

kubectl exec POD-NAME -- ls /usr/share/nginx/html

🚀 4. Choose the container (pods with more than one)​

kubectl exec -it POD-NAME -c CONTAINER-NAME -- sh

🚀 5. Access the application without exposing it publicly​

port-forward creates a tunnel between your computer and the pod:

kubectl port-forward deployment/web-deploy 8080:80

Open http://localhost:8080 in the browser. Stop with Ctrl+C.

🚀 6. Copy files to and from the pod​

kubectl cp POD-NAME:/etc/nginx/nginx.conf ./nginx.conf
kubectl cp ./arquivo.txt POD-NAME:/tmp/arquivo.txt

🚀 7. Debug pods without a terminal (minimal images)​

Some images do not have sh. Attach a temporary debug container:

kubectl debug -it POD-NAME --image=busybox --target=nginx

✅ How to know it worked​

The terminal prompt changes to the container's, and the commands show the pod's content.

warning

Changes made inside the pod are lost when it is recreated. For permanent changes, modify the Deployment or the image. In production, use the terminal only for inspection.

❗ Common problems​

SymptomCauseSolution
executable file not foundThe image has no sh or bashUse kubectl debug (step 7)
container not foundWrong container nameCheck with kubectl describe pod
unable to upgrade connectionNo permission or network blockedCheck your access (RBAC)
address already in use on port-forwardThe local port is busyChange 8080 to another, such as 8081
Pod in Pending or CrashLoopBackOffThe container is not runningUse Logs and Events

➡️ Next step: YAML

🧠 Questions?​

Talk to our SaveinCloud technical support team!