这是我的 PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: do-block-storage
这是我的部署配置
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysite
labels:
tier: backend
spec:
replicas: 2
selector:
matchLabels:
app: mysite
tier: backend
strategy:
type: Recreate
template:
metadata:
labels:
app: mysite
tier: backend
spec:
containers:
- name: mysite
image: my-image
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/nginx/sites-enabled
- name: my-pvc
mountPath: /var/www/app
volumes:
- name: my-pvc
persistentVolumeClaim:
claimName: my-pvc
- name: config
configMap:
name: wordpress-nginx-config
items:
- key: config
path: default.conf
imagePullSecrets:
- name: registry-secret
这是我的 wordpress 配置图
apiVersion: v1
kind: ConfigMap
metadata:
name: wordpress-nginx-config
labels:
tier: backend
data:
config: |
server {
listen 80;
index index.php index.html;
server_name _;
error_log /dev/stdout info;
access_log /dev/stdout;
root var/www/app;
location /.git {
deny all;
return 403;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
expires 5d;
}
location ^~ /.well-known {
allow all;
auth_basic off;
}
}
访问我的服务 URL 时,仍然出现错误 404。我将不胜感激任何能得到的帮助。我部署时没有使用 PVC,但成功了,我知道问题出在我的 PVC 配置上。