Skip to content

Manarhamed00/CICD-Pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 

Repository files navigation

My Project

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.

Getting Started

Prerequisites

Tools Required

  1. VM (Virtual Machine) - You need to create a Virtual Machine on your system to install and run Minikube.
  2. Minikube - Tool for running Kubernetes clusters locally.
  3. Docker - A containerization tool needed for Minikube's setup.
  4. kubectl - Command line tool for interacting with Kubernetes clusters.
  5. Jenkins - For automating deployment processes (optional, for CI/CD).
  6. Linux (Red Hat/CentOS/Fedora) - Minikube works best on Linux operating systems.

Prerequisites

  1. Create a VM:

    • Install a Virtual Machine platform like VirtualBox, VMware, or KVM.
    • Set up a Linux distribution (Red Hat 9.2 is suggested).
  2. 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
  3. 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
  4. Install kubectl:

    • Install kubectl using dnf or download the binary manually:
      sudo dnf install kubectl -y

Installation Steps

  1. Install Minikube:

    • Run the following command to start Minikube with the default driver (Docker in this case):
      minikube start --driver=docker
  2. Verify Minikube Setup:

    • Check if Minikube is running:
      minikube status
  3. 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
  4. Access Jenkins:

    • Visit http://localhost:8080 in your browser and use the password retrieved above to unlock Jenkins.
  5. Set up Kubernetes with Minikube:

    • Use kubectl to interact with the Kubernetes cluster created by Minikube:
      kubectl cluster-info

Additional Configuration (Optional)

  1. 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
  2. **Configure CI/CD Pipeline

    • Set up your Jenkins pipeline for automating deployments to Kubernetes clusters using Jenkins and Docker.

Webhooks

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/

Docker Setup

Docker Commands

To build and run your Docker image, follow these steps:

  1. Build the Docker Image:

    docker build -t my-django-app .

  2. 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.

  1. View Running Containers: docker ps

  2. 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.

Future Improvement

Testing and Validation

Contributing

We welcome contributions from the community! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository on GitHub.
  2. Create a new branch off of develop for your feature or fix.
  3. Make your changes and commit them with clear, descriptive commit messages.
  4. Push your changes to your fork.
  5. Submit a pull request against the develop branch of the original repository.

Testing and Validation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published