kubernetes的使用六--安装jenkins

本文是kubernetes的使用的第五篇,我们安装jenkins,我们都知道jenkins是CI/CD的集成非常好用的工具,那我们也少不了要用它了。下面就是部署jenkins的yaml文件:

Jenkins-deployment.yaml:

apiVersion: extensions/v1beta1

kind: Deployment

metadata:

name: jenkins

spec:

replicas: 1

template:

metadata:

labels:

app: jenkins

spec:

containers:

- name: jenkins

image: jenkins

imagePullPolicy: IfNotPresent

ports:

- containerPort: 8080

- containerPort: 50000

readinessProbe:

httpGet:

path: /login

port: 8080

periodSeconds: 10

timeoutSeconds: 5

successThreshold: 2

failureThreshold: 5

env:

- name: JENKINS_OPTS

value: ""

volumeMounts:

- mountPath: /var/jenkins_home

name: jenkins-home

resources:

limits:

cpu: 500m

memory: 1500Mi

requests:

cpu: 500m

memory: 1500Mi

volumes:

- name: jenkins-home

nfs:

server: 197.168.60.2

path: /home/nfs_data/my_jenkins

Jenkins-service.yaml文件:

apiVersion: v1

kind: Service

metadata:

name: jenkins-ui

spec:

selector:

app: jenkins

type: NodePort

ports:

- protocol: TCP

port: 8080

targetPort: 8080

nodePort: 30005

name: ui

 

---

apiVersion: v1

kind: Service

metadata:

name: jenkins-slaves

spec:

selector:

app: jenkins

ports:

- protocol: TCP

port: 50000

targetPort: 50000

name: slaves

在jenkins-service.yaml中看见,我们利用了NodePort特性,就能够利用http://${master_ip}:nodePort的方式访问我们的jenkins。

你可能感兴趣的:(kubernetes的使用六--安装jenkins)