Pod存储卷
Pod Volume
同一个Pod中的多个容器可以共享Pod级别的存储卷Volume,Volume可以定义为各种类型,多个容器各自进行挂载,将Pod的Volume挂载为容器内部需要的目录。
例如:Pod级别的Volume:"app-logs",用于tomcat向其中写日志文件,busybox读日志文件。
pod-volumes-applogs.yaml
apiVersion: v1
kind: Pod
metadata:
name: volume-pod
spec:
containers:
- name: tomcat
image: tomcat
ports:
- containerPort: 8080
volumeMounts:
- name: app-logs
mountPath: /usr/local/tomcat/logs
- name: busybox
image: busybox
command: ["sh","-c","tailf /logs/catalina*.log"]
volumeMounts:
- name: app-logs
mountPath: /logs
volumes:
- name: app-logs
emptuDir: {}
查看日志
- kubectl logs
<pod_name>
-c<container_name>
- kubectl exec -it
<pod_name>
-c<container_name>
– tail /usr/local/tomcat/logs/catalina.xx.log
参考文章
- 《Kubernetes权威指南》
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
最后修改 December 25, 2022: deploy by blog source (a162b04)