Hi All,
I was trying to setup Jenkins in Rancher server using NFS (Shared storage)
I ran into many issues and finally solved it.
Thought will share the steps so that others will benefit.
-
Before getting started with, make sure you have hosts setup in Rancher Environment.
-
Next follow this steps on this link: Rancher-Nfs Prerequiiste
-
Click on Catalog menu in Rancher server and search for nfs
Click on view details button.
- You will see a screen like below. Enter the details as seen in screenshot. HostIP will be your NFS server.
Note : The export base directory should be same as the directory you created as part of Step 2.
Click on launch button.
- Navigate to Infrastructure tab to double check storage driver is active.
- Now proceed to Stack menu and create a stack.
I will be creating a Jenkins stack.
docker-compose.yml
version: '2'
volumes:
jenkins-var-jenkins:
driver: rancher-nfs
jenkins-etc-ssl-certs:
driver: rancher-nfs
services:
Jenkins:
image: jenkins:2.60.2
stdin_open: true
volumes:
- jenkins-var-jenkins:/var/jenkins_home
- jenkins-etc-ssl-certs:/etc/ssl/certs
tty: true
Jenkins-LB:
image: rancher/lb-service-haproxy:v0.7.5
ports:
- 8080:8080/tcp
labels:
io.rancher.container.agent.role: environmentAdmin
io.rancher.container.create_agent: 'true'
rancher-compose.yml
version: '2'
services:
Jenkins:
scale: 2
start_on_create: true
Jenkins-LB:
scale: 1
start_on_create: true
lb_config:
certs: []
port_rules:
- path: ''
priority: 1
protocol: http
service: Jenkins
source_port: 8080
target_port: 8080
- You may see an error like in the screenshot below.
-
Go to your host machine and edit /etc/exports and add “no_root_squash” to the mount option.
It will look like
/nfs *(rw,sync,no_subtree_check,no_root_squash) -
Restart the nfs-server with command.
systemctl restart nfs-server ( It varies on linux versions) -
Delete and recreate the stack as per Step 6
-
A jenkins stack with load balancer will be created and accessible now.
Note: You can check my github repo for the code.
Jenkins-Rancher-Catalog