Make connection with kubernetes and jenkins
This document outlines the steps to connect Kubernetes and Jenkins on a Linux (Ubuntu) machine with Minikube running. 🖥 🖥️ 📡
Prerequisites: 📜
-
Jenkins installed on a Linux (Ubuntu) machine.
-
Minikube running on the same machine.
Required Plugins:
-
Docker
-
Docker Pipeline
-
Kubernetes
Creating a Service Account and Secret for Kubernetes Plugin in Minikube 🏗️🛠️
- Create a file named account.yaml with the following content:
for file file
- Run the following command:
kubectl apply -f account.yaml
Save the secret token data for configuring Kubernetes credentials in Jenkins:
-
Run
kubectl get secrets
to list secrets. -
Run
kubectl describe secrets/jenkins-token
to get the token data . -
Copy the token and store it securely.
Adding Kubernetes Credentials to Jenkins
-
Open Jenkins and navigate to Manage Jenkins > Manage Credentials.
-
Click “Secret Text” and paste the copied token into the field.
-
Create a Kubernetes ID named “my_kubernetes” with the token as credentials.
Adding DockerHub Credentials to Jenkins 📇
- Navigate to Manage Jenkins > Manage Credentials.
- Click “Username and Password” and provide your DockerHub credentials.
Configuring Kubernetes Plugin in Jenkins 🔲 🔲 🔲
-
Navigate to Manage Jenkins > Manage Nodes & Clouds.
-
Scroll to the bottom and click “Add a new cloud”. Select “Kubernetes”.
Convert the Minikube CA certificate to Base64 encoding:
Bash
cat /home/devyan/.minikube/ca.crt | base64 -w 0; echo
-
Use Kubernetes Id(my_kubernetes) which was crated earlier.
-
Paste the encoded certificate into the “Kubernetes server certificate key” field.
-
Save the configuration.
-
Verification and Next Steps