Istio Mixer容器日志导致大量磁盘空间使用

时间:2018-12-11 14:05:00

标签: kubernetes istio

我有一个启用了Istio的EKS群集,并且我的节点不断地用尽磁盘空间。

计算总体磁盘使用率使我进入istio-mixer容器,该容器具有日志文件,仅在 12天内使用了超过 50GB 的磁盘空间的正常运行时间:

[root@ip-some-ip containers]# pwd
/var/lib/docker/containers

[root@ip-some-ip containers]# du -schx .[!.]* * | sort -h | tail -n 10
66M 8bf5e8ee5a03096c589ad8f53b9e1a3d3088ca67b0064f3796e406f00336b532
73M 657eca261461d10c5b1b81ab3078d2058b931a357395903808b0145b617c1662
101M    bb338296ff06ef42ae6177c8a88e63438c26c398a457dc3f5301ffcb4ef2682b
127M    21f2da86055ad76882730abf65d4465386bb85598f797f451e7ad66726243613
134M    9c2be24e8b9345659b6f208c9f2d4650bb1ece11e0c4b0793aa01fdfebadb44e
383M    5d5fdbe6813ddc3ff2f6eb96f62f8317bd73e24730e2f44ebc537367d9987142
419M    475f8dfc74c3df2bc95c47df56e37d1dfb9181fae9aa783dafabba8283023115
592M    9193c50e586e0c7ecaeb87cecd8be13714a5d6ccd6ea63557c034ef56b07772f
52G 9c6b3e4f26603471d0aa9b6a61b3da5a69001e6b9be34432ffa62d577738c149
54G total

[root@ip-192-168-228-194 containers]# du -hs 9c6b3e4*/*.log
52G 9c6b3e4f26603471d0aa9b6a61b3da5a69001e6b9be34432ffa62d577738c149-json.log

[root@ip-ip-some-ip containers]# docker ps -a | grep 9c6b3e4f2660
9c6b3e4f2660        d559bdcd7a88                                                       "/usr/local/bin/mi..."   12 days ago         Up 12 days                                     k8s_mixer_istio-telemetry-6b5579595f-fvm5x_istio-system_6324c262-f3b5-11e8-b615-0eccb0bb4724_0

我的问题是:

  • 预计会有这么多的日志输出吗?
  • 混合器日志级别可以降低吗?怎么样?更改它会影响我的遥测指标吗?
  • 有没有一种配置日志“保留期”的方法?

其他信息:

  • Istio v1.0.2(已部署正式头盔图;没有自定义配置)
  • k8s v1.10.11-eks
  • 该集群大约有20个Pod在启用Istio的名称空间中运行

2 个答案:

答案 0 :(得分:2)

混合器中的日志记录级别的默认值为info。您提供的日志将确认您具有此设置。因此,大量冗余信息收集在日志中,并且有可能降低某些来源的日志记录级别。

您可以通过两种方式对其进行更改:

  1. 在工作窗格上,无需重启。

    在日志中,您可以找到以下行:

    2018-12-12T17:54:55.461261Z info    ControlZ available at 192.168.87.249:9876
    

    这意味着,在9876端口的调音台容器中,您可以找到Istio ControlZ Web界面。要从安装了kubectl的计算机上对其进行访问,您需要运行以下命令:

    kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l istio=mixer,istio-mixer-type=telemetry -o jsonpath='{.items[0].metadata.name}') 9876:9876 &
    

    然后,在浏览器中转到链接http://localhost:9876/scopez/,您将看到以下仪表板,您可以在其中更改日志级别:

    enter image description here

  2. --log_output_level容器的istio-telemetry部署添加mixer标志。

    这是调音台文档中有关该标志的说明:

      

    -log_output_level字符串
      以逗号分隔的输出的最低每作用域日志级别,形式为:,:,...,其中scope可以是[adapters,api,attributes,default,grpcAdapter,loadshedding]之一,而level可以是以下之一[调试,信息,警告,错误,无](默认为“默认:信息”)

    请注意,对于yaml文件中的密钥--log_output_level attributes:warn,api:error,您需要使用以下之一:

    • - --log_output_level=attributes:warn,api:error
    • 在不同行上的值- --log_output_level- attributes:warn,api:error

    部署示例:

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      annotations:
      labels:
        chart: mixer-1.0.4
        istio: mixer
        release: istio
      name: istio-telemetry
      namespace: istio-system
    spec:
      progressDeadlineSeconds: 600
      replicas: 2
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: telemetry
          istio: mixer
          istio-mixer-type: telemetry
      strategy:
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 1
        type: RollingUpdate
      template:
        metadata:
          annotations:
            scheduler.alpha.kubernetes.io/critical-pod: ""
            sidecar.istio.io/inject: "false"
          creationTimestamp: null
          labels:
            app: telemetry
            istio: mixer
            istio-mixer-type: telemetry
        spec:
          containers:
          - args:                                                #Flags for the Mixer process
            - --address                                          #Flag on two different lines
            - unix:///sock/mixer.socket
            - --configStoreURL=k8s://                            #Flag with '='
            - --configDefaultNamespace=istio-system
            - --trace_zipkin_url=http://zipkin:9411/api/v1/spans
            - --log_output_level=attributes:warn,api:error       # <------ THIS LINE IS WHAT YOU ARE LOOKING FOR
            env:
            - name: GODEBUG
              value: gctrace=2
            image: docker.io/istio/mixer:1.0.4
            imagePullPolicy: IfNotPresent
            livenessProbe:
              failureThreshold: 3
              httpGet:
                path: /version
                port: 9093
                scheme: HTTP
              initialDelaySeconds: 5
              periodSeconds: 5
              successThreshold: 1
              timeoutSeconds: 1
            name: mixer
            ports:
            - containerPort: 9093
              protocol: TCP
            - containerPort: 42422
              protocol: TCP
            resources:
              requests:
                cpu: 10m
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
            volumeMounts:
            - mountPath: /sock
              name: uds-socket
          - args:
            - proxy
            - --serviceCluster
            - istio-telemetry
            - --templateFile
            - /etc/istio/proxy/envoy_telemetry.yaml.tmpl
            - --controlPlaneAuthPolicy
            - MUTUAL_TLS
            env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - name: INSTANCE_IP
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: status.podIP
            image: docker.io/istio/proxyv2:1.0.4
            imagePullPolicy: IfNotPresent
            name: istio-proxy
            ports:
            - containerPort: 15090
              name: http-envoy-prom
              protocol: TCP
            resources:
              requests:
                cpu: 10m
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
            volumeMounts:
            - mountPath: /etc/certs
              name: istio-certs
              readOnly: true
            - mountPath: /sock
              name: uds-socket
          dnsPolicy: ClusterFirst
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          serviceAccount: istio-mixer-service-account
          serviceAccountName: istio-mixer-service-account
          terminationGracePeriodSeconds: 30
          volumes:
          - name: istio-certs
            secret:
              defaultMode: 420
              optional: true
              secretName: istio.istio-mixer-service-account
          - emptyDir: {}
            name: uds-socket
    

此外,您还可以使用以下标志为混合器过程配置日志轮换:

  

-log_rotate字符串可选旋转日志文件的路径

     

-log_rotate_max_age int日志文件的最长有效期限,以天为单位,超过该期限,文件将被旋转(0表示没有限制)(默认值为30)

     

-log_rotate_max_backups int删除较旧文件之前要保留的日志文件备份的最大数量(0表示没有限制)(默认为1000)

     

-log_rotate_max_size int日志文件的最大大小(以MB为单位)(超出该大小,默认值为104857600)

但是,我无法生成大量此类日志并测试其工作方式。

链接:

不幸的是,official documentation不好,但是也许可以有所帮助。

另外,here是所有混合器服务器标志的列表。

答案 1 :(得分:1)

这是我解决问题的方式以及有关Istio新版本的一些有用信息。

Istio v1.0.2:

Stdio adapter正在生成大量日志:

  

stdio适配器使Istio可以将日志和指标输出到   本地机器。日志和指标可以直接遵循Mixer的标准   输出流,标准错误流或任何本地可达的流   文件。

在Istio v1.0.2中,默认情况下启用了此适配器,将日志流式传输到Mixer容器stderr。为了暂时解决此问题,我deleted the following rules

kubectl delete rule stdio --namespace=istio-system
kubectl delete rule stdio-tcp --namespace=istio-system

删除这些规则不会影响Prometheus指标(由another adapter处理)。

Istio v1.1.0 +:

在此版本中,Istio将mixer.adapters.stdio.enabled引入了helm installation options默认情况下禁用了stdio适配器,并包括了following comment

  

#stdio是组织遥测中的调试适配器,不建议使用   用于生产。

在以下PR中进行了更改: