apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
  namespace: wordpress
  labels:
    app: wordpress
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      containers:
      - image: riscv64/wordpress:6.7.2-php8.1-fpm-alpine
        name: wordpress
        imagePullPolicy: Always
        env:
        - name: WORDPRESS_DB_HOST
          value: "mariadb.mariadb"
        - name: WORDPRESS_DB_PASSWORD
          value: "wordpress"
        - name: WORDPRESS_DB_USER
          value: "wordpress"
        - name: WORDPRESS_DB_NAME
          value: "wordpress"
        ports:
         - containerPort: 9000
           name: php-fpm
           protocol: TCP
        volumeMounts:
         - name: nfs-wordpress
           mountPath: /var/www/html
           subPath: html
      - name: nginx
        image: riscv64/nginx:1.27.4-alpine
        ports:
          - containerPort: 80
        volumeMounts:
          - name: nfs-wordpress
            mountPath: /var/www/html
            subPath: html
          - name: nfs-wordpress
            mountPath: /etc/nginx/conf.d/default.conf
            subPath: default.conf
      volumes:
      - name: nfs-wordpress
        persistentVolumeClaim:
          claimName: wordpress-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: wordpress
  namespace: wordpress
spec:
  selector:
    app: wordpress
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: wordpress-pv
spec:
  storageClassName: ""
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    server: 192.168.2.110
    path: /mnt/nfs_share/wordpress/riscv
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: wordpress-pvc
  namespace: wordpress
spec:
  storageClassName: ""
  volumeName: wordpress-pv
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 2Gi
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: wordpress-http
  namespace: wordpress
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`wordpress-riscv.allarddcs.nl`)
      kind: Rule
      services:
        - name: wordpress
          port: 80
      middlewares:
        - name: redirect-to-https
          namespace: wordpress
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: wordpress-tls
  namespace: wordpress
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`wordpress-riscv.allarddcs.nl`)
      kind: Rule
      services:
        - name: wordpress
          port: 80
  tls:
    certResolver: letsencrypt
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: redirect-to-https
  namespace: wordpress
spec:
  redirectScheme:
    scheme: https
    permanent: true



