Skip to main content

Command Palette

Search for a command to run...

Launching your Kubernetes Cluster with Deployment

Published
•2 min read•View as Markdown

What is Deployment in k8s

A Deployment provides a configuration for updates for Pods and ReplicaSets.

You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new replicas for scaling, or to remove existing Deployments and adopt all their resources with new Deployments.

Today's task let's keep it very simple.

Task-1:

Create one Deployment file to deploy a sample todo-app on K8s using "Auto-healing" and "Auto-Scaling" feature

  • add a deployment.yml file (sample is kept in the folder for your reference)

  • apply the deployment to your k8s (minikube) cluster by command kubectl apply -f deployment.yml

Creating namespace.

- kubectl create namespace django-ns

image

View namespace.

- kubectl get namespace

image

Create deployment.yaml and view.

- vim deployment.yaml

- cat deployment.yaml

image

Applying the configuration od deployment.yaml file.

- kubectl apply -f deployment.yaml

image

View pods created with deployment file

- kubectl get pods -n django-ns

image

Deleting a pod

- kubectl delete pod django-deployment-6fcf5458b5-4tzqx -n django-ns

image

View pods

- kubectl get pods -n django-ns : (One pod is terminating and another pod is creating automatically to get the desired state (3 pods) mentioned in the deployment, and this feature is called "Auto Healing")

image

Changing the replicas to 4 in the deployment"

- vim deployment.yaml

- cat deployment.yaml

image

Apply the edited deployment

- kubectl apply -f deployment.yaml

image

View pods

- kubectl get pods -n django-ns: (Pods have been scaled to the desired state (4 pods) mentioned in the deployment file.

image

Let's make your resume shine with one more project ;)

Having an issue? Don't worry, adding a sample deployment file , you can always refer that or wathch this video

Happy Learning :)

More from this blog

Untitled Publication

32 posts