---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: efs-sc
  csi:
    driver: efs.csi.aws.com
    volumeHandle: fs-0face104b4b98169a
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: efs-claim
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: efs-sc
  resources:
    requests:
      storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: joget-dx8-tomcat9
  labels:
    app: joget-dx8-tomcat9
spec:
  replicas: 2
  selector:
    matchLabels:
      app: joget-dx8-tomcat9
  template:
    metadata:
      labels:
        app: joget-dx8-tomcat9
    spec:
      volumes:
        - name: joget-dx8-tomcat9-pv
          persistentVolumeClaim:
            claimName: joget-dx8-tomcat9-pvc
      securityContext:
        runAsUser: 1000
        fsGroup: 0
      containers:
        - name: joget-dx8-tomcat9
          image: jogetworkflow/joget-dx8-tomcat9:latest
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: joget-dx8-tomcat9-pv
              mountPath: /opt/joget/wflow
          env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
---
apiVersion: v1
kind: Service
metadata:
  name: joget-dx8-tomcat9
  labels:
    app: joget-dx8-tomcat9
spec:
  ports:
    - name: http
      port: 8080
      targetPort: 8080
    - name: https
      port: 9080
      targetPort: 9080
  selector:
    app: joget-dx8-tomcat9
  type: NodePort
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: joget-dx8-tomcat9-clusterrolebinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: joget-dx8-ingress
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/healthcheck-path: /jw
    alb.ingress.kubernetes.io/success-codes: 200-399
    alb.ingress.kubernetes.io/load-balancer-attributes: idle_timeout.timeout_seconds=300
spec:
  rules:
    - http:
        paths:
          - pathType: Prefix
            path: "/jw"
            backend:
              service:
                name: joget-dx8-tomcat9
                port:
                  number: 8080
