首页 > 解决方案 > 如何在kubernetes的volume中映射当前目录?

问题描述

我需要将当前目录映射到 Windows 上的 Kubernetes 卷。

我可以使用 hostPath 来做到这一点,但我无法在我的部署中获取当前目录。

通常我们使用 ./ 来传递当前目录但 kubernetes 无法识别它。

如何在 windows kubernetes 中使用相应的 ./?

这是我尝试做的方式:

apiVersion: apps/v1
kind: Deployment
metadata:
name: testeleitor
labels:
    app: leitoreventos
spec:
selector:
    matchLabels:
    app: leitoreventos
    tier: backend
replicas: 1
template:
    metadata:
    labels: 
        app: leitoreventos
        tier: backend
    spec:
    restartPolicy: Always
    containers:
    - image: leitordeeventos:v1.6.1
        name: leitor
        ports:
        - containerPort: 5555 
        volumeMounts:
        - mountPath: /home/binarios/test/
          name: test-volume
    volumes:
    - name: test-volume
      hostPath:
        path: ./test/
        type: Directory

标签: kubernetes

解决方案


推荐阅读