apiVersion: apps/v1
kind: Deployment
metadata:
  #命名规范:应用名称-版本
  name: maxwell-id01
  namespace: default
  annotations:
    #Reloader can watch changes in ConfigMap and Secret and do rolling upgrades
    configmap.reloader.stakater.com/reload: "foo-configmap,bar-configmap,baz-configmap"
  labels:
    app: maxwell-id01
spec:
  #保留历史版本数量
  revisionHistoryLimit: 3
  replicas: 1
  selector:
    matchLabels:
      #istio标签
      app: maxwell-id01
      version: v1
  #minReadySeconds: 60     #滚动升级时60s后认为该pod就绪
  strategy:
    rollingUpdate:  #由于replicas为3,则整个升级,pod个数在2-4个之间
      maxSurge: 1      #滚动升级时会先启动1个pod
      maxUnavailable: 1 #滚动升级时允许的最大Unavailable的pod个数
  template:
    metadata:
      labels:
        app: maxwell-id01
        version: v1
    spec:
      #nodeName: k8s.node1 #指定调度节点为k8s.node1
      #nodeName: virtual-kubelet
      #调度特定的节点,用于集群弹性伸缩
      #nodeSelector:
      #  kubernetes.io/role: agent
      #  beta.kubernetes.io/os: linux
      #  type: virtual-kubelet
      #tolerations:
      #- key: virtual-kubelet.io/provider
      #  operator: Exists
      #- key: alibabacloud.com/eci
      #  operator: "Exists"
      #  effect: NoSchedule
      terminationGracePeriodSeconds: 60 #k8s将会给应用发送SIGTERM信号，可以用来正确、优雅地关闭应用,默认为30秒
      #imagePullSecrets:
      #- name: registrykey-ali-ext
      #priorityClassName: high-priority # 这里指定高优先的 PriorityClass
      containers:
      - name: maxwell
        image: zendesk/maxwell
        #workingDir: /yourworkdir
        #command:
        #- /cmd
        #- --cpu=100m
        #- --extra-cpu=2m
        #- --memory=150Mi
        #- --extra-memory=30Mi
        #args:
        #- -conf
        #- /etc/app.conf
        imagePullPolicy: Always
        resources:
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 4
            memory: 8Gi
        securityContext:
          #allowPrivilegeEscalation: false
          capabilities: {}
          privileged: false
          #runAsUser: 1000
          #fsGroup: 1000
        env:
          - name: LOG_LEVEL
            value: "debug"
          - name: MYSQL_HOST
            value: "mysql_server"
          - name: PORT
            value: "3306"
          - name: MYSQL_USERNAME
            value: "mysql"
          - name: MYSQL_PASSWORD
            value: "mysql_password"
          - name: SCHEMA_DATABASE
            value: "maxwell"
          - name: CLIENT_ID
            value: "maxwell"
          - name: JDBC_OPTIONS
            value: "autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&connectTimeout=10000"
          - name: SSL
            value: "DISABLED"
          - name: MAXWELL_PRODUCER
            value: "stdout"
          - name: KAFKA_BROKERS
            value: "localhost:9092"
          - name: KAFKA_VERSION
            value: "1.0.0"
          - name: PRODUCER_PARTITION_BY
            value: "database"
          - name: KAFKA_TOPIC
            value: "maxwell_topic"
          - name: KAFKA.ACKS
            value: "1"
          - name: KAFKA.COMPRESSION.TYPE
            value: "snappy"
          - name: KAFKA.RETRIES
            value: "10"
          - name: DDL_KAFKA_TOPIC 
            value: "maxwell_ddl_topic"
          - name: OUTPUT_DDL
            value: "false"
          - name: OUTPUT_NULL_ZERODATES
            value: "false"
          #- name: FILTER
          #  value: "exclude: db.*, include: *.tbl, include: *./bar(bar)?/, exclude: foo.bar.col=val"
          - name: BUFFER_MEMORY_USAGE
            value: "0.25"
          #log collector with aliyun log-pilot
          #- name: aliyun_logs_catalina
          #  value: "stdout"
          #- name: aliyun_logs_access
          #  value: "/usr/local/tomcat/logs/localhost_access_log.*.txt"
        ports:
        #监控端口
        - containerPort: 8080
          name: metrics
          protocol: TCP
