Docker and Kubernetes Exercise
The goal of this exercise is to gain hands-on experience with Docker and get acquainted with the basics of Kubernetes.
In this step, you will create a Docker image based on a Linux distribution. The image should include the necessary tools, such as curl
, to perform various operations.
In this step, you will develop a basic server that can handle incoming requests and respond with the hostname and current time. You will need to write the server code and then create a Dockerfile to containerize the project.
Now it's time to deploy the project on Kubernetes using Minikube. You will need to write the required deployment files, including a Config Map, Deployment, and Service. These files will define the desired state of the application and how it should be managed within the cluster.
Follow the steps below to execute the project:
- Build the Docker image:
docker build -t image-name .
- Run the Docker container:
docker run -d -p 8080:8080 image-name
- Access the server by sending requests to
http://localhost:8080
To deploy the project on Kubernetes using Minikube:
- Ensure Minikube is installed and running.
- Apply the Kubernetes deployment files:
kubectl apply -f deployment.yaml
- Access the deployed application using the exposed service.
Please note that you may need to customize the deployment files, such as specifying container image names and ports, to align with your project's requirements.
By completing this exercise, you will have gained practical experience with Docker and Kubernetes, enabling you to containerize applications and deploy them on a Kubernetes cluster.