apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: poc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      initContainers:
      - name: init-nginx-config
        image: nginx:latest
        command: ['sh', '-c', 'cp -r /etc/nginx/* /mnt/etc']
        volumeMounts:
        - name: etc-volume
          mountPath: /mnt/etc
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
          name: config-volume
        - mountPath: /var/log/nginx
          name: log-volume
        - mountPath: /mnt/nfs
          name: nfs-volume
        - mountPath: /etc/nginx
          name: etc-volume
      volumes:
      - name: config-volume
        configMap:
          name: nginx-config
      - name: log-volume
        persistentVolumeClaim:
          claimName: log-pvc
      - name: nfs-volume
        persistentVolumeClaim:
          claimName: nfs-pvc
      - name: etc-volume
        persistentVolumeClaim:
          claimName: etc-pvc

