编写jenkins.yaml
说明:
容器跑起来后,jenkins的目录是/var/jenkins_home
存储卷用的是hostPath,这里面我们指定pod调度到k8s-master01
在k8s-master01上创建目录:mkdir /data_jenkins
创建名称空间:kubectl create ns jenkins
jenkins.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
name: jenkins
namespace: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
nodeName: k8s-master01
containers:
- name: jenkins
image: jenkins/jenkins:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
name: web
protocol: TCP
- containerPort: 50000
name: agent