Basic KUBECTL Commands

The following kubectl commands cover the operations you will most often need when working with a Capacity Private Cloud installation on Kubernetes — inspecting workloads, viewing logs, opening a shell inside a container, checking ingress and services, managing lifecycle (scale, restart, roll back), and reviewing cluster and storage state.

Run kubectl with no arguments, or with --help, to see the full command list and detailed usage. Almost every kubectl subcommand accepts -h for per-command help (for example, kubectl logs -h).

About the namespace: Most of these commands target a specific Kubernetes namespace. The platform's default namespace is lumenvox, which is the example used throughout this article. If your installation uses a different namespace, substitute it wherever you see -n lumenvox below. To avoid typing the flag on every command, set a default namespace for your current context:

kubectl config set-context --current --namespace=lumenvox

Inspecting Workloads

List Pods

Show all pods in the namespace. Add -o wide to include the node each pod is scheduled on and the pod IP.

kubectl get pods -n lumenvox
kubectl get pods -n lumenvox -o wide

List Deployments

Show every Deployment in the namespace along with its desired and ready replica counts.

kubectl get deployments -n lumenvox

List Services

Show the Service endpoints exposed by the deployment. Useful for confirming internal service names and cluster IPs when wiring up integrations.

kubectl get services -n lumenvox

Show Everything in the Namespace

List every common resource (pods, services, deployments, replica sets, stateful sets) in a single command. Useful for a quick snapshot of the namespace's state.

kubectl get all -n lumenvox

Describe a Pod

Show detailed information for a specific pod — events, conditions, container status, environment variables, volume mounts, and more. Useful as a first stop when a pod will not start or is misbehaving.

kubectl describe pod <pod-name> -n lumenvox

Recent Events

Show recent cluster events, sorted by timestamp. When something has just broken, this is one of the fastest ways to see what Kubernetes was complaining about — failed image pulls, scheduling problems, liveness probe failures, and so on.

kubectl get events -n lumenvox --sort-by='.lastTimestamp'

Logs and Diagnostics

View Pod Logs

Show the logs from a specific container inside a pod. This is the most important command for installation troubleshooting — start here when something is not behaving as expected.

kubectl logs <pod-name> -c <container-name> -n lumenvox

Useful flags to add when needed:

  • -f — Follow the log stream in real time.
  • --tail=100 — Show only the most recent 100 lines.
  • --previous — Show logs from the previous container instance (useful when a pod has just restarted).
  • --since=1h — Show only logs from the last hour. Accepts other durations such as 10m, 24h.

Open a Shell Inside a Container

Get an interactive shell inside a running container. Indispensable for inspecting filesystems, testing connectivity, or running ad-hoc commands inside the pod. Most platform containers ship with sh; some include bash.

kubectl exec -it <pod-name> -c <container-name> -n lumenvox -- /bin/sh

To run a single command without an interactive session:

kubectl exec <pod-name> -c <container-name> -n lumenvox -- <command>

Check Resource Usage

Show current CPU and memory usage per pod. Requires the cluster's metrics server to be installed and running.

kubectl top pods -n lumenvox

Networking

List Ingress

Show the configured ingress points, including hostnames and IP addresses. Use this to verify that the Admin Portal and Deployment Portal endpoints are exposed as expected.

kubectl get ingress -n lumenvox

Port-Forward a Pod or Service

Forward a local port on your workstation to a port on a pod or service. Useful for testing internal endpoints (e.g. the Management API, a database) without exposing them through ingress.

kubectl port-forward pod/<pod-name> 8080:80 -n lumenvox
kubectl port-forward service/<service-name> 8080:80 -n lumenvox

The session stays open until you press Ctrl+C.

Lifecycle Management

Delete a Pod

Delete a pod so that Kubernetes auto-recreates it. This is a common way to recover a misbehaving pod without restarting the entire deployment.

kubectl delete pod <pod-name> -n lumenvox

Restart a Deployment

Trigger a rolling restart of every pod in a deployment. Each pod is replaced in turn, so the service stays available throughout. This is the preferred way to refresh a deployment without changing its configuration — useful after a configuration change at the cluster level, or to clear transient issues across all replicas.

kubectl rollout restart deployment/<deployment-name> -n lumenvox

Check Rollout Status

Watch the progress of a rollout (after a restart, scale change, or image update) until it completes. Returns control once every replica is updated and ready, or reports a failure.

kubectl rollout status deployment/<deployment-name> -n lumenvox

Scale a Deployment

Manually set the replica count for a deployment when auto-scaling is not enabled. The example below scales to 2 replicas:

kubectl scale deploy <deployment-name> --replicas=2 -n lumenvox

Roll Back a Deployment

Revert a deployment to its previous revision. Useful if a recent change has caused a regression.

kubectl rollout undo deployment/<deployment-name> -n lumenvox

To see the rollout history (and choose a specific revision to roll back to with --to-revision=N):

kubectl rollout history deployment/<deployment-name> -n lumenvox

Cluster and Storage

List Nodes

Show every node in the cluster along with its status, version, and age. Add -o wide for kernel version, OS image, and internal/external IPs.

kubectl get nodes
kubectl get nodes -o wide

Node Resource Usage

Show current CPU and memory usage per node. Requires the metrics server.

kubectl top nodes

List Persistent Volume Claims

Show the persistent volume claims (PVCs) the platform's stateful components rely on — the file store, databases, and similar. The status column should read Bound for healthy claims.

kubectl get pvc -n lumenvox

List ConfigMaps and Secrets

List the configmaps and secrets in the namespace. The secret command shows only names and types — values remain hidden.

kubectl get configmaps -n lumenvox
kubectl get secrets -n lumenvox

Context and Namespace

Show the Current Context

Confirm which cluster and user your kubectl is currently pointed at. Important to check before running anything destructive when you work with more than one cluster.

kubectl config current-context

List All Contexts

Show every cluster context configured in your kubeconfig.

kubectl config get-contexts

Switch Context

Switch to a different cluster context.

kubectl config use-context <context-name>

Related Articles


Was this article helpful?