$ cat pvc.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: jenkins namespace: jenkins spec: accessModes: - ReadWriteOnce resources: requests: storage: 30Gi storageClassName: rbd $ cat deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: jenkins namespace: jenkins spec: replicas: 1 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 selector: matchLabels: app: jenkins template: metadata: labels: app: jenkins spec: dnsPolicy: ClusterFirst containers: - name: jenkins image: jenkins/jenkins:lts imagePullPolicy: IfNotPresent securityContext: runAsUser: 0 ports: - containerPort: 8080 name: web protocol: TCP - containerPort: 50000 name: agent protocol: TCP env: - name: JAVA_OPTS value: "-Duser.timezone=Asia/Shanghai" volumeMounts: - name: jenkinshome mountPath: /var/jenkins_home volumes: - name: jenkinshome persistentVolumeClaim: claimName: jenkins $ cat service.yaml kind: Service apiVersion: v1 metadata: name: jenkins namespace: jenkins labels: app: jenkins spec: ports: - port: 8080 targetPort: 8080 name: web selector: app: jenkins $ cat ingress.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: jenkins namespace: jenkins annotations: kubernetes.io/ingress.class: "nginx" spec: rules: - host: xxjenkins.tagtic.cn http: paths: - path: '/' backend: serviceName: jenkins servicePort: 8080 tls: - hosts: - xxjenkins.tagtic.cn secretName: all-tagtic.cn
$cd agent/ $ cat service.yaml apiVersion: v1 kind: Service metadata: labels: app: jenkins name: jenkins-agent namespace: jenkins spec: ports: - name: agent port: 50000 protocol: TCP targetPort: 50000 selector: app: jenkins sessionAffinity: None type: ClusterIP
配置 jenkins