Can I use Jenkins kubernetes plugin when Jenkins server is outside of a kubernetes cluster? Can I use Jenkins kubernetes plugin when Jenkins server is outside of a kubernetes cluster? kubernetes kubernetes

Can I use Jenkins kubernetes plugin when Jenkins server is outside of a kubernetes cluster?


1、prepare a service account for kubernetes-plugin in k8s

apiVersion: v1kind: ServiceAccountmetadata:  name: jenkins---kind: RoleapiVersion: rbac.authorization.k8s.io/v1beta1metadata:  name: jenkinsrules:- apiGroups: [""]  resources: ["pods"]  verbs: ["create","delete","get","list","patch","update","watch"]- apiGroups: [""]  resources: ["pods/exec"]  verbs: ["create","delete","get","list","patch","update","watch"]- apiGroups: [""]  resources: ["pods/log"]  verbs: ["get","list","watch"]- apiGroups: [""]  resources: ["secrets"]  verbs: ["get"]---apiVersion: rbac.authorization.k8s.io/v1beta1kind: RoleBindingmetadata:  name: jenkinsroleRef:  apiGroup: rbac.authorization.k8s.io  kind: Role  name: jenkinssubjects:- kind: ServiceAccount  name: jenkins

2、find the according secret generated: jenkins-token-xxxxxx

From the k8s dashboard, we can get the "ca.crt" string and "token" string from the secret.

3、configure jenkins cloud

In the "Kubernetes server certificate key" item, fill in the "ca.crt" string.

In the "Credentials" item, creat a credential of type "Secret text" or "OpenShift OAuth token"(even if we use the pure k8s), fill in the "token" string, then use the credential.

"Test Connection" should pass now.


Answer on another question: https://stackoverflow.com/a/48834012/502914

We are using Jenkins outside a Kubernetes cluster, but able to connect to the cluster, spin up pods as slaves and destroy after builds are done (using default namespace).