# deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: test
  name: phpenv-php-fpm
  labels:
    app: phpenv-php-fpm
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpenv-php-fpm
  template:
    metadata:
      labels:
        app: phpenv-php-fpm
    spec:
      #做一个emptyDir类型，名为wwwroot的volume 用于多个容器共享同一个挂载
      volumes:
        - name: wwwroot
          emptyDir: { }
        - name: nginx-config-volume
          configMap:
            name: nginx-config
      imagePullSecrets:
        - name: qcloudregistrykey
        # 私有docker 镜像仓库
      #      # 自定义设置POD的hosts
      #      hostAliases:
      #        - ip: "127.0.0.1"
      #          hostnames:
      #            - "php-fpm"
      containers:
        #php-worker php工作环境
        - name: php-worker
          image: ccr.ccs.tencentyun.com/simmoc/phpenv_php-worker:v1.0
          imagePullPolicy: Always
          volumeMounts:
            - name: wwwroot
              mountPath: /var/www/html
          # 容器启动后，将容器中的代码拷贝到 本地文件系统的共享目录/var/www/html中
          lifecycle:
            postStart:
              exec:
                command: [ "/bin/sh", "-c", "cp -r /data/www/ /var/www/html" ]
        #php-fpm php运行环境
        - name: php-fpm
          image: ccr.ccs.tencentyun.com/simmoc/phpenv_php-fpm:v1.0
          imagePullPolicy: Always
          volumeMounts:
            - name: wwwroot
              mountPath: /var/www/html


        #php-nginx nginx
        - name: php-nginx
          image: ccr.ccs.tencentyun.com/simmoc/phpenv_nginx:v1.0
          imagePullPolicy: Always
          volumeMounts:
            - name: wwwroot
              mountPath: /var/www/html
            - name: nginx-config-volume
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          # livenessProbe:
          #   httpGet:
          #     path: /
          #     port: http
          # readinessProbe:
          #   httpGet:
          #     path: /
          #     port: http
          resources:
            { }
