apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zentao
  namespace: default
  labels:
    app: zentao
spec:
  selector:
    matchLabels:
      app: zentao
  serviceName: zentao
  replicas: 1
  #minReadySeconds: 60     #滚动升级时60s后认为该pod就绪
  template:
    metadata:
      labels:
        app: zentao
    spec:
      terminationGracePeriodSeconds: 60 ##k8s将会给应用发送SIGTERM信号，可以用来正确、优雅地关闭应用,默认为30秒
      #从私有仓库下载镜像
      #imagePullSecrets:
      #- name: registrykey-ali-ext
      securityContext:
        sysctls:
          #kubernetes >= v1.11 and kernel version >= 4.15 needed
          #- name: kernel.msgmax
          #  value: "65536"
          - name: net.ipv4.tcp_syncookies
            value: "0"
          - name: net.ipv4.ip_local_port_range
            value: "1024 65535"
          - name: net.core.somaxconn
            value: "65535"
          - name: net.ipv4.ip_unprivileged_port_start
            value: "0"
          - name: net.ipv4.tcp_tw_reuse
            value: "1"
          - name: net.ipv4.tcp_fin_timeout
            value: "30"
          - name: net.ipv4.tcp_keepalive_intvl
            value: "10"
          - name: net.ipv4.tcp_keepalive_probes
            value: "2"
          - name: net.ipv4.tcp_keepalive_time
            value: "120"
          - name: net.ipv4.tcp_ecn
            value: "1"
          - name: net.ipv4.tcp_max_syn_backlog
            value: "65536"
          - name: net.ipv4.tcp_rfc1337
            value: "1"
          - name: net.ipv4.tcp_slow_start_after_idle
            value: "0"
          - name: net.ipv4.tcp_fack
            value: "1"
          - name: net.ipv4.tcp_max_tw_buckets
            value: "262144"
          - name: net.ipv4.tcp_fastopen
            value: "3"
          - name: net.ipv4.icmp_ratelimit
            value: "100"
          - name: net.ipv4.tcp_abort_on_overflow
            value: "1"
          - name: net.ipv4.tcp_adv_win_scale
            value: "2"
          - name: net.ipv4.tcp_retries2
            value: "8"
          - name: net.ipv4.tcp_syn_retries
            value: "3"
          - name: net.ipv4.tcp_synack_retries
            value: "2"
          - name: net.unix.max_dgram_qlen
            value: "512"
          - name: net.ipv4.tcp_fwmark_accept
            value: "1"
          - name: net.ipv4.fwmark_reflect
            value: "1"
      containers:
      - name: zentao
        image: slpcat/zentao
        imagePullPolicy: Always
        livenessProbe: #kubernetes认为该pod是存活的,不存活则需要重启
          httpGet:
            path: /
            port: 80
            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: 80
            scheme: HTTP
          initialDelaySeconds: 30 # equals to minimum startup time of the application
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 5
        env:
        - name: USER
          value: "root"
        - name: PASSWD
          value: "password"
        - name: BIND_ADDRESS
          value: "false"
        resources:
          # keep request = limit to keep this container in guaranteed class
          requests:
            cpu: 500m
            memory: 1Gi
          limits:
            cpu: 2000m
            memory: 4Gi
        ports:
          - name: web
            containerPort: 80
        volumeMounts:
          - name: zentao-data
            mountPath: "/opt"
  volumeClaimTemplates:
  - metadata:
      name: zentao-data
    spec:
      accessModes:
      - ReadWriteOnce
      #ceph rbd storageclass
      #storageClassName: rbd
      resources:
        requests:
          storage: 40Gi
