我正在尝试部署Magento应用,但出现以下错误。该集群是在EKS上创建的,PVC
找不到persistentvolumeclaim“媒体” 错误:无法启动容器“ magento-web”:来自守护程序的错误响应:OCI运行时创建失败:container_linux.go:349:启动容器进程导致“ process_linux.go:449:容器初始化导致了“ rootfs_linux.go:58:安装” \“ / var / lib / kubelet / pods / 8865b7dsdbd-721c-45f3-ab77-43a5f5da1362 / volume-subpaths / nginx-config / magento-web / 0 \”到rootfs \“ / var / lib / docker / overlay2 / b1b3faa530b6sasas4ad6a9e62db641 / merged \“,位于\” / var / lib / docker / overlay2 / b1b3faa530b64ad6a9e62db641c5589fef3d29a9ab01fdsd2db594652851a1814a6 / merged / etc / nginx / conf.d / default.conf \“导致\”不是目录\“”:未知:您是否要尝试:将目录挂载到文件上(反之亦然)?检查指定的主机路径是否存在以及是否为预期的类型 后退重启失败的容器
apiVersion: v1
kind: Service
metadata:
name: magento-web
namespace: magento
labels:
app: magento-web
k8s-app: magento
spec:
ports:
- name: "http"
port: 80
protocol: TCP
targetPort: 80
selector:
app: magento-web
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: magento-web
namespace: magento
labels:
app: magento-web
k8s-app: magento
spec:
selector:
matchLabels:
app: magento-web
strategy:
rollingUpdate:
maxSurge: 50%
maxUnavailable: 30%
type: RollingUpdate
template:
metadata:
labels:
app: magento-web
k8s-app: magento
spec:
containers:
- image: nginx:mainline
imagePullPolicy: Always
name: magento-web
ports:
- containerPort: 80
protocol: TCP
resources:
limits:
cpu: 10m
memory: 128Mi
requests:
cpu: 10m
memory: 128Mi
volumeMounts:
- mountPath: /etc/nginx/conf.d/default.conf
name: nginx-config
subPath: default.conf
- mountPath: /var/www/html/magento2.conf
name: nginx-config
subPath: magento2.conf
- name: media
mountPath: /var/www/html/pub/media
- mountPath: /var/www/html/pub/static
name: static
volumes:
- configMap:
defaultMode: 420
name: nginx
name: nginx-config
- name: media
persistentVolumeClaim:
claimName: media
- name: static
persistentVolumeClaim:
claimName: static
kubectl get pvc -n magento
volumes:
- configMap:
defaultMode: 420
name: nginx
name: nginx-config
- name: media
persistentVolumeClaim:
claimName: media
- name: static
persistentVolumeClaim:
claimName: static
答案 0 :(得分:2)
由于错误提示“ default.conf,您是否正在尝试将目录挂载到文件上(反之亦然)”
configmap的用法似乎不正确,请尝试这样使用
- configMap:
items:
- key: default.conf
path: default.conf
name: nginx
name: nginx-config