apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat8
  namespace: default
  labels:
    app: tomcat8
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tomcat8
#  minReadySeconds: 60     #滚动升级时60s后认为该pod就绪
  strategy:
    rollingUpdate:  ##由于replicas为3,则整个升级,pod个数在2-4个之间
      maxSurge: 1      #滚动升级时会先启动1个pod
      maxUnavailable: 1 #滚动升级时允许的最大Unavailable的pod个数
  template:
    metadata:
      labels:
        app: tomcat8
    spec:
      terminationGracePeriodSeconds: 60 ##k8s将会给应用发送SIGTERM信号，可以用来正确、优雅地关闭应用,默认为30秒
      #imagePullSecrets:
      #- name: registrykey-ali-ext
      containers:
      - name: tomcat8
        #image: registry.cn-beijing.aliyuncs.com/example/example_web:${BUILD_NUMBER}
        image: slpcat/tomcat:alpine-8.5-pinpoint
        imagePullPolicy: Always
        command:
        - sh
        - -c
        - "configure-agent.sh && catalina.sh run"
        livenessProbe: #kubernetes认为该pod是存活的,不存活则需要重启
          httpGet:
            path: /
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 60 ## equals to the maximum startup time of the application + couple of seconds
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        readinessProbe: #kubernetes认为该pod是启动成功的
          httpGet:
            path: /
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 30 ## equals to minimum startup time of the application
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        resources:
          # keep request = limit to keep this container in guaranteed class
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 4
            memory: 8Gi
        env:
          - name: PINPOINT_VERSION
            value: "2.2.1"
          - name: AGENT_ID
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: SPRING_PROFILES
            value: "release"
          - name:  TRANSPORT_MODULE
            value: "GRPC"
          - name: APP_NAME
            value: "tomcat-demo"
          - name: COLLECTOR_IP
            value: "pinpoint-collector.tracing"
          - name: COLLECTOR_TCP_PORT
            value: "9994"
          - name: COLLECTOR_STAT_PORT
            value: "9995"
          - name: COLLECTOR_SPAN_PORT
            value: "9996"
          - name: PROFILER_SAMPLING_RATE
            value: "20"
          - name: DEBUG_LEVEL
            value: "INFO"
          - name: JAVA_OPTS
            value: "-server -Djava.awt.headless=true -javaagent:/pinpoint-agent/pinpoint-agent-${PINPOINT_VERSION}/pinpoint-bootstrap-${PINPOINT_VERSION}.jar -Dpinpoint.agentId=${AGENT_ID} -Dpinpoint.applicationName=${APP_NAME} -Dpinpoint.config=/pinpoint-agent/pinpoint-agent-${PINPOINT_VERSION}/pinpoint-root.config -Xverify:none -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:ReservedCodeCacheSize=240M -XX:MaxRAMFraction=2 -XshowSettings:vm -XX:+AggressiveOpts -XX:-UseBiasedLocking -XX:+UseFastAccessorMethods -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:SoftRefLRUPolicyMSPerMB=0 -XX:G1ReservePercent=25 -XX:G1NewSizePercent=10 -XX:G1MaxNewSizePercent=25 -XX:MaxGCPauseMillis=20 -XX:-OmitStackTraceInFastThrow -XX:+ParallelRefProcEnabled -XX:ParallelGCThreads=8 -XX:MaxTenuringThreshold=1 -XX:G1HeapWastePercent=10 -XX:SurvivorRatio=8 -XX:G1MixedGCCountTarget=16 -XX:G1MixedGCLiveThresholdPercent=90 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=32m -XX:+PerfDisableSharedMem -XX:-ResizePLAB"
        ports:
          - name: http
            containerPort: 8080
