我目前正在开发一个 Lumen 项目,我们使用 Minikube 作为我们的开发环境。我们的主机/Users/development/<project name>
安装在/var/www/html
并且工作正常。/var/www/html/storage/framework
但是,由于整个/var/www/html
目录具有1001:1001所有权这一事实,我面临着文件写入无法正常工作的存储问题。
这是我的部署规范:
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: apiserver
namespace: development
labels:
app: sample-app-name
spec:
selector:
matchLabels:
app: sample-app-name
tier: apiserver
replicas: 1
template:
metadata:
labels:
app: sample-app-name
tier: apiserver
spec:
containers:
- name: php-app
image: my-image:latest
resources:
requests:
cpu: 100m
memory: 100Mi
imagePullPolicy: Never
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/var/www/html"
name: host-mount
imagePullSecrets:
- name: dockercred
volumes:
- name: host-mount
hostPath:
path: "/Users/development/<app directory>"
我尝试将持久卷移动到它自己的单独文件中,并创建了一个 pvc,但它仍然无法正常工作。我还尝试了多种方法来更改使用初始化容器和安全上下文的目录权限,但它仍然始终将权限设置为 **1001:1001* 我在这里真的很绝望,所以任何帮助将不胜感激。
主机规格:
- 操作系统:Ubuntu 18.04.3 LTS
- Minikube 版本:v0.30.0
- Kubectl 客户端版本:客户端版本:version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10- 15T19:18:23Z",GoVersion:"go1.12.10",编译器:"gc",平台:"linux/amd64"}
- Kubectl 服务器版本:服务器版本:version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03- 26T16:44:10Z",GoVersion:"go1.9.3",编译器:"gc",平台:"linux/amd64"}
- Virtualbox 版本:5.2.34 r133893 (Qt5.9.5)
编辑:(这是我在部署中使用的图像的 docker 文件)
FROM phpearth/php:7.1-nginx
RUN apk add --no-cache php7.1-redis php7.1-pdo php7.1-pdo_pgsql php7.1-xdebug composer bash
COPY ./nginx-default.conf /etc/nginx/conf.d/default.conf
COPY ./xdebug.ini /etc/php/7.1/conf.d/xdebug.ini
COPY ./www.conf /etc/php/7.1/php-fpm.d/www.conf
RUN mkdir -p /var/www/storage/import
RUN mkdir -p /var/www/storage/import/files
RUN mkdir -p /var/www/storage/import/templates
RUN mkdir -p /var/www/storage/logs
RUN mkdir -p /var/www/storage/framework/sessions
RUN mkdir -p /var/www/storage/framework/views
RUN touch /var/www/storage/logs/lumen.log
RUN chown -Rf 1000:1000 /var/www/
# Install the blackfire client
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s http://packages.blackfire.io/binaries/blackfire-php/1.23.1/blackfire-php-alpine_amd64-php-71.tar.gz \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > /etc/php/7.1/conf.d/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz