多容器共享volume

目标: pod中 包含两个容器: tomcat和busybox, 设置volume:app-logs, 用于tomcat向其中写日志, busybox读日志文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox-deployment
  namespace: default 
  labels:
    app: busybox
spec:
  selector:
    matchLabels:
      app: busybox
  replicas: 1
  template:
    metadata:
      labels:
        app: busybox
    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", "tail -f /logs/catalina*.log"]
        volumeMounts:
        - name: app-logs
          mountPath: /logs
      volumes:
      - name: app-logs
        emptyDir: {}
kubectl logs -f busybox-deployment-7fd499c769-zb4q9  -c busybox

posted @ 2019-08-03 15:11  你很棒  阅读(619)  评论(0编辑  收藏  举报