gmacario/easy-jenkins

Install Kubernetes plugins

gmacario opened this issue · 4 comments

Reopening issue as a reminder that I should understand how to configure the plugin to talk to an external Kubernetes cluster - See conversation in #289 for my initial attempts

Try configuring Jenkins to connect to Kubernetes cluster "kube-101" on GCP

Reference: https://cloud.google.com/solutions/configuring-jenkins-kubernetes-engine

See also: https://github.com/jenkinsci/kubernetes-plugin/blob/master/README.md sections

  • Running locally with minikube
  • Running in Google Container Engine GKE

Locally testing on nemo (Ubuntu 18.04.1 LTS 64-bit)

Browse https://console.cloud.google.com > Kubernetes Engine > Clusters

  • Select cluster "kube-101"
  • In tab "Details", section "Cluster", take note of Endpoint (public IP address)
  • Click "Show credentials"
gcloud init
gcloud container clusters list
gcloud container describe kube-101
gcloud container clusters get-credentials kube-101
kubectl config view
kubectl cluster-info
kubectl get namespaces
kubectl create namespace easy-jenkins

Jenkins > Manage Jenkins > Configure System

  • Cloud > Add a new cloud > Kubernetes
    • Name: kube-101 (from GCP console > Clusters)
    • Kubernetes URL: https://35.241.146.224 (paste from GCP console: Cluster Details > Endpoint)
    • Kubernetes server certificate key: (paste from GCP console: Cluster credentials > Cluster CA certificate)
    • Disable https certificate check: No
    • Kubernetes Namespace: easy-jenkins
    • Credentials > Add > Jenkins
      • Domain: Global credentials (unrestricted)
      • Kind: Username with password
        • Scope: Global (Jenkins, nodes, items, all child items, etc)
        • Username: admin (paste from GCP console: Cluster credentials > Username)
        • Password: (paste from GCP console: Cluster credentials > Password)
        • ID: (empty)
        • Description: (empty)
      • Click "Add"

Click "Test Connection" and make sure that

Connection test successful

Continue configuring Kubernetes Cloud "kube-101"

  • Jenkins URL: http://nemo.gmacario.it:9080
  • Jenkins tunnel: (empty)
  • Connection Timeout: 0 (leave default)
  • Read Timeout: 0 (leave default)
  • Container Cap: 10 (leave default)
  • Pod Retention: Never
  • Images > Kubernetes Pod Template
    • Name: jnlp slave
    • Namespace: (emtpy)
    • Labels: (empty)
    • Usage: TODO (Use this node as much as possible)
    • The name of the pod template to inherit from: (empty)
    • Containers > Container Template
      • Name: (empty)
      • Docker image: jenkins/jnlp-slave
      • Always pull image: No
      • Working directory: /home/jenkins
      • Command to run: /bin/sh -c
      • Arguments to pass to the command: cat
      • Allocate pseudo-TTY: Yes
      • EnvVars: (none)
      • Volumes: (none)
      • Max number of instances: (empty)
      • Pod Retention: Default
      • Time in minutes to retain slave when idle: (empty)
      • Time in seconds for Pod deadline: (empty)
      • Time in seconds for Jenkins connection: 100 (default)
      • Raw yaml for the Pod: (empty)

then click "Save"

Test:

Jenkins > Open Blue Ocean > New Pipeline

  • Where do you store your code? GitHub
  • Which organization does the repository belong to? gmacario
  • Choose a repository: test-jenkins-kubernetes-plugin

The multibranch pipeline is loaded and started, however the build of branch "feature/kube-declarative-pipeline" never starts

screenshot from 2018-10-05 15-04-22

This situation can also be detected by looking at the Kubernetes dashboard of cluster "kube-101", namespace "easy-jenkins":

screenshot from 2018-10-05 15-09-12

It looks look like that the Pods mypod-kr0c7-xxxx running inside Kubernetes cluster "kube-101" on GCP are unable to connect to our Jenkins master, since the URL http://nemo.gmacario.it:9080 is behind a corporate firewall.

Closing issue, will reopen when we able to test both Jenkins master as well as the slaves deployed on the same Kubernetes cluster, or at least with some capability of communicating to each other.

Detailed instructions to deploy a Jenkins cluster on Kubernetes posted at https://gmacario.github.io/howto/kubernetes/gcp/jenkins/2018/10/09/install-jenkinsx-on-gcp.html