kubectl 1.37 cheatsheet

kubectl 1.37: Creating and changing

8 common kubectl 1.37 tasks.

Apply a manifest

Create or update the resources defined in a file.

kubectl apply -f deployment.yaml

Apply a folder of manifests

Create or update everything in a folder.

kubectl apply -f k8s/

Apply a Kustomize directory

Build and apply a folder containing a kustomization.yaml.

kubectl apply -k overlays/prod

Create a deployment

Create a deployment from an image.

kubectl create deployment web --image=nginx

Expose a deployment as a service

Create a service in front of a deployment.

kubectl expose deployment web --port=80

Edit a resource in your editor

Open the live definition and apply your changes on save.

kubectl edit deployment web

Delete resources from a manifest

Delete everything defined in a file.

kubectl delete -f deployment.yaml

Caution: Check kubectl config current-context first so you don't delete on the wrong cluster.

Delete a pod

Delete a pod. A controller usually creates a replacement.

kubectl delete pod web-7d9f8c6b5-abcde

Was this page helpful?