unable to mount a folder inside container(pod) to host folder in kubernetes .

6,593 views
Skip to first unread message

sandeepn...@gmail.com

unread,
Nov 13, 2017, 8:00:05 AM11/13/17
to Kubernetes user discussion and Q&A
Hi i am trying to mount the volume from container to host and throwing an exception to me .
My
yaml is like this

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: vthree-f3dev-app-pod-volumes
labels:
component: apiserver
provider: kubernetes
spec:
replicas: 1
selector:
template:
metadata:
labels:
component: apiserver
provider: kubernetes
spec:
containers:
- name: f3dev
image: XXXXXXXXXXXXXXXXXX
ports:
- containerPort: 8443
volumeMounts:
- mountPath: /etc/tomcat8/logs
name: test-volume
env:
- name : VTHREE_F3DEV_APP_POD_SERVICE_CONTEXT_ROOT
value : "f3dev"
- name : SOLR_SERVC_CONTEXT_ROOT
value : "solr"
volumes:
- name: test-volume
hostPath:
path: /logs/f3dev-pod-logs

And i am getting error while i am trying to deploy this

The Deployment "vthree-f3dev-app-pod-volumes" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "test-volume"

my kubctl version

kubectl --version
Kubernetes v1.5.2


Please suggest me where i am doing wrong .


Brandon Philips

unread,
Nov 13, 2017, 8:13:42 AM11/13/17
to kubernet...@googlegroups.com
It looks like the volumes section is not indented correctly. It should be indented to the same level as containers as it is part of the PodSpec[1].


Brandon

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.
--
CTO, CoreOS, Inc
Tectonic is enterprise Kubernetes

sandeepn...@gmail.com

unread,
Nov 15, 2017, 4:50:49 AM11/15/17
to Kubernetes user discussion and Q&A
Thanks Brandon,

Now i am able to deploy but facing different issue .If i add volumes in yaml file my entry point script is not picking and pods are not getting up . If i remove the volumes content in yaml file pods are getting up without issue . I am getting confused . can you help with this . Below is the yaml file

apiVersion: extensions/v1beta1
kind: Deployment
metadata:

name: psearch-servc
spec:
replicas: 2
template:
metadata:
labels:
component: powersearch
provider: kubernetes
spec:
containers:
- name: powersearch
image: 172.26.47.239:5000/tomcat:powersearch
ports:
- containerPort: 9000
volumeMounts:
- mountPath: /etc/micro/trunk/
name: power-logs-volume


env:
- name : VTHREE_F3DEV_APP_POD_SERVICE_CONTEXT_ROOT
value : "f3dev"
- name : SOLR_SERVC_CONTEXT_ROOT
value : "solr"
volumes:

- name: power-logs-volume
hostPath:
path: /logs/power-search-logs

[root@VM-K8S-DOCKER-1 centos]# kubectl get pods
NAME READY STATUS RESTARTS AGE
psearch-servc-987683058-qpp30 0/1 CrashLoopBackOff 6 6m
psearch-servc-987683058-qtp0n 0/1 CrashLoopBackOff 6 6m
vthree-f3dev-app-pod-1585762450-kztvm 1/1 Running 0 1h
[root@VM-K8S-DOCKER-1 centos]# kubectl logs psearch-servc-987683058-qtp0n
/bin/bash: ./tomcat.sh: No such file or directory
[root@VM-K8S-DOCKER-1 centos]#

Please let me know if any further details required.Thanks in Advance


Rodrigo Campos

unread,
Nov 15, 2017, 8:58:37 PM11/15/17
to kubernet...@googlegroups.com


On Wednesday, November 15, 2017, <sandeepn...@gmail.com> wrote:
Thanks Brandon,

          Now i am able to deploy but facing different issue .If i add volumes in yaml file my entry point script is not picking and pods are not getting up . If i remove the volumes content in yaml file pods are getting up without issue . I am getting confused . can you help with this . Below  is the yaml file

As the error says, it has nothing to do with volumes but with the CMD or entry point of your docker image. The command it executes prints the error you pasted:
Reply all
Reply to author
Forward
0 new messages