Mustafa CavusogluMC

Command Palette

Search for a command to run...

AboutExperiencesProjects
Linux3Docker3Git3uv1Miniconda1Kubernetes3
Back to Home
Kubernetes

Essential kubectl commands for Kubernetes management

kubectlpodsdeploymentsservices

kubectl Basics

Essential commands for Kubernetes cluster management.

Cluster Information

# View cluster info
kubectl cluster-info

# Get nodes
kubectl get nodes

# View current context
kubectl config current-context

# List contexts
kubectl config get-contexts

# Switch context
kubectl config use-context my-cluster

Working with Resources

# Get resources
kubectl get pods
kubectl get services
kubectl get deployments
kubectl get all

# Get with more details
kubectl get pods -o wide

# Get YAML output
kubectl get pod my-pod -o yaml

# Describe resource
kubectl describe pod my-pod

# Watch resources
kubectl get pods -w

Creating Resources

# Apply manifest
kubectl apply -f manifest.yaml

# Create from file
kubectl create -f manifest.yaml

# Create deployment
kubectl create deployment nginx --image=nginx

# Expose as service
kubectl expose deployment nginx --port=80 --type=LoadBalancer

Debugging

# View pod logs
kubectl logs pod-name

# Follow logs
kubectl logs -f pod-name

# Logs from specific container
kubectl logs pod-name -c container-name

# Execute in pod
kubectl exec -it pod-name -- bash

# Port forward
kubectl port-forward pod-name 8080:80