By following these steps, you should have successfully set up Minikube with Docker, installed kubectl, and optionally configured Jenkins for CI/CD automation. This setup will allow you to deploy microservices applications on Kubernetes locally with minimal downtime using strategies like blue-green deployment.
- VM (Virtual Machine) - You need to create a Virtual Machine on your system to install and run Minikube.
- Minikube - Tool for running Kubernetes clusters locally.
- Docker - A containerization tool needed for Minikube's setup.
- kubectl - Command line tool for interacting with Kubernetes clusters.
- Jenkins - For automating deployment processes (optional, for CI/CD).
- Linux (Red Hat/CentOS/Fedora) - Minikube works best on Linux operating systems.
-
Create a VM:
- Install a Virtual Machine platform like VirtualBox, VMware, or KVM.
- Set up a Linux distribution (Red Hat 9.2 is suggested).
-
Install Docker:
- Follow the installation guide for Docker based on your operating system:
sudo dnf install docker -y sudo systemctl start docker sudo systemctl enable docker
- Make sure the Docker daemon is running and that your user is added to the Docker group:
sudo usermod -aG docker $USER newgrp docker
- Follow the installation guide for Docker based on your operating system:
-
Install Minikube:
- Download and install Minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo mv minikube-linux-amd64 /usr/local/bin/minikube sudo chmod +x /usr/local/bin/minikube
- Download and install Minikube:
-
Install kubectl:
- Install kubectl using
dnf
or download the binary manually:sudo dnf install kubectl -y
- Install kubectl using
-
Install Minikube:
- Run the following command to start Minikube with the default driver (Docker in this case):
minikube start --driver=docker
- Run the following command to start Minikube with the default driver (Docker in this case):
-
Verify Minikube Setup:
- Check if Minikube is running:
minikube status
- Check if Minikube is running:
-
Setting up Jenkins (Optional for CI/CD):
- Pull the latest Jenkins Docker image:
sudo docker pull jenkins/jenkins:lts
- Run Jenkins in a Docker container:
sudo docker run -d -p 8080:8080 -p 50000:50000 --name jenkins jenkins/jenkins:lts
- Retrieve the Jenkins initial admin password:
sudo docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
- Pull the latest Jenkins Docker image:
-
Access Jenkins:
- Visit
http://localhost:8080
in your browser and use the password retrieved above to unlock Jenkins.
- Visit
-
Set up Kubernetes with Minikube:
- Use kubectl to interact with the Kubernetes cluster created by Minikube:
kubectl cluster-info
- Use kubectl to interact with the Kubernetes cluster created by Minikube:
-
Install Jenkins Plugins:
- From the Jenkins dashboard, go to Manage Jenkins > Manage Plugins, and install necessary plugins such as:
- Kubernetes Plugin
- CloudBees Folder Plugin
- Docker Pipeline Plugin
- Git Plugin
- From the Jenkins dashboard, go to Manage Jenkins > Manage Plugins, and install necessary plugins such as:
-
**Configure CI/CD Pipeline
- Set up your Jenkins pipeline for automating deployments to Kubernetes clusters using Jenkins and Docker.
To trigger Jenkins pipeline builds automatically on code changes, set up a webhook in your GitHub repository with the following URL:
http://your-jenkins-server/github-webhook/
To build and run your Docker image, follow these steps:
-
Build the Docker Image:
docker build -t my-django-app .
-
Run a Container using the Built Image:
docker run -d -p 8000:8000 my-django-app
Replace 8000:8000 with the appropriate port mapping if your Django application uses a different port.
-
View Running Containers: docker ps
-
Push the Docker Image to a Registry (e.g., Docker Hub):
docker push username/my-django-app
Replace username with your Docker Hub username and my-django-app with the name you want to give to your Docker image.
We welcome contributions from the community! If you'd like to contribute to this project, please follow these steps:
- Fork the repository on GitHub.
- Create a new branch off of develop for your feature or fix.
- Make your changes and commit them with clear, descriptive commit messages.
- Push your changes to your fork.
- Submit a pull request against the develop branch of the original repository.