将Nginx Webroot挂载到PersistenVolume中

时间:2018-12-19 16:42:31

标签: kubernetes

我正在尝试创建基本的php-fpm和nginx设置。

我有2个docker映像,一个运行php-fpm,另一个运行nginx(自定义一个,包括我的php代码)

我创建了两个容器都使用的PersistentVolumeClaim。

我的问题是,当我exec进入nginx容器时,webroot文件夹为空。

我目前正在为/var/www/html创建一个卷,并在我的Nginx图像中,COPY将我的index.php放入/var/www/html

我有以下内容:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
    name: pv-claim
spec:
    accessModes:
    - ReadWriteOnce
    resources:
        requests:
            storage: 2Gi

我的nginx-deployment.yaml中包含以下内容

    spec:
        containers:
        - name: nginx
          image: MY_CUSTOM/IMAGE:v1
          ports:
          - containerPort: 80
            name: nginx
          volumeMounts:
          - name: persistent-storage
            mountPath: /var/www/html
          - name: nginx-config-volume
            mountPath: /etc/nginx/nginx.conf
            subPath: nginx.conf
        volumes:
        - name: persistent-storage
          persistentVolumeClaim:
              claimName: pv-claim
        - name: nginx-config-volume
          configMap:
              name: nginx-config

我期望的是/var/www/html下的docker映像中的内容将在卷内。

除非我完全不正确。如果是这样,我如何将我的应用放入卷挂架中?

谢谢

0 个答案:

没有答案