apiVersion: apps/v1
kind: Deployment
metadata:
  name: drupal-deployment
  namespace: <NAMESPACE_PLACEHOLDER>
spec:
  replicas: 1
  selector:
    matchLabels:
      app: drupal
  template:
    metadata:
      labels:
        app: drupal
    spec:
      imagePullSecrets:
        - name: ghcr-image-pull-secret
      
      containers:
      - name: drupal-container
        image: <FULL_IMAGE_PATH_PLACEHOLDER>
        ports:
        - containerPort: 80
        
        env:
        # IP viene de variables de GitHub
        - name: DRUPAL_DB_HOST
          value: "<DRUPAL_DB_HOST_PLACEHOLDER>"
        - name: DRUPAL_DB_PORT
          value: "5432"
        # Nombre viene de variables de GitHub
        - name: DRUPAL_DB_NAME
          value: "<DRUPAL_DB_NAME_PLACEHOLDER>"
        - name: DRUPAL_DB_USER
          valueFrom:
            secretKeyRef:
              name: drupal-db-secret
              key: username
        - name: DRUPAL_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: drupal-db-secret
              key: password
        - name: DRUPAL_HASH_SALT
          valueFrom:
            secretKeyRef:
              name: drupal-config-secret
              key: hash-salt
        - name: SERVER_IP
          value: "<SERVER_IP_PLACEHOLDER>"
        
        volumeMounts:
        - name: drupal-files
          mountPath: /var/www/html/web/sites/default/files
        - name: drupal-private
          mountPath: /var/www/html/private
        
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 120
          periodSeconds: 30
        
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 60
          periodSeconds: 10
      
      volumes:
      - name: drupal-files
        persistentVolumeClaim:
          claimName: drupal-files-pvc
      - name: drupal-private
        persistentVolumeClaim:
          claimName: drupal-private-pvc