我是容器和kubernetes的新手。 我想做的是创建一个可以访问本地目录的Pod。
我遵循了以下指示: configure persistent volume storage
创建了我的“ Persistent Volume”,“ Persistent Volume Claim”和我的pod。
问题是tomcat无法在共享目录上写
这是持久卷:
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"
这是永久数量声明:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
这是我要创建的tomcat Pod:
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
这有点明显,但这是豆荚上的错误。
[root @ testserver webapp6-test]#kubectl exec -it webapp6-/ bin / bash
root @ webapp6:/ usr / local / tomcat#mkdir / usr / local / tomcat / webapps / sample
mkdir:无法创建目录“ / usr / local / tomcat / webapps / sample”:权限被拒绝
答案 0 :(得分:1)
问题出在您的PVC yaml文件中,您没有指定org.neo4j.driver.v1.exceptions.ServiceUnavailableException: Connection to the database terminated. This can happen due to network instabilities, or due to restarts of the database
at org.neo4j.driver.internal.util.ErrorUtil.newConnectionTerminatedError(ErrorUtil.java:45) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.util.ErrorUtil.newConnectionTerminatedError(ErrorUtil.java:38) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.async.inbound.ChannelErrorHandler.channelInactive(ChannelErrorHandler.java:76) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1010) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1409) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:927) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[neo4j-java-driver-1.6.3.jar:1.6.3-b33d284ef6f350edbfe9e8f4539cdcdb0200bd0b]
at java.lang.Thread.run(Thread.java:844) [?:?]
。因此,PV和PVC无法相互绑定。请用以下文件替换PVC yaml文件:
storageClassName
现在一切正常。希望这会有所帮助。
我很快就用您的Yaml部署了pod,最后一切正常:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-webapp6
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
现在,当我查看主机时,可以看到新创建的[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
文件
a
因此,至少yaml文件可以正常工作。