snippetkubernetesMinor
How to create named volumes in Kubernetes?
Viewed 0 times
volumescreatekubernetesnamedhow
Problem
Several named volumes have been created in docker-compose. How to create these in Kubernetes?
How to transform the following
How to transform the following
named volume example defined in docker-compose to kubernetes formatversion: "3"
services:
x:
image: z
volumes:
- a:/path/inside/container
y:
image: c
volumes:
- a:/path/inside/container
volumes:
a:Solution
k8s have documentation page about volumes and their types https://kubernetes.io/docs/concepts/storage/volumes/
So in short you need to define
So in short you need to define
spec.volumes and spec.containers[].volumeMounts like: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: {}Code Snippets
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: {}Context
StackExchange DevOps Q#1812, answer score: 5
Revisions (0)
No revisions yet.