![Kubernetes 上现有的 Wordpress 部署,其中持久卷在部署时返回错误 404](https://linux22.com/image/748418/Kubernetes%20%E4%B8%8A%E7%8E%B0%E6%9C%89%E7%9A%84%20Wordpress%20%E9%83%A8%E7%BD%B2%EF%BC%8C%E5%85%B6%E4%B8%AD%E6%8C%81%E4%B9%85%E5%8D%B7%E5%9C%A8%E9%83%A8%E7%BD%B2%E6%97%B6%E8%BF%94%E5%9B%9E%E9%94%99%E8%AF%AF%20404.png)
这是我的 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 配置上。