apiVersion: apps/v1
kind: Deployment
metadata:
  name: drupal
  namespace: drupal
  labels:
    app: drupal
spec:
  replicas: 1
  selector:
    matchLabels:
      app: drupal
  template:
    metadata:
      labels:
        app: drupal
    spec:
      containers:
        - name: drupal
          image: riscv64/drupal:fpm
          imagePullPolicy: Always
          env:
            - name: MYSQL_DATABASE
              value: drupal
            - name: MYSQL_USER
              value: drupal
            - name: MYSQL_PASSWORD
              value: DRUPAL
            - name: MYSQL_ROOT_PASSWORD
              value: password
          ports:
            - containerPort: 9000
          volumeMounts:
            - name: drupal-data
              mountPath: /opt/drupal/web
        - name: nginx
          image: riscv64/nginx:1.27.4-alpine
          ports:
            - containerPort: 80
          volumeMounts:
            - name: drupal-data
              mountPath: /opt/drupal/web
            - name: nginx-config
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
      volumes:
        - name: drupal-data
          persistentVolumeClaim:
            claimName: drupal-pvc
        - name: nginx-config
          configMap:
            name: nginx-config
---
apiVersion: v1
kind: Service
metadata:
  name: drupal
  namespace: drupal
  labels:
    app: drupal
spec:
  selector:
    app: drupal
  type: NodePort
  sessionAffinity: None
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: drupal-tls
  namespace: drupal
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`drupal-riscv.allarddcs.nl`)
    kind: Rule
    services:
    - name: drupal
      port: 80
  tls:
    certResolver: letsencrypt
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: drupal-http
  namespace: drupal
spec:
  entryPoints:
    - web
  routes:
  - match: Host(`drupal-riscv.allarddcs.nl`)
    kind: Rule
    services:
    - name: drupal
      port: 80
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: drupal-pv
spec:
  storageClassName: ""
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    server: 192.168.2.110
    path: /mnt/nfs_share/drupal/riscv
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: drupal-pvc
  namespace: drupal
spec:
  storageClassName: ""
  volumeName: drupal-pv
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi

