Kubernetes: MountVolume.SetUp failed: hostPath类型检查失败不是一个目录

我正在尝试使用hydra部署登录同意提供程序。

这是yaml文件。

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: login-consent-deployment
  labels:
    app: login-consent-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: login-consent-nginx
  template:
    metadata:
      labels:
        app: login-consent-nginx
    spec:
      containers:
      - name: login-consent-nginx
        image: ubergarm/openresty-nginx-jwt:latest
        command: ["/usr/local/openresty/bin/openresty", "-g", "daemon off;", "-c", "/usr/local/openresty/nginx/conf/nginx.conf"]
        ports:
        - name: http-lc-port
          containerPort: 80
        resources:
          limits:
            cpu: "0.1"
            memory: 32Mi
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: login-consent-nginx-conf-volume
        - mountPath: /usr/local/openresty/nginx/html
          name: login-consent-www-resources
      volumes:
      - name: login-consent-nginx-conf-volume
        configMap:
          name: login-consent-conf
          items:
            - key: login-consent.conf
              path: login-consent.conf
      - name: login-consent-www-resources
        hostPath:
          path: C:\Users\myUser\www
          type: Directory

---
apiVersion: v1
kind: Service
metadata:
  name: login-consent-service
spec:
  type: LoadBalancer
  selector:
    app: login-consent-nginx
  ports:
  - protocol: TCP
    name: http-lc-nginx
    port: 3000
    targetPort: http-lc-port

部署后我在pod说明中获得的错误

Warning FailedMount 2s (x4 over 6s) kubelet, docker-for-desktop MountVolume.SetUp failed for volume "login-consent-www-resources" : hostPath类型检查失败:C:\Users\myUser\www不是一个目录

www是我的用户主目录中的一个文件夹

$docker run --rm -v c:/Users/myUser:/data alpine ls /data
3D Objects
...
...
...
...
www

我想知道我在这里做错了什么?我正在使用Windows上的docker,它具有自己的集成Kubernetes,并启用了我在docker中的共享文件夹C。

任何帮助?

点赞
用户7016115
用户7016115

所以,在 Docker 容器内,你的 c:/Users/myUser 现在可以作为 /data 使用。因此,你必须使用 /data/www 作为主机路径。

2019-07-06 06:33:06
用户7120031
用户7120031

直到我将 Windows 风格的路径改为 Unix 风格,才使其运作正常,修改后如下:

path: /C/Users/myUser/www
2022-02-26 01:36:59