apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    jenkins: slave
    jenkins/label: static-jnlp
  name: static-jnlp
  namespace: ci
spec:
  replicas: 1
  selector:
    matchLabels:
      app: static-jnlp
  serviceName: static-jnlp
  template:
    metadata:
      labels:
        app: static-jnlp
      name: static-jnlp
    spec:
      containers:
      - name: jnlp
        env:
        - name: JENKINS_SECRET
          value: "bb150372e4dddb4cd64c376fb6ea6979a904312a20cd1cbe588eed5a1f8da47c"
        - name: JAVA_OPTS
          value: -server -Djava.awt.headless=true -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider
            -Dfile.encoding=UTF8 -Xverify:none -XX:MetaspaceSize=128m -XX:+UseNUMA -XX:+UseNUMAInterleaving
            -XX:NUMAInterleaveGranularity=65536 -XX:+UseLargePages -XX:+UseCompressedOops
            -XX:MaxMetaspaceSize=512m -XX:ReservedCodeCacheSize=240M -XX:MaxRAMFraction=2
            -XshowSettings:vm -XX:+AggressiveOpts -Djute.maxbuffer=41943040 -XX:-UseBiasedLocking
            -XX:+UseFastAccessorMethods -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
            -XX:+UseCompressedOops -XX:+CMSClassUnloadingEnabled  -XX:+CMSScavengeBeforeRemark
            -XX:+DisableExplicitGC -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:SoftRefLRUPolicyMSPerMB=0
            -XX:G1ReservePercent=25 -XX:G1NewSizePercent=10 -XX:G1MaxNewSizePercent=25
            -XX:MaxGCPauseMillis=20 -XX:-OmitStackTraceInFastThrow -XX:+ParallelRefProcEnabled
            -XX:ParallelGCThreads=8 -XX:MaxTenuringThreshold=1 -XX:G1HeapWastePercent=10
            -XX:SurvivorRatio=8 -XX:G1MixedGCCountTarget=16 -XX:G1MixedGCLiveThresholdPercent=90
            -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=32m -XX:+PerfDisableSharedMem
            -XX:-ResizePLAB
        - name: JENKINS_AGENT_NAME
          value: static-jnlp-0
        - name: JENKINS_NAME
          value: static-jnlp-0
        - name: JENKINS_AGENT_WORKDIR
          value: /home/jenkins
        - name: JENKINS_URL
          value: http://jenkins.ci/
        image: slpcat/kube-jenkins-dind-agent:oraclejdk8-bullseye
        imagePullPolicy: Always
        resources:
          limits:
            cpu: "4"
            memory: 4Gi
          requests:
            cpu: "4"
            memory: 4Gi
        securityContext:
          #privileged: true
          runAsUser: 0
          runAsGroup: 0
          #fsGroup: 1000
        volumeMounts:
        - mountPath: /home/jenkins
          name: workspace-volume
        - mountPath: /var/run/docker.sock
          name: docker-sock
        workingDir: /home/jenkins
      #imagePullSecrets:
      #- name: ali-vpc
      nodeSelector:
        kubernetes.io/os: linux
        kubernetes.io/arch: amd64
        #kubernetes.io/hostname=node001
      volumes:
      - name: docker-sock
        hostPath:
          # directory location on host
          path: /var/run/docker.sock
          # this field is optional
          type: Socket 
  volumeClaimTemplates:
  - metadata:
      name: workspace-volume
    spec:
      accessModes:
      - ReadWriteOnce
      #ceph rbd storageclass
      #storageClassName: rbd
      resources:
        requests:
          storage: 80Gi
