Part-87: π Kubernetes Deployments with Imperative Commands in GCP (Google Kubernetes Engine)

In this guide, weβll explore Kubernetes Deployments using the imperative way on Google Kubernetes Engine (GKE).
Weβll cover creating, scaling, updating, exposing, and managing deployments step by step.
π Topics Covered
- Create Deployment
- Scale the Deployment
- Expose Deployment as a Service
- Update Deployment
- Rollback Deployment
- Rolling Restarts
πΉ Step 01: Introduction to Deployments
What is a Deployment?
A Deployment in Kubernetes is a higher-level abstraction that manages Pods and ReplicaSets.
It allows you to define:
- The container image to run
- The number of replicas (Pods)
- Update strategies (rolling updates)
- Rollback in case of failures
What can we do with a Deployment?
Using a deployment, you can:
- Roll out new application versions
- Scale the number of Pods up/down
- Ensure self-healing (Pods restart if they fail)
- Perform rolling updates & rollbacks
- Expose applications internally or externally
πΉ Step 02: Create a Deployment
Letβs create a simple Nginx deployment with 3 replicas.
# Create Deployment
kubectl create deployment my-first-deployment \
--image=ghcr.io/stacksimplify/kubenginx:1.0.0 \
--replicas=3
# Verify Deployment
kubectl get deployments
kubectl get deploy
# Describe Deployment
kubectl describe deployment my-first-deployment
# Verify ReplicaSet
kubectl get rs
# Verify Pods
kubectl get po
β At this point, we have 3 Pods running managed by a Deployment & ReplicaSet.
πΉ Rollout History with Change-Cause
Kubernetes allows tracking deployment revisions and rolling back if needed.
# Check Rollout History
kubectl rollout history deployment/my-first-deployment
# Add change-cause annotation
kubectl annotate deployment/my-first-deployment \
kubernetes.io/change-cause="Deployment CREATE - App Version 1.0.0"
# Verify rollout history
kubectl rollout history deployment/my-first-deployment
πΉ Step 03: Scaling a Deployment
We can easily scale the number of Pods up or down.
# Scale Up to 6 replicas
kubectl scale --replicas=6 deployment/my-first-deployment
# Verify
kubectl get deploy
kubectl get rs
kubectl get po
# Scale Down to 3 replicas
kubectl scale --replicas=3 deployment/my-first-deployment
kubectl get deploy
πΉ Step 04: Expose Deployment as a Service
By default, Pods are accessible only inside the cluster.
Weβll expose the Deployment using a LoadBalancer service so itβs accessible externally.
# Expose Deployment
kubectl expose deployment my-first-deployment \
--type=LoadBalancer \
--port=80 \
--target-port=80 \
--name=my-first-deployment-service
# Get Service Info
kubectl get svc
π Note: On GCP, a public LoadBalancer IP will be created.
πΉ Step 05: Access the Application
Once the LoadBalancer is provisioned, youβll see an External IP.
# Access Application in Browser
http://
# Or via curl
curl http://
β
Recap
With imperative commands in GKE, we:
- Created a Deployment
- Verified ReplicaSet & Pods
- Scaled Pods up & down
- Exposed app via LoadBalancer
- Tracked rollout history
π Thanks for reading! If this post added value, a like β€οΈ, follow, or share would encourage me to keep creating more content.
β Latchu | Senior DevOps & Cloud Engineer
βοΈ AWS | GCP | βΈοΈ Kubernetes | π Security | β‘ Automation
π Sharing hands-on guides, best practices & real-world cloud solutions