K8S 日志收集(二):生产日志

修改docker启动的log参数

修改文件/etc/sysconfig/docker

--log-driver=json-file

创建一个deployment

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: busybox-log-dm
spec:
  replicas: 3
  strategy:
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLables:
      name: busybox-log-dm
  template:
    metadata:
      labels:
        name: busybox-log-dm
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: busybox-log
        image: 192.168.19.111/baseimages/busybox:latest
        imagePullPolicy: Always
        args:
        - /bin/sh
        - -c
        - >
          while true:
          do
            sleep 2;
            date -R;
            hostname;
          done
        volumeMounts:
        - name: tz-config
          mountPath: /etc/localtime
      volumes:
        - name: tz-config
          hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai
              

https://docs.docker.com/config/containers/logging/configure/

posted @ 2018-04-28 11:05  长风七万里  阅读(218)  评论(0编辑  收藏  举报