apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
  namespace: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      containers:
      - name: jenkins
        image: allardkrings/riscv64-jenkins:1.6
        securityContext:
          privileged: true
        ports:
          - name: http-port
            containerPort: 8080
          - name: jnlp-port
            containerPort: 50000
#        env:
#          - name: MASTER_GLOBAL_JAVA_OPTIONS
#            value: "org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.defaultImage=allardkrings/riscv64-jenkins-agent:1.0" 
        volumeMounts:
          - name: jenkins-home
            mountPath: /var/jenkins_home
      serviceAccountName: "jenkins-service-account"
      volumes:
        - name: jenkins-home
          persistentVolumeClaim:
            claimName: jenkins-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: jenkins
  namespace: jenkins
spec:
  ports:
    - port: 8080
      name: primary
      targetPort: 8080
    - port: 50000
      name: agent
      targetPort: 50000
  selector:
    app: jenkins
  type: ClusterIP
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: jenkins-tls
  namespace: jenkins
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`jenkins-riscv.allarddcs.nl`)
    kind: Rule
    services:
    - name: jenkins
      port: 8080
  tls:
    certResolver: letsencrypt
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-pv
spec:
  storageClassName: ""
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    server: 192.168.2.110
    path: /mnt/nfs_share/jenkins
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pvc
  namespace: jenkins
spec:
  storageClassName: ""
  volumeName: jenkins-pv
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi


