---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: jenkins
  namespace: jenkins
spec:
  serviceName: jenkins
  replicas: 1
  selector:
    matchLabels:
      k8s-app: jenkins
  template:
    metadata:
      labels:
        k8s-app: jenkins
    spec:
      containers:
        - name: jenkins
          image: harbor.freedom.org/freedom/jenkins-centos7:2.319.1-1.1
          imagePullPolicy: Always
          ports:
            - name: tcp8080
              containerPort: 8080
          env:
            - name: TZ
              value: Asia/Shanghai
          resources:
            limits:
              cpu: 4000m
              memory: 8192Mi
            requests:
              cpu: 100m
              memory: 256Mi
          volumeMounts:
            - name: jenkins-data
              mountPath: /data
            # `docker run docker`配置。
            - name: docker-socket
              mountPath: /var/run/docker.sock
              readOnly: true
      volumes:
        - name: docker-socket
          hostPath:
            path: /var/run/docker.sock
  volumeClaimTemplates:
    - metadata:
        name: jenkins-data
        annotations:
          volume.beta.kubernetes.io/storage-class: storageclass-nfs-infra
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 50Gi