0% found this document useful (0 votes)
49 views3 pages

Ex 9

xcv

Uploaded by

sanjaybatthula24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views3 pages

Ex 9

xcv

Uploaded by

sanjaybatthula24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No: 9

Automate the Process of Running Containerized Application Using Kubernetes


Aim: Automate the process of running the containerized application developed in exercise 7
using Kubernetes.

Description:
To automate the process of running the containerized application developed in exercise 7
using Kubernetes, follow these steps:

Lab Manual: Automate the Process of Running Containerized Application


Using Kubernetes

1. Create a Kubernetes Cluster


Create a Kubernetes cluster using one of the following methods:
- Cloud providers like Google Cloud (GKE) or Amazon Web Services (EKS).
- Local installation using Minikube or Docker Desktop.
For this lab, ensure Kubernetes is enabled in Docker Desktop (Windows) or Minikube is
installed.

2. Push the Docker Image to a Registry


Push the Docker image of your application (developed in Exercise 7) to a container registry,
such as Docker Hub or Google Container Registry:
1. Log in to Docker Hub:
docker login

2. Push the image:


docker push your-dockerhub-username/app-name:tag

3. Create a Deployment
Create a deployment in Kubernetes that specifies the number of replicas and the Docker
image to use. Below is an example YAML file for the deployment:

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

4. Create a Service
Create a service in Kubernetes that exposes the deployment to the network. Below is an
example YAML file for the service:

apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
- name: http
port: 80
targetPort: 80
type: ClusterIP

5. Apply the Deployment and Service


Apply the deployment and service to the cluster using the `kubectl` command-line tool:

kubectl apply -f deployment.yaml


kubectl apply -f service.yaml
6. Verify the Deployment
Verify the deployment by checking the status of the pods and the service:

kubectl get pods


kubectl get services

Additional Notes
This is a basic example of how to automate the process of running a containerized
application using Kubernetes. In real-world scenarios, you might need to handle additional
complexities such as:
- Managing persistent data.
- Scaling applications.
- Rolling updates.
This lab provides a good starting point for using Kubernetes to manage your containers.

Result
By following this lab manual, you successfully automated the process of running the
containerized application developed in Exercise 7 using Kubernetes.

You might also like