Kubectl Deployment

Kubectl deployment is the fastest way to push workloads to a Kubernetes cluster. It is direct, controlled, and scriptable. With a single command, you define the desired state of your application and let Kubernetes match reality to that state.

What is Kubectl Deployment

Kubectl is the CLI for Kubernetes. The kubectl apply and kubectl create commands handle deployments. A Deployment resource manages ReplicaSets and pods. It ensures your app runs with the exact number of instances, updated with zero downtime, and rolled back if something fails.

Create a Deployment

Start with a YAML manifest. This file describes:

  • apiVersion: apps/v1
  • kind: Deployment
  • metadata: name, labels
  • spec: replicas, selector, pod template

Example:

apiVersion: apps/v1
kind: Deployment
metadata:
 name: my-app
spec:
 replicas: 3
 selector:
 matchLabels:
 app: my-app
 template:
 metadata:
 labels:
 app: my-app
 spec:
 containers:
 - name: my-app-container
 image: myimage:latest
 ports:
 - containerPort: 80

Run:

kubectl apply -f deployment.yaml

Update a Deployment

Change the image version in your manifest. Apply again. Kubernetes rolls out the new pods while keeping the old ones running until the new version is ready.

kubectl set image deployment/my-app my-app-container=myimage:v2

Monitor progress:

kubectl rollout status deployment/my-app

Roll Back a Deployment

If the update fails:

kubectl rollout undo deployment/my-app

Kubernetes returns to the last stable state. This is critical for minimizing downtime.

Scale a Deployment

To handle more load:

kubectl scale deployment my-app --replicas=10

Scaling down is just as simple.

Best Practices for Kubectl Deployment

  • Use declarative YAML for repeatability.
  • Tag images clearly to avoid accidental updates.
  • Monitor rollout status for every change.
  • Combine deployments with ConfigMaps and Secrets for environment settings.
  • Test in staging before production.

The kubectl deployment process is the heartbeat of modern Kubernetes operations: define, apply, scale, update, and roll back. It is fast, predictable, and under your control.

Run this in a real cluster now. See it live in minutes with hoop.dev — no friction, no waiting, just your deployment in action.