Tech & DevOps HubEspace Tech & DevOps

Explorez le monde du Dev, du Cloud et des outils DevOps à travers nos articles et discussions Explore the world of development, the cloud and DevOps tools
 FR      EN
K8S
Général
Show deployment definition
kubectl get deploy myapp -o yaml

Shows the full YAML manifest of the resource.
List nodes with labels
kubectl get nodes --show-labels

Displays nodes and their labels.
List all pods
kubectl get pods -A

Shows all pods across all namespaces with status.
List all available APIs
kubectl api-resources

Shows all Kubernetes API resources.
List all namespace resources
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n my-namespace

Displays all active resources in the namespace.
Port-forward a service
kubectl port-forward svc/myapp 8080:80

Allows local access to the service port.
Debug
Debug pod with ephemeral container
kubectl debug pod/mypodName -it --image=busybox

Provides interactive debugging inside the pod.
List pods sorted by CPU
kubectl top pod --sort-by=cpu

Displays highest CPU-consuming pods.
Logs from crashed pod
kubectl logs podName --previous
kubectl logs -p podName

Shows logs from the last terminated container.
Show recent events
kubectl get events --sort-by=.metadata.creationTimestamp

Displays recent cluster events.
Delete
Delete failed pods
kubectl delete pod --field-selector=status.phase=Failed

Deletes pods in Failed status.
Delete all namespace resources
kubectl delete all --all -n test

Deletes all resources inside the namespace.
Deployment
Apply manifest
kubectl apply -f deployment.yaml

Creates or updates resources from a YAML file.
Restart deployment
kubectl rollout restart deploy myapp

Forces pod restart for deployment.
Execute
Execute command in container
kubectl exec -it mypodName -c nginx -- bash

Opens an interactive shell inside a container.
Execute command in pod
kubectl exec -it podName -- bash

Opens an interactive shell in a pod.