Skip to main content

Common Commands

Updated at: 2025-11-18 16:03:25

The following commands are useful when working with Kubernetes on the Virtual Kubernetes Services.
For more commands, refer to the Kubernetes official documentation.

Apply and Edit Manifests

Examples
---
kubectl apply -f [manifest.yaml] # Apply a manifest to deploy resources or update existing ones
kubectl edit [resource_type] [resource_name/id] # Edit a resource manifest using your default text editor

Check Resource Status

Examples
---
# General syntax
kubectl get [resource_type]

# Deployments
kubectl get deploys # List all active deployments
kubectl get deploy [deployment-name] # Show details of a specific Deployment

# Services
kubectl get services # List all Services in the current namespace
kubectl get services --sort-by=.metadata.name # Sort Services by name
kubectl get services --namespace [namespace] # List Services in a specific namespace


# PVC
kubectl get pvc # List active PersistentVolumeClaims

# Virtual Servers
kubectl get vs

# Pod
kubectl get pods # List all Pods in the current namespace
kubectl get pods -o wide # Display additional Pod information
kubectl get pods --namespace [namespace] # List Pods in a specific namespace

# CPU, GPU, and memory requests for each Pod
# Note: Assumes that jq is installed.
kubectl get pods -o json | jq '.items[] | {name:.metadata.name,cpu:.spec.containers[].resources.requests.cpu,gpu:.spec.containers[].resources.requests。"nvidia.com/gpu", memory:.spec.containers[].resources.requests.memory}'

Describe Pods and Retrieve Logs

Examples
---
# General syntax
kubectl describe [resource_type] [name/id]

# Pod
kubectl describe pods # Show detailed information for all Pods
kubectl describe pod [pod_id] # Details for a specific Pod
kubectl describe pod [pod_id] -o yaml # YAML output for a specific Pod


# Logs
kubectl logs -f [pod_id] # Stream logs from a Pod

Delete Resources

Examples
---
kubectl delete [resource_type] [name/id]
kubectl delete pod [pod_id] # Delete a Pod; its Pods will be removed and not recreated.
kubectl delete deploy [deployment_name] # Delete a Deployment; Pods will not restart

Scaling

Examples
---
kubectl scale --replicas=[number] [resource_type]/[name/id]


## Scale a Deployment to [number] replicas
kubectl scale --replicas=[number] deployment/[deployment_name]

Execute Commands in a Pod

Examples
---
kubectl exec -it [pod_id] -- bash # Open a bash shell inside your Pod