💻 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.
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-deployDeployment 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.
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.
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
| Symptom | Cause | Solution |
|---|---|---|
executable file not found | The image has no sh or bash | Use kubectl debug (step 7) |
container not found | Wrong container name | Check with kubectl describe pod |
unable to upgrade connection | No permission or network blocked | Check your access (RBAC) |
address already in use on port-forward | The local port is busy | Change 8080 to another, such as 8081 |
Pod in Pending or CrashLoopBackOff | The container is not running | Use Logs and Events |
➡️ Next step: YAML
🧠 Questions?
Talk to our SaveinCloud technical support team!