Scale a Deployment
# Scale a deployment to 3 replicas
kubectl scale deployment my-deployment --replicas=3
Debug a Running Pod
# Start a debugging session in a running Pod
kubectl exec -it pod-name -- /bin/sh
Create a Kubernetes Job
# Sample Kubernetes Job configuration
apiVersion: batch/v1
kind: Job
metadata:
name: example-job
spec:
template:
spec:
containers:
- name: example
image: busybox
command: ["echo", "Hello Kubernetes"]
restartPolicy: Never
View Cluster Resource Utilization
# Check resource usage for nodes and namespaces
kubectl top nodes
kubectl top pods --namespace=my-namespace
Rolling Update for Deployments
# Update the image version for a deployment with zero downtime
kubectl set image deployment/my-deployment my-container=myimage:v2