# ๐Ÿš€ Kubernetes Deployment Management A guide to managing **Deployments** in Kubernetes, including listing, editing, scaling, rollbacks, and version history. --- ## ๐Ÿ“‹ Listing & Editing Deployments ### ๐Ÿ”น List Deployments in a Namespace ```bash kubectl get deploy -n ``` ### ๐Ÿ”น Edit a Deployment ```bash kubectl edit deployment.apps -n ``` > ๐Ÿ› ๏ธ **Note:** > Unlike ReplicaSets, Deployments **automatically update** existing Pods when the image or spec is changed. This makes Deployments ideal for rolling updates and version control. --- ## ๐Ÿ“ˆ Scaling a Deployment Scale the number of replicas (Pods) for a Deployment: ```bash kubectl scale -n deployment --replicas= ``` --- ## ๐Ÿ” Rollout Management ### ๐Ÿ”น View Rollout History ```bash kubectl rollout history deployment -n ``` ### ๐Ÿ”น View Specific Revision ```bash kubectl rollout history deployment -n --revision= ``` ### ๐Ÿ”น Roll Back to a Previous Revision ```bash kubectl rollout undo deployment -n --to-revision= ``` > โœ… **Tip:** > Deployments maintain revision history. This allows you to **roll back to a previous working version** in case of failure. --- ## ๐Ÿงพ Example Deployment YAML ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: app-1 namespace: dev labels: label1: test1 app.kubernetes.io/label2: test2 spec: replicas: 3 selector: matchLabels: app.kubernetes.io/label2: test2 template: metadata: labels: app.kubernetes.io/label2: test2 os: linux spec: containers: - name: nginx image: nginx ``` > ๐ŸŽฏ **Why use Deployments?** > They offer: * Rolling updates * Rollbacks * Declarative Pod management * History tracking --- ## โœ… Summary | Feature | Pod | ReplicaSet | Deployment | | ---------------- | --- | ---------- | ---------- | | Manual creation | โœ… | ๐Ÿšซ | ๐Ÿšซ | | Scales Pods | โŒ | โœ… | โœ… | | Self-healing | โŒ | โœ… | โœ… | | Rolling updates | โŒ | โŒ | โœ… | | Revision history | โŒ | โŒ | โœ… |