Jenkins connects to the K8s cluster through the kubernetes plugin

1. Jenkins installs the kubernetes plugin

1.1 Click System Management on the left

1.2 Click Plugin Management

1.3 Install the plugin Kubernetes plugin

1.4 Restart Jenkins after installation

Enter http://192.168.0.196:8080/restart in the browser, click "Yes" on the page to restart Jenkins

2. Enter the configuration page

2.1 Click System Management on the left

2.2 Click Node Management

2.3 Click Configure Clouds

3. Configuration

3.1 Select Kubernetes from the drop-down box

3.2 Click Kubernetes Cloud details... to enter the configuration details page

3.3 Fill in the authentication information

Need to fill in the 4 contents in the red box

Kubernetes address

View this via the command line

kubectl cluster-info

The red box is the address

Kubernetes service certificate key

It is the certificate-authority-data part in /root/.kube/config, and encrypted by base64

Enter the following command in the terminal to view certificate-authority-data:

cat .kube/config

Execute the following command for base64 encryption:

echo "certificate-authority-data冒号后面的内容" | base64 -d

Fill in the content in the red box into "Kubernetes service certificate key"

Kubernetes namespace

Just use default by default

credentials

This place needs to add a

In the pop-up page, type Secret text

The following Secret is added through the terminal:

  • Create
kubectl create sa jenkins

Get the token name

kubectl describe sa jenkins

Get token value

kubectl describe secrets jenkins-token-szvg9 -n default

The token in the above figure is the content filled in the Secret

The last description can be filled in freely

Click Add and the credentials are ready

4. Verification

Click the connection test, the k8s cluster version is displayed on the left

Fill in the Jenkins address below, and click the save button to complete

Guess you like

Origin blog.csdn.net/huangge1199/article/details/126037432