Wednesday, May 22, 2019

How To Install Jenkins X On Ubuntu VM

I hope these steps will be useful for those who want to try Jenkins X on a local VM without external IP (NAT). In my case this is VMware ESXi VM, Ubuntu 18.04.2 LTS, 10GB RAM.
For the Kubernetes installation, just follow the good instructions from here. 
My installation was different in that the to fix coredns Pending state, I’ve installed weave-net pod network instead of CALICO:

$ kubectl apply -f "$(kubectl version | base64 | tr -d '\ n')"

Few preparations were necessary before jx install: I killed much time getting ADDRESS column not empty in kubectl get ing output, using ClusterIP, NodePort and LoadBalancer in rotation, so I chose separate ingress install:

$ helm upgrade --install ingress --namespace=ingress --set \

  rbac.create=true,controller.kind=DaemonSet,controller.service.type=ClusterIP,controller.hostNetwork=true, stable/nginx-ingress

If you see:

Error: could not find tiller 

use these commands:

$ kubectl —-namespace kube-system create serviceaccount tiller

$ kubectl create clusterrolebinding tiller-cluster-rule —-clusterrole=cluster-admin —-serviceaccount=kube-system:tiller

$ kubectl —-namespace kube-system patch deploy tiller-deploy -p ‘{“spec”:{“template”:{“spec”:{“serviceAccount”:”tiller”}}}}’ 

$ kubectl taint nodes —all 

   Then I used nfs provider to get persistent volumes (nfs server is required):

$ helm install stable/nfs-client-provisioner --set nfs.server=NFS_SERVER_IP --set nfs.path=NFS_SHARE_PATH
Now it's ready for install:

$ jx install --provider=kubernetes --external-ip=YOUR_VM_IP --ingress-service=ingress-nginx-ingress-controller --ingress-deployment=ingress-nginx-ingress-controller --ingress-namespace=ingress --on-premise

Answer "no" when jx will ask "No existing ingress controller found in the kube-system namespace, shall we install one?"

After install, check that ADDRESS column is not empty in kubectl get ing output:

$ kubectl get ing
NAME                HOSTS                                    ADDRESS      PORTS   AGE
chartmuseum   80      42h
deck               80      42h
docker-registry   80      42h
hook               80      42h
jx-jx-app-jenkins   80      41h
monocular     80      42h
nexus             80      42h
tide               80      42h

  Check the local hook ingress connectivity:

$ curl -S

Now you can import your local project to Jenkins X with jx import or add some predefined projects with jx create.  
Since VM does not have an external IP,  webhooks that Jenkins prescribed on a Github will not work. There are several solutions here - for example ultrahook.  Replace Jenkins X webhooks URL for Staging, Production and your Dev repositories on Github with ultrahook URL and run with an ingress hook URL:

$ ultrahook github

To get Jenkins X console working (it only makes sense if you use Jenkinsfile in some project),  needs to install Jenkins App first (choose all required plugins):

$ jx add app jx-app-jenkins

and run it:

$ jx console

  Jenkins Console:

After opening this URL in browser, you'll see usual Jenkins login page. Surprisingly, the admin password you wrote down after installation is not suitable here. Maybe I missed something, but I had to run the following commands to find out the password:

$ go get

and then look for the jenkins-admin-password field:

$ kubectl get secret jx-jx-app-jenkins -o yaml | ksd

And you should see the familiar interface after login:

No comments:

Nekoware build system for IRIX

Besides Solaris, I love IRIX and, as the owner of the Octane, I'd like to have modern versions of at least basic utilities. Almost...