Day - 32: Launching your Kubernetes Cluster with Deployment

Day - 32: Launching your Kubernetes Cluster with Deployment

ยท

3 min read

This is #90DaysofDevops challenge under the guidance of ShubhamLondhe sir.

Day 32 TASK

Introduction:

  • In the realm of Kubernetes (k8s), Deployment stands as a cornerstone concept for managing applications' lifecycles. It provides a powerful mechanism for defining and controlling the state of application replicas within a cluster. Let's embark on a journey to explore the essence of Deployment and its practical applications.

What is Deployment in k8s

  • A Deployment in Kubernetes serves as a blueprint for orchestrating updates to Pods and Replica Sets. By defining a desired state within a Deployment configuration, the Kubernetes Deployment Controller orchestrates the transition from the current state to the desired state seamlessly and at a controlled pace.

Key Features of Deployment:

  • Today's task simplifies the complex nature of Deployment in Kubernetes by focusing on two fundamental features: Auto-healing and Auto-scaling.

Tasks:

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

Here are the steps:

  1. Launch an EC2 instance and select "t2.medium" as the instance type.

  2. Once the instance is running, connect to it using SSH.

    Now Clone the repository from GitHub. GitHub Repo link:

    https://github.com/Akashdhengale/django-todo-cicd.git

    Here are the steps to clone a repository from GitHub:

  • Go to the GitHub repository's page.

  • Find the green "Code" button and click on it.

  • Copy the URL provided. It should look something like this: github.com/username/repository-name.git

  • Open your terminal or command prompt.

  • Navigate to the directory where you want to clone the repository using the cd command.

  • Type git clone followed by the URL you copied earlier.

  • Press Enter to execute the command.

  • Now let's create aDockerfile.

  • Let's proceed with generating the image.

  •     docker build . -t django-todo:latest
    

    Proceeding to create a Docker container to verify if the image is running on a specific port or not.

    1. Run the following command to create a Docker container from your image and map a port on your local machine to a port in the container:
    docker run -d -p 8000:8000 django-todo:latest

2. To push your Docker image to Docker Hub, follow these steps:

  • Log in to Docker Hub:
docker login
docker push akash2097/django-todo:latest

  • To add a deployment.yml file

  • To apply the deployment to your Kubernetes (minikube) cluster, you can use the kubectl apply -f command. Here's how:
kubectl apply -f deployment.yaml

  • To list a deployment:
kubectl get deployments
  • To get Pods:
kubectl get pods

  • We'll delete one of the pods that belong to our application, and then we'll check to see if Kubernetes automatically creates a new pod to replace the one we deleted.
kubectl delete pod <pod_name>

  • In Kubernetes, "auto-healing" refers to the automatic detection and recovery from pod failures or issues without manual intervention.

  • "Auto-scaling" dynamically adjusts the number of pods in a deployment based on workload demands, ensuring optimal resource utilization and performance.

Conclusion:

  • In Kubernetes, Deployment is key for managing app lifecycles. With features like auto-healing and auto-scaling, it helps DevOps make deployments smoother and ensure apps run well. As you learn more about Kubernetes, mastering Deployment will open doors to better app management and scaling. Keep exploring for more tips and tutorials on Kubernetes. Happy Deploying!

Feel free to drop any questions in the comments section. I'm here to help!

If you liked what you read, please consider following and giving it a thumbs up ๐Ÿ‘ to show your support ๐Ÿ˜„

Thanks for taking the time to read! ๐Ÿ’š

Did you find this article valuable?

Support Akash Dhengale by becoming a sponsor. Any amount is appreciated!

ย