This project involves creating a simple static website and deploying it using Docker and Kubernetes. The primary goal is to containerize a frontend application, push it to Docker Hub, and deploy it to a Kubernetes cluster managed by Kind (Kubernetes in Docker).
- Create a new project directory.
- Inside the directory, add the following files:
index.html(HTML file for the website)styles.css(CSS file for styling)
- Initialize a Git repository in the project directory.
- Add and commit your code to the Git repository.
- Create a
Dockerfileusing Nginx as the base image. - Copy the
index.htmlandstyles.cssfiles into the Nginx HTML directory.
- Log in to Docker Hub.
- Push the Docker image to your Docker Hub repository.
- Install Kind (Kubernetes in Docker).
- Create a Kind cluster.
- Create a Kubernetes Deployment YAML file to specify:
- The Docker image
- Desired replicas
- Apply the deployment to the Kind cluster.
- Create a Kubernetes Service YAML file specifying the service type as
ClusterIP. - Apply the service to your cluster.
- Port-forward the service to access the application locally.
- Open your browser and navigate to the forwarded port to view the application.
The following files will be included in the project:
index.html(Frontend HTML content)styles.css(CSS styling)Dockerfile(To containerize the application using Nginx)my-nginx-deployment.yaml(Kubernetes Deployment configuration)my-nginx-service.yaml(Kubernetes Service configuration)
- Docker installed on your system
- Kubernetes tools (e.g.,
kubectland Kind) - Docker Hub account
- Clone this repository.
- Build the Docker image:
docker build -t <your-dockerhub-username>/<repository-name>:<tag> .
- Push the Docker image to Docker Hub:
docker push <your-dockerhub-username>/<repository-name>:<tag>
- Create a Kind cluster:
kind create cluster
- Deploy the application:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
- Access the application:
Open your browser and navigate to
kubectl port-forward svc/<service-name> <local-port>:<service-port>
http://localhost:<local-port>.
This project is part of a containerization and orchestration capstone. Special thanks to mentors and peers for their guidance.