一千萬個為什麽

搜索

如何在Kubernetes中創建命名卷?



在docker-compose中已經創建了幾個命名卷。如何在Kubernetes中創建這些內容?

如何將docker-compose中定義的以下命名卷示例轉換為kubernetes格式

version: "3"
services:
  x:
    image: z
    volumes:
      - a:/path/inside/container
  y:
    image: c
    volumes:
      - a:/path/inside/container
volumes:
  a:

轉載註明原文: 如何在Kubernetes中創建命名卷?

一共有 1 個回答:

k8s have documentation page about volumes and their types https://kubernetes.io/docs/concepts/storage/volumes/

因此,簡而言之,您需要定義 spec.volumesspec.containers []。volumeMounts ,如:

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: gcr.io/google_containers/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir: {}