apiVersion: apps/v1
kind: Deployment
metadata:
  name: kong
  namespace: kong
  labels:
    app: kong
spec:
  replicas: 3
  selector:
    matchLabels:
      app: kong
  template:
    metadata:
      labels:
        name: kong
        app: kong
    spec:
      securityContext:
        sysctls:
          #kubenetes >= 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: "2"
          - name: net.ipv4.tcp_fin_timeout
            value: "20"
          - 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: "1048576"
          - 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: kong
        #image: kong:0.14.1-centos
        image: slpcat/kong:0.14.1-alpine
        imagePullPolicy: Always
        env:
          - name: KONG_ADMIN_LISTEN
            value: 'off'
          - name: KONG_DATABASE
            value: "postgres"
          - name: KONG_PG_HOST
            value: "postgres"
          - name: KONG_PG_PORT
            value: "5432"
          - name: KONG_PG_DATABASE
            value: "kong"
          - name: KONG_PG_USER
            value: "kong"
          - name: KONG_PG_PASSWORD
            value: "kong"
          #- name: KONG_DNS_RESOLVER
          #  value: "127.0.0.1:53"
          - name: KONG_DNS_ORDER
            value: "A,SRV,LAST,CNAME"
          - name: KONG_PROXY_ACCESS_LOG
            value: "/dev/stdout"
          - name: KONG_ADMIN_ACCESS_LOG
            value: "/dev/stdout"
          - name: KONG_PROXY_ERROR_LOG
            value: "/dev/stderr"
          - name: KONG_ADMIN_ERROR_LOG
            value: "/dev/stderr"
          - name: KONG_ANONYMOUS_REPORTS
            value: "off"
          - name: KONG_HEADERS
            value: "off"
          - name: KONG_CLIENT_MAX_BODY_SIZE
            value: "0"
          #- name: KONG_WORKER_CONNECTIONS
          #  value: "20000"
          - name: KONG_CLIENT_BODY_BUFFER_SIZE
            value: "8m"
          - name: KONG_PROXY_LISTEN
            value: "0.0.0.0:8000, 0.0.0.0:8443 ssl http2"
        ports:
        - name: proxy
          containerPort: 8000
          protocol: TCP
        - name: proxy-ssl
          containerPort: 8443
          protocol: TCP
