Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes docker volume mounting option

I have a docker image with the option for property file like,

CMD java -jar /opt/test/test-service.war 
--spring.config.location=file:/conf/application.properties

I use the -v volume mount in my docker run command as follows.

-v /usr/xyz/props/application.properties:/conf/application.properties

I am not sure how to achieve the same thing in Kubernetes.
I use minikube to run kubernetes in my local mac.

like image 814
user1578872 Avatar asked Mar 16 '18 05:03

user1578872


1 Answers

That should be an host path volume, illustrated with this example pod.

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
  volumes:
  - name: test-volume
    hostPath:
      # directory location on host
      path: /data
      # this field is optional
      type: Directory
like image 84
VonC Avatar answered Oct 19 '22 13:10

VonC