account-db-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: account-db
  namespace: default
spec:
  type: ExternalName
  externalName: rm-8vb0228mnrm0482hk.mysql.zhangbei.rds.aliyuncs.com

account-service-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    aliyun.log_store_errorLog: /var/log/common/common_error.log
    aliyun.log_store_monitorLog: /var/log/monitor/monitor_digest.log
    aliyun.log_store_requestlog: stdout
    aliyun.scale: "1"
    kompose.cmd: kompose convert -f source/swarm-piggymetrics.yaml --volumes PersistentVolumeClaimOrHostPath
    kompose.version: 1.17.0 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: account-service
  name: account-service
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: account-service
    spec:
      containers:
      - env:
        - name: ACCOUNT_SERVICE_PASSWORD
          value: accountPwd
        - name: CLUSTER_NAME
          value: K8SCluster
        - name: CONFIG_SERVICE_PASSWORD
          value: configPwd
        - name: MONGODB_PASSWORD
          value: mongodbPwd
        - name: RDS_PASSWORD
          value: hello@1235
        - name: RDS_URL
          value: rm-8vb0228mnrm0482hk.mysql.zhangbei.rds.aliyuncs.com
        - name: affinity
          value: service!=account-mongodb
        - name: aliyun_logs_errorlog
          value: /var/log/common/common_error.log
        - name: aliyun_logs_monitorlog
          value: /var/log/monitor/monitor_digest.log
        - name: aliyun_logs_requestlog
          value: stdout
        image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/account-service
        name: account-service
        resources: {}
        volumeMounts:
        - mountPath: /var/log/common
          name: volumn-sls-errorlog
        - mountPath: /var/log/monitor
          name: volumn-sls-monitorlog
      restartPolicy: Always
      volumes:
      - emptyDir: {}
        name: volumn-sls-errorlog
      - emptyDir: {}
        name: volumn-sls-monitorlog
status: {}

auth-mongodb-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    aliyun.probe.url: tcp://container:27017
    kompose.cmd: kompose convert -f source/swarm-piggymetrics.yaml --volumes PersistentVolumeClaimOrHostPath
    kompose.version: 1.17.0 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: auth-mongodb
  name: auth-mongodb
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: auth-mongodb
    spec:
      nodeSelector:
        group: db
      containers:
      - command:
        - /init.sh
        env:
        - name: MONGODB_PASSWORD
          value: mongodbPwd
        - name: constraint
          value: group==db
        image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/mongodb
        livenessProbe:
          tcpSocket:
            port: 27017
        name: auth-mongodb
        resources: {}
      restartPolicy: Always
status: {}
			

auth-service-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    aliyun.latest_image: "true"
    aliyun.log_store_requestlog: stdout
    aliyun.routing.port_5000: auth-service.local
    aliyun.scale: "1"
    kompose.cmd: kompose convert -f source/swarm-piggymetrics.yaml --volumes PersistentVolumeClaimOrHostPath
    kompose.version: 1.17.0 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: auth-service
  name: auth-service
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: auth-service
    spec:
      containers:
      - args:
        - java
        - -Xmx500m
        - -jar
        - /app/auth-service.jar
        command:
        - java
        - -Xmx200m
        - -jar
        - /app/auth-service.jar
        env:
        - name: ACCOUNT_SERVICE_PASSWORD
          value: accountPwd
        - name: CLUSTER_NAME
          value: K8SCluster
        - name: CONFIG_SERVICE_PASSWORD
          value: configPwd
        - name: MONGODB_PASSWORD
          value: mongodbPwd
        - name: NOTIFICATION_SERVICE_PASSWORD
          value: notificationPwd
        - name: STATISTICS_SERVICE_PASSWORD
          value: statisticsPwd
        - name: aliyun_logs_requestlog
          value: stdout
        image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/auth-service:latest
        name: auth-service
        ports:
        - containerPort: 5000
        resources: {}
        securityContext:
          capabilities:
            add:
            - all
            drop:
            - SETGID
            - SETUID
          privileged: true
        volumeMounts:
        - mountPath: /data/oss
          name: volume-name-piggymetrics
        - mountPath: /data/nas
          name: vn-nas-piggymetrics
        - mountPath: /data/yunpan
          name: vn-yunpan-piggymetrics
        - mountPath: /var/run/docker.sock
          name: auth-service-claim3
        - mountPath: /data/tmp
          name: auth-service-claim4
      restartPolicy: Always
      volumes:
      - name: volume-name-piggymetrics
        persistentVolumeClaim:
          claimName: volume-name-piggymetrics
      - name: vn-nas-piggymetrics
        persistentVolumeClaim:
          claimName: vn-nas-piggymetrics
      - name: vn-yunpan-piggymetrics
        persistentVolumeClaim:
          claimName: vn-yunpan-piggymetrics
      - hostPath:
          path: /var/run/docker.sock
        name: auth-service-claim3
      - hostPath:
          path: /tmp
        name: auth-service-claim4
status: {}

config-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    aliyun.auto_scaling.max_cpu: "70"
    aliyun.auto_scaling.max_instances: "10"
    aliyun.auto_scaling.min_cpu: "30"
    aliyun.auto_scaling.min_instances: "1"
    aliyun.auto_scaling.step: "1"
    aliyun.latest_image: "false"
    aliyun.probe.cmd: curl -u user:configPwd http://127.0.0.1:8888/account-service/spring.data.mongodb.host
    aliyun.probe.initial_delay_seconds: "30"
    aliyun.probe.timeout_seconds: "30"
    aliyun.rolling_updates: "true"
    aliyun.rolling_updates.parallelism: "2"
    aliyun.scale: "3"
    kompose.cmd: kompose convert -f source/swarm-piggymetrics.yaml --volumes PersistentVolumeClaimOrHostPath
    kompose.version: 1.17.0 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: config
  name: config
spec:
  replicas: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 2
      maxSurge: 13
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: config
    spec:
      containers:
      - env:
        - name: CONFIG_SERVICE_PASSWORD
          value: configPwd
        image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/config:latest
        imagePullPolicy: Always
        livenessProbe:
          exec:
            command:
            - curl
            - -u
            - user:configPwd
            - http://127.0.0.1:8888/account-service/spring.data.mongodb.host
          initialDelaySeconds: 30
          timeoutSeconds: 30
        name: config
        resources:
          limits:
            cpu: "1"
            memory: "1073741824"
        securityContext:
          capabilities:
            add:
            - all
      restartPolicy: Always
status: {}

gateway-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    aliyun.auto_scaling.max_cpu: "70"
    aliyun.auto_scaling.max_instances: "10"
    aliyun.auto_scaling.min_cpu: "30"
    aliyun.auto_scaling.min_instances: "1"
    aliyun.auto_scaling.step: "1"
    aliyun.log_store_requestlog: stdout
    aliyun.probe.initial_delay_seconds: "50"
    aliyun.probe.timeout_seconds: "30"
    aliyun.probe.url: http://container:4000/index.html
    aliyun.rolling_updates: "true"
    aliyun.rolling_updates.parallelism: "2"
    aliyun.routing.port_4000: gateway;gateway.swarm.piggymetrics.com
    aliyun.scale: "1"
    kompose.cmd: kompose convert -f source/swarm-piggymetrics.yaml --volumes PersistentVolumeClaimOrHostPath
    kompose.version: 1.17.0 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: gateway
  name: gateway
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: gateway
    spec:
      containers:
      - env:
        - name: CONFIG_SERVICE_PASSWORD
          value: configPwd
        - name: aliyun_logs_requestlog
          value: stdout
        image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/gateway:latest
        livenessProbe:
          httpGet:
            path: /index.html
            port: 4000
          initialDelaySeconds: 50
          timeoutSeconds: 30
        name: gateway
        ports:
        - containerPort: 4000
      restartPolicy: Always
status: {}

gateway-ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: gateway
  name: gateway
spec:
  rules:
  - host: gateway.c7f537c92438f415b943e7c2f8ca30b3b.cn-zhangjiakou.alicontainer.com
    http:
      paths:
      - backend:
          serviceName: gateway
          servicePort: 80
  - host: gateway.swarm.piggymetrics.com
    http:
      paths:
      - backend:
          serviceName: gateway
          servicePort: 80
status:
  loadBalancer: {}

logtail2-daemonset.yaml

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  annotations:
    aliyun.global: "true"
    aliyun.latest_image: "false"
    kompose.cmd: kompose convert -f source/swarm-piggymetrics.yaml --volumes PersistentVolumeClaimOrHostPath
    kompose.version: 1.17.0 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: logtail2
  name: logtail2
spec:
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: logtail2
    spec:
      hostNetwork: true
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
        - 100.100.2.136
        - 100.100.2.138
      hostAliases:
      - ip: "192.168.0.1"
        hostnames:
        - "www.baidu.com"
      - ip: "192.168.253.8"
        hostnames:
        - "sample.aliyun.com"
      containers:
      - env:
        - name: log_region
          value: cn_hangzhou
        image: registry.aliyuncs.com/acs-sample/logtail:yunqi
        name: logtail2
        resources: {}
        securityContext:
          capabilities:
            add:
            - SYS_RAWIO
      restartPolicy: Always

swarm-piggymetrics.yaml

version: '2'
services:
  rabbitmq:
    image: >-
      registry-vpc.cn-hangzhou.aliyuncs.com/hd_docker_images/rabbitmq:latest
    hostname: rabbitmq
    restart: always
    ports:
      - '15672:15672'
    logging:
      options:
        max-file: '10'
        max-size: 10m
    labels:
      aliyun.scale: '1'
      aliyun.routing.port_15672: rabbitmq
    memswap_limit: 0
    shm_size: 0
    memswap_reservation: 0
    kernel_memory: 0
    name: rabbitmq

  config:
    environment:
      - CONFIG_SERVICE_PASSWORD=configPwd
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/config:latest
    hostname: config
    restart: always
    logging:
      options:
        max-file: '10'
        max-size: 10m
    labels:
      aliyun.probe.cmd: >-
        curl -u user:configPwd
        http://127.0.0.1:8888/account-service/spring.data.mongodb.host
      aliyun.probe.initial_delay_seconds: '30'
      aliyun.probe.timeout_seconds: '30'
      aliyun.scale: '10'
      aliyun.rolling_updates: 'true'
      aliyun.rolling_updates.parallelism: '2'
      aliyun.auto_scaling.max_cpu: '70'
      aliyun.auto_scaling.min_cpu: '30'
      aliyun.auto_scaling.step: '1'
      aliyun.auto_scaling.max_instances: '10'
      aliyun.auto_scaling.min_instances: '1'
      aliyun.latest_image: 'false'
    oom-kill-disable: true
    memswap_limit: 2000000000
    shm_size: 67108864
    memswap_reservation: 536870912
    kernel_memory: 0
    name: config
    mem_limit: 1073741824
    cpu_shares: 100
    cap_add:
      - all

  registry:
    environment:
      - CONFIG_SERVICE_PASSWORD=configPwd
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/registry:latest
    hostname: registry
    restart: always
    depends_on:
      - config
    ports:
      - '8761:8761'
    logging:
      options:
        max-file: '10'
        max-size: 10m
    labels:
      aliyun.scale: '1'
      aliyun.routing.port_8761: eureka
    memswap_limit: 0
    shm_size: 0
    memswap_reservation: 0
    kernel_memory: 0
    name: registry

  gateway:
    environment:
      - CONFIG_SERVICE_PASSWORD=configPwd
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/gateway:latest
    hostname: gateway
    restart: always
    depends_on:
      - config
    ports:
      - '80:4000'
    logging:
      options:
        max-file: '10'
        max-size: 10m
    labels:
      aliyun.probe.url: 'http://container:4000/index.html'
      aliyun.probe.initial_delay_seconds: '50'
      aliyun.probe.timeout_seconds: '30'
      aliyun.routing.session_sticky: 'true'
      aliyun.scale: '1'
      aliyun.routing.port_4000: gateway;gateway.swarm.piggymetrics.com
      aliyun.lb.port_4000: tcp://independent-slb:8080
      aliyun.rolling_updates: 'true'
      aliyun.rolling_updates.parallelism: '2'
      aliyun.auto_scaling.max_cpu: '70'
      aliyun.auto_scaling.min_cpu: '30'
      aliyun.auto_scaling.step: '1'
      aliyun.auto_scaling.max_instances: '10'
      aliyun.auto_scaling.min_instances: '1'
      aliyun.log_store_requestlog: stdout  # 采集stdout日志到requestlog日志库中
      aliyun.log_ttl_requestlog: 30  # 设置requestlog日志库日志数据保存30天
      aliyun.log.timestamp: true # Docker 在收集日志的时候可以选择是否添加 timestamp
    external_links:
      - auth-service.local
    oom-kill-disable: true
    name: gateway

  auth-service:
    environment:
      - MONGODB_PASSWORD=mongodbPwd
      - NOTIFICATION_SERVICE_PASSWORD=notificationPwd
      - STATISTICS_SERVICE_PASSWORD=statisticsPwd
      - ACCOUNT_SERVICE_PASSWORD=accountPwd
      - CONFIG_SERVICE_PASSWORD=configPwd
      - CLUSTER_NAME=$CLUSTER_NAME
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/auth-service:latest
    command: ["java", "-Xmx500m", "-jar", "/app/auth-service.jar"]
    restart: always
    logging:
      options:
        max-file: '10'
        max-size: 10m
    labels:
      aliyun.scale: '1'
      aliyun.log_store_requestlog: stdout  # 采集stdout日志到requestlog日志库中
      aliyun.log_ttl_requestlog: 30  # 设置requestlog日志库日志数据保存30天
      aliyun.log.timestamp: false # Docker 在收集日志的时候可以选择是否添加 timestamp
      aliyun.routing.session_sticky: "true"
      aliyun.routing.port_5000: auth-service.local
      aliyun.latest_image: 'true'
      aliyun.depends: config
    links:
      - auth-mongodb
    volumes:
      - 'volume_name_piggymetrics:/data/oss:rw'
      - 'VN_NAS_PIGGYMETRICS:/data/nas:rw'
      - 'VN_YUNPAN_PIGGYMETRICS:/data/yunpan:rw'
      - '/var/run/docker.sock:/var/run/docker.sock:rw'
      - '/tmp:/data/tmp'
    memswap_limit: 0
    shm_size: 0
    memswap_reservation: 0
    kernel_memory: 0
    name: auth-service
    hostname: auth-service
    entrypoint:
      - 'java'
      - '-Xmx200m'
      - '-jar'
      - '/app/auth-service.jar'
    cap_add:
      - all
    cap_drop:
      - SETGID
      - SETUID
    privileged: true

  auth-mongodb:
    environment:
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      constraint: group==db
    image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/mongodb
    restart: always
    labels:
      aliyun.probe.url: tcp://container:27017
    logging:
      options:
        max-size: 10m
        max-file: '10'
    entrypoint: '/init.sh'
    devices:
      - /dev/mem:/dev/mem

  account-service:
    environment:
      CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
      ACCOUNT_SERVICE_PASSWORD: $ACCOUNT_SERVICE_PASSWORD
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      RDS_PASSWORD: $RDS_PASSWORD
      RDS_URL: $RDS_URL
      CLUSTER_NAME: $CLUSTER_NAME
      affinity: service!=account-mongodb
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/account-service
    hostname: account-service
    restart: always
    external_links:
      - auth-service.local
    links:
      - account-mongodb:account-mongodb
      - account-db:account-db
    depends_on:
      config:
        condition: service_healthy
    logging:
      options:
        max-size: 10m
        max-file: '10'
    labels:
      aliyun.scale: '1'
      aliyun.log_store_requestlog: stdout  # 采集stdout日志到requestlog日志库中
      aliyun.log_store_errorLog: /var/log/common/common_error.log # 采集error日志到requestlog日志库中
      aliyun.log_store_monitorLog: /var/log/monitor/monitor_digest.log # 采集monitor_digest日志到requestlog日志库中
      aliyun.log_ttl_requestlog: 30  # 设置requestlog日志库日志数据保存30天
      aliyun.log.timestamp: true # Docker 在收集日志的时候可以选择是否添加 timestamp

  account-mongodb:
    environment:
      INIT_DUMP: account-service-dump.js
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      constraint: group==db
    image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/mongodb
    restart: always
    logging:
      options:
        max-size: 10m
        max-file: '10'
  statistics-service:
    environment:
      CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      STATISTICS_SERVICE_PASSWORD: $STATISTICS_SERVICE_PASSWORD
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/statistics-service
    hostname: statistics-service
    external_links:
      - auth-service.local
    restart: always
    depends_on:
      config:
        condition: service_healthy
    logging:
      options:
        max-size: 10m
        max-file: '10'
    labels:
      aliyun.log_store_requestlog: stdout  # 采集stdout日志到requestlog日志库中
      aliyun.log_ttl_requestlog: 30  # 设置requestlog日志库日志数据保存30天
      aliyun.log.timestamp: true # Docker 在收集日志的时候可以选择是否添加 timestamp
  statistics-mongodb:
    environment:
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      constraint: group==db
    image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/mongodb
    hostname: statistics-mongodb
    restart: always
    logging:
      options:
        max-size: 10m
        max-file: '10'
  notification-service:
    environment:
      CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      NOTIFICATION_SERVICE_PASSWORD: $NOTIFICATION_SERVICE_PASSWORD
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/notification-service
    hostname: notification-service
    external_links:
      - auth-service.local
    restart: always
    depends_on:
      config:
        condition: service_healthy
    logging:
      options:
        max-size: 10m
        max-file: '10'
    labels:
      aliyun.log_store_requestlog: stdout  # 采集stdout日志到requestlog日志库中
      aliyun.log_ttl_requestlog: 30  # 设置requestlog日志库日志数据保存30天
      aliyun.log.timestamp: true # Docker 在收集日志的时候可以选择是否添加 timestamp
  notification-mongodb:
    image: registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/mongodb
    hostname: notification-mongodb
    restart: always
    environment:
      MONGODB_PASSWORD: $MONGODB_PASSWORD
      constraint: group==db
    logging:
      options:
        max-size: 10m
        max-file: '10'
  monitoring:
    environment:
      - CONFIG_SERVICE_PASSWORD=configPwd
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/monitoring:latest
    hostname: monitoring
    restart: always
    depends_on:
      - config
    ports:
      - '9000:9000'
    logging:
      options:
        max-size: 10m
        max-file: '10'
    labels:
      aliyun.scale: '1'
      aliyun.routing.port_9000: hystrix
    memswap_limit: 0
    shm_size: 0
    memswap_reservation: 0
    kernel_memory: 0
    name: monitoring
  turbine-stream-service:
    environment:
      CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
    image: >-
      registry-vpc.cn-zhangjiakou.aliyuncs.com/goomoon-piggymetrics/turbine-stream-service
    hostname: turbine-stream-service
    restart: always
    depends_on:
      config:
        condition: service_healthy
    ports:
      - '8989:8989'
    logging:
      options:
        max-size: 10m
        max-file: '10'

  logtail2:
    image: registry.aliyuncs.com/acs-sample/logtail:yunqi
    labels:
      aliyun.latest_image: 'false'
      aliyun.global: 'true'
    devices:
      - /dev/mem:/dev/mem
    environment:
      - log_region=cn_hangzhou
    net: host
    extra_hosts:
      - "www.baidu.com:192.168.0.1"
      - "sample.aliyun.com:192.168.253.8"
    dns:
      - 100.100.2.136
      - 100.100.2.138
    cap_add:
      - SYS_RAWIO