Windows节点上使用logtail-阿里云开发者社区

开发者社区> 阿里云容器服务 ACK> 正文
登录阅读全文

Windows节点上使用logtail

简介: 环境要求 创建Linux托管集群,添加OS为Windows的节点池来使用Windows节点 集群已经部署了日志组件 添加Windows节点的logtail 在kube-system下的configmap alibaba-log-configuration中添加item win-log-conf.

环境要求

  • 创建Linux托管集群,添加OS为Windows的节点池来使用Windows节点
  • 集群已经部署了日志组件

添加Windows节点的logtail

  • 在kube-system下的configmap alibaba-log-configuration中添加item
## 根据集群所在的region,写入对应的值
win-log-config-path: C:\Program Files (x86)\Alibaba\Logtail\conf\{your region}\ilogtail_config.json
  • 部署Windows节点的daemonset
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  labels:
    k8s-app: win-logtail-ds
  name: win-logtail-ds
  namespace: kube-system
spec:
  selector:
    matchLabels:
      k8s-app: logtail-ds
      kubernetes.io/cluster-service: "true"
      version: v1.0
  template:
    metadata:
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ""
      labels:
        k8s-app: logtail-ds
        kubernetes.io/cluster-service: "true"
        version: v1.0
    spec:
      containers:
      - env:
        - name: ALIYUN_LOGTAIL_CONFIG
          valueFrom:
            configMapKeyRef:
              key: win-log-config-path
              name: alibaba-log-configuration
        - name: ALIYUN_LOGTAIL_USER_ID
          valueFrom:
            configMapKeyRef:
              key: log-ali-uid
              name: alibaba-log-configuration
        - name: ALIYUN_LOGTAIL_USER_DEFINED_ID
          valueFrom:
            configMapKeyRef:
              key: log-machine-group
              name: alibaba-log-configuration
        - name: ALICLOUD_LOG_DOCKER_ENV_CONFIG
          value: "true"
        - name: ALICLOUD_LOG_ECS_FLAG
          value: "true"
        - name: ALICLOUD_LOG_DEFAULT_PROJECT
          valueFrom:
            configMapKeyRef:
              key: log-project
              name: alibaba-log-configuration
        - name: ALICLOUD_LOG_ENDPOINT
          valueFrom:
            configMapKeyRef:
              key: log-endpoint
              name: alibaba-log-configuration
        - name: ALICLOUD_LOG_DEFAULT_MACHINE_GROUP
          valueFrom:
            configMapKeyRef:
              key: log-machine-group
              name: alibaba-log-configuration
        - name: ALIYUN_LOG_ENV_TAGS
          value: _node_name_|_node_ip_
        - name: _node_name_
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: spec.nodeName
        - name: _node_ip_
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: status.hostIP
        - name: cpu_usage_limit
          value: "1.0"
        - name: mem_usage_limit
          value: "512"
        - name: max_bytes_per_sec
          value: "20971520"
        - name: send_request_concurrency
          value: "20"
        image: registry.cn-hangzhou.aliyuncs.com/log-service/winlogtail:ltsc2019-1.0.0.10
        imagePullPolicy: IfNotPresent
        name: logtail
        resources:
          limits:
            memory: 512Mi
          requests:
            cpu: 100m
            memory: 256Mi
        securityContext:
          privileged: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: '\\\\.\pipe\docker_engine'
          name: sock
        - mountPath: 'c:\ProgramData\docker'
          name: root
          readOnly: true
        - mountPath: 'c:\logtail_host'
          name: root-c
          readOnly: true
      nodeSelector:
        beta.kubernetes.io/os: windows
      terminationGracePeriodSeconds: 30
      tolerations:
      - effect: NoSchedule
        key: os
        operator: Equal
        value: windows
      volumes:
      - hostPath:
          path: '\\\\.\pipe\docker_engine'
        name: sock
      - hostPath:
          path: 'c:\ProgramData\docker'
        name: root
      - hostPath:
          path: 'c:\'
        name: root-c

目前logtail仅限于支持采集stdout的输出至日志服务,后续会支持对日志文件的采集

部署完成后可以使用如下应用去验证是否可用:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: logtail-test
  name: logtail-test
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: logtail-test
      name: logtail-test
    spec:
      containers:
      - name: nanoserver
        image: mcr.microsoft.com/windows/servercore:1809
        command: ["powershell.exe"]
        args: ["ping -t 127.0.0.1 -w 10000"]
        env:
      ######### 配置 环境变量 ###########
        - name: aliyun_logs_logtail-stdout
          value: stdout
        - name: aliyun_logs_logttail-tags
          value: tag1=v1
      #################################
      nodeSelector:
        beta.kubernetes.io/os: windows
      tolerations:
      - effect: NoSchedule
        key: os
        operator: Equal
        value: windows

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
阿里云容器服务 ACK
使用钉钉扫一扫加入圈子
+ 订阅

云端最佳容器应用运行环境,安全、稳定、极致弹性

官方博客
官网链接