L
L
letema2019-03-23 17:13:06
PHP
letema, 2019-03-23 17:13:06

How to merge nginx php-fpm containers in kubernetes?

Good afternoon. I'm trying to merge two containers in a pod.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: app
  name: app-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: app
    spec:
      volumes:
        - name: shared-files
          emptyDir: {}
        - name: shared-log
          hostPath:
            path: /env/var/log/nginx
        - name: nginx-config-default
          configMap:
            name: nginx-default
        - name: php-fpm
          configMap:
            name: php-fpm
        - name: php-fpm-xdebug
          configMap:
            name: php-fpm-xdebug
      containers:
        - image: nginx:1.15.9
          name: nginx
          ports:
          - containerPort: 80
          volumeMounts:
            - name: shared-files
              mountPath: /var/www/
            - name: shared-log
              mountPath: /var/log/nginx
            - name: nginx-config-default
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
        - image: app
          imagePullPolicy: Never
          name: app
          ports:
          - containerPort: 11080
          volumeMounts:
            - name: shared-files
              mountPath: /var/www
            - name: php-fpm
              mountPath: /etc/php/7.1/fpm/pool.d/www.conf
              subPath: www.conf
            - name: php-fpm-xdebug
              mountPath: /usr/local/etc/php/conf.d/xdebug-dev.ini
              subPath: xdebug-dev.ini
          lifecycle:
            postStart:
              exec:
                command: ["/bin/sh", "-c", "cp -r /app/. /var/www"]
status: {}

Why is the var/www folder in the pod empty even though there are files in the app container in the folder

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question