Pod not writing on a local path
I'm new with containers and kubernetes.
What I'm trying to do is to create a pod with access to a local directory.
I have followed the directions from:
configure persistent volume storage
Created my Persistent Volume, Persistent Volume Claim and my pod.
The problem is that the tomcat is not able to write on the shared directory
This is the Persistent Volume:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-webapp6
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/opt/test_tomcat/app"
This is the Persistent Volume Claim:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
This is the tomcat Pod I'm trying to create:
apiVersion: v1
kind: Pod
metadata:
name: webapp6
spec:
containers:
- image: tomcat:8.0
name: webapp6
ports:
- containerPort: 8080
name: webapp6
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: test-volume
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: pvc-webapp6
Its a bit obvious, but this the error on the pod.
[root@testserver webapp6-test]# kubectl exec -it webapp6 -- /bin/bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
mkdir: cannot create directory ‘/usr/local/tomcat/webapps/sample’: Permission denied
kubernetes docker-volume persistent-storage
add a comment |
I'm new with containers and kubernetes.
What I'm trying to do is to create a pod with access to a local directory.
I have followed the directions from:
configure persistent volume storage
Created my Persistent Volume, Persistent Volume Claim and my pod.
The problem is that the tomcat is not able to write on the shared directory
This is the Persistent Volume:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-webapp6
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/opt/test_tomcat/app"
This is the Persistent Volume Claim:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
This is the tomcat Pod I'm trying to create:
apiVersion: v1
kind: Pod
metadata:
name: webapp6
spec:
containers:
- image: tomcat:8.0
name: webapp6
ports:
- containerPort: 8080
name: webapp6
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: test-volume
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: pvc-webapp6
Its a bit obvious, but this the error on the pod.
[root@testserver webapp6-test]# kubectl exec -it webapp6 -- /bin/bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
mkdir: cannot create directory ‘/usr/local/tomcat/webapps/sample’: Permission denied
kubernetes docker-volume persistent-storage
add a comment |
I'm new with containers and kubernetes.
What I'm trying to do is to create a pod with access to a local directory.
I have followed the directions from:
configure persistent volume storage
Created my Persistent Volume, Persistent Volume Claim and my pod.
The problem is that the tomcat is not able to write on the shared directory
This is the Persistent Volume:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-webapp6
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/opt/test_tomcat/app"
This is the Persistent Volume Claim:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
This is the tomcat Pod I'm trying to create:
apiVersion: v1
kind: Pod
metadata:
name: webapp6
spec:
containers:
- image: tomcat:8.0
name: webapp6
ports:
- containerPort: 8080
name: webapp6
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: test-volume
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: pvc-webapp6
Its a bit obvious, but this the error on the pod.
[root@testserver webapp6-test]# kubectl exec -it webapp6 -- /bin/bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
mkdir: cannot create directory ‘/usr/local/tomcat/webapps/sample’: Permission denied
kubernetes docker-volume persistent-storage
I'm new with containers and kubernetes.
What I'm trying to do is to create a pod with access to a local directory.
I have followed the directions from:
configure persistent volume storage
Created my Persistent Volume, Persistent Volume Claim and my pod.
The problem is that the tomcat is not able to write on the shared directory
This is the Persistent Volume:
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-webapp6
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/opt/test_tomcat/app"
This is the Persistent Volume Claim:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
This is the tomcat Pod I'm trying to create:
apiVersion: v1
kind: Pod
metadata:
name: webapp6
spec:
containers:
- image: tomcat:8.0
name: webapp6
ports:
- containerPort: 8080
name: webapp6
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: test-volume
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: pvc-webapp6
Its a bit obvious, but this the error on the pod.
[root@testserver webapp6-test]# kubectl exec -it webapp6 -- /bin/bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
mkdir: cannot create directory ‘/usr/local/tomcat/webapps/sample’: Permission denied
kubernetes docker-volume persistent-storage
kubernetes docker-volume persistent-storage
edited Nov 20 '18 at 15:27
radicaled
asked Nov 20 '18 at 14:37
radicaledradicaled
3931322
3931322
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The issue is in your PVC yaml file where you're not specifying the storageClassName
. Hence the PV and PVC couldn't bound to each other. Please replace the PVC yaml file with the following file:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Now everything should work. Hope this helps.
I quickly used your yaml to deploy pod and everything is working fine at my end:
[root@Master admin]# kubectl exec -it webapp6 bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
root@webapp6:/usr/local/tomcat# touch /usr/local/tomcat/webapps/sample/a
root@webapp6:/usr/local/tomcat# ls /usr/local/tomcat/webapps/sample/
a
Now when I look at host, I can see the newly created a
file
[root@Master admin]# ls /opt/test_tomcat/app/sample/
a
So, at least yaml files are working fine.
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395396%2fpod-not-writing-on-a-local-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue is in your PVC yaml file where you're not specifying the storageClassName
. Hence the PV and PVC couldn't bound to each other. Please replace the PVC yaml file with the following file:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Now everything should work. Hope this helps.
I quickly used your yaml to deploy pod and everything is working fine at my end:
[root@Master admin]# kubectl exec -it webapp6 bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
root@webapp6:/usr/local/tomcat# touch /usr/local/tomcat/webapps/sample/a
root@webapp6:/usr/local/tomcat# ls /usr/local/tomcat/webapps/sample/
a
Now when I look at host, I can see the newly created a
file
[root@Master admin]# ls /opt/test_tomcat/app/sample/
a
So, at least yaml files are working fine.
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
|
show 1 more comment
The issue is in your PVC yaml file where you're not specifying the storageClassName
. Hence the PV and PVC couldn't bound to each other. Please replace the PVC yaml file with the following file:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Now everything should work. Hope this helps.
I quickly used your yaml to deploy pod and everything is working fine at my end:
[root@Master admin]# kubectl exec -it webapp6 bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
root@webapp6:/usr/local/tomcat# touch /usr/local/tomcat/webapps/sample/a
root@webapp6:/usr/local/tomcat# ls /usr/local/tomcat/webapps/sample/
a
Now when I look at host, I can see the newly created a
file
[root@Master admin]# ls /opt/test_tomcat/app/sample/
a
So, at least yaml files are working fine.
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
|
show 1 more comment
The issue is in your PVC yaml file where you're not specifying the storageClassName
. Hence the PV and PVC couldn't bound to each other. Please replace the PVC yaml file with the following file:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Now everything should work. Hope this helps.
I quickly used your yaml to deploy pod and everything is working fine at my end:
[root@Master admin]# kubectl exec -it webapp6 bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
root@webapp6:/usr/local/tomcat# touch /usr/local/tomcat/webapps/sample/a
root@webapp6:/usr/local/tomcat# ls /usr/local/tomcat/webapps/sample/
a
Now when I look at host, I can see the newly created a
file
[root@Master admin]# ls /opt/test_tomcat/app/sample/
a
So, at least yaml files are working fine.
The issue is in your PVC yaml file where you're not specifying the storageClassName
. Hence the PV and PVC couldn't bound to each other. Please replace the PVC yaml file with the following file:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Now everything should work. Hope this helps.
I quickly used your yaml to deploy pod and everything is working fine at my end:
[root@Master admin]# kubectl exec -it webapp6 bash
root@webapp6:/usr/local/tomcat# mkdir /usr/local/tomcat/webapps/sample
root@webapp6:/usr/local/tomcat# touch /usr/local/tomcat/webapps/sample/a
root@webapp6:/usr/local/tomcat# ls /usr/local/tomcat/webapps/sample/
a
Now when I look at host, I can see the newly created a
file
[root@Master admin]# ls /opt/test_tomcat/app/sample/
a
So, at least yaml files are working fine.
edited Nov 20 '18 at 15:43
answered Nov 20 '18 at 15:03
Prafull LadhaPrafull Ladha
3,308320
3,308320
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
|
show 1 more comment
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Actually, I was using the storageClassName: manual. I put the wrong PVC yaml on the question. I have updated it now.
– radicaled
Nov 20 '18 at 15:19
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
Could you please elaborate further. Because I am able to write inside the pod at /usr/local/tomcat/webapps and those files are reflected at /opt/test_tomcat/app..
– Prafull Ladha
Nov 20 '18 at 15:23
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
When tomcat deploys the sample.war that is inside /opt/test_tomcat/app, it needs to create the sample directory with the application deploy. Its to able to deploy/create the sample directory.
– radicaled
Nov 20 '18 at 15:28
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
Its Not able to create/deploy the sample application inside the /opt/test_tomcat/app directory. Sorry, I'm not able to edit my previous comment :S
– radicaled
Nov 20 '18 at 15:39
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
I have edited my ans. Yamls are working fine. I will again have a look about what is wrong there
– Prafull Ladha
Nov 20 '18 at 15:44
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395396%2fpod-not-writing-on-a-local-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown