apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
  namespace: jenkins
  labels:
    app: jenkins
spec:
  selector:
    matchLabels:
      app: jenkins
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      serviceAccountName: jenkins
      containers:
        - name: jenkins
          image: jenkins/jenkins:2.263.4-lts-alpine
          imagePullPolicy: IfNotPresent
          env:
            - name: JAVA_OPTS
              value: -Xmx2048m -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85 -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts;"
          ports:
            - containerPort: 8080
              protocol: TCP
            - containerPort: 50000
              protocol: TCP
          volumeMounts:
            - mountPath: /var/jenkins_home
              name: jenkins
      restartPolicy: Always
      securityContext:
        runAsUser: 0
      terminationGracePeriodSeconds: 30
      volumes:
        - name: jenkins
          persistentVolumeClaim:
            claimName: jenkins-claim
