Deploying a Web Application Using Kubernetes
In this assignment, we will deploy a web application using Kubernetes on a
local Minikube cluster. This setup will allow us to run and manage
containerized applications efficiently.
Steps to Deploy the Web Application
Step 1: Start Minikube
We need to start Minikube, which will set up a local Kubernetes cluster.
Run the following command in your terminal:
minikube start
This will initialize the Kubernetes cluster on your local system.
Step 2: Navigate to the Deployment Directory
Now, move to the directory where your YAML configuration files are stored.
cd
~/Devops/kubernetes/deploy/yaml/apache_phpadmin_mysql/PHPMYAD
MIN_MYSQL
This directory contains the Kubernetes configuration files needed for
deployment.
Step 3: Apply Namespace
Namespaces in Kubernetes help in organizing different resources. We will
apply the namespace configuration to create a new namespace for our
deployment.
kubectl apply -f [Link]
This will create a namespace lampdemo where our resources will be
deployed.
Step 4: Deploy Resources in the Namespace
Now, deploy all the required resources in the lampdemo namespace using
kubectl apply.
kubectl apply -n lampdemo -k ./
This command applies all the YAML configuration files present in the current
directory. It deploys Apache, PHPMyAdmin, and MySQL services.
Step 5: Check the Status of Pods
To ensure everything is running correctly, check the status of the pods in the
lampdemo namespace.
kubectl get po -n lampdemo
This will display a list of running pods. Each pod should have a Running
status.
Step 6: Check Services
Next, we check the services running in the lampdemo namespace.
kubectl get svc -n lampdemo
This will show details such as service name, type, external IP, and ports
needed to access the application.
Step 7: Access the Service
To access the deployed application, use the Minikube service command.
minikube service lamp -n lampdemo
This command will open the application in your browser or provide the URL
where the service is running.
Step 8: Verify the Deployment
Finally, verify if the web application is accessible by visiting the provided URL
(e.g., [Link]
You should see your web application running successfully.