k8s部署kong

官网:https://docs.konghq.com/kubernetes-ingress-controller/2.0.x/references/custom-resources/
github地址:https://github.com/Kong/kubernetes-ingress-controller
保留客户端真实IP地址:https://docs.konghq.com/kubernetes-ingress-controller/2.0.x/guides/preserve-client-ip/

1、下载yaml

wget https://raw.githubusercontent.com/Kong/kubernetes-ingress-controller/master/deploy/single/all-in-one-dbless.yaml

2、编辑Service

---
apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
  name: kong-proxy
  namespace: kong
spec:
  ports:
  - name: proxy
    port: 80
    protocol: TCP
    targetPort: 8000
  - name: proxy-ssl
    port: 443
    protocol: TCP
    targetPort: 8443
  - name: konga-api
    port: 8001
    protocol: TCP
    targetPort: 8001
  selector:
    app: ingress-kong
  type: NodePort

3、编辑kong变量

      - env:
        - name: KONG_PROXY_LISTEN
          value: 0.0.0.0:8000 reuseport backlog=16384, 0.0.0.0:8443 http2 ssl reuseport
            backlog=16384
        - name: KONG_PORT_MAPS
          value: 80:8000, 443:8443
        - name: KONG_ADMIN_LISTEN
          #value: 127.0.0.1:8444 http2 ssl reuseport backlog=16384
          value: 0.0.0.0:8001,127.0.0.1:8444 http2 ssl reuseport backlog=16384
        - name: KONG_STATUS_LISTEN
          value: 0.0.0.0:8100
        - name: KONG_DATABASE
          value: "off"
        - name: KONG_NGINX_WORKER_PROCESSES
          value: "2"
        - name: KONG_KIC
          value: "on"
        # 获取真实IP
        - name: KONG_TRUSTED_IPS
          value: "0.0.0.0/0,::/0"
        - name: KONG_REAL_IP_HEADER
          value: "X-Forwarded-For"
        - name: KONG_ADMIN_ACCESS_LOG
          value: /dev/stdout
        - name: KONG_ADMIN_ERROR_LOG
          value: /dev/stderr
        - name: KONG_PROXY_ERROR_LOG
          value: /dev/stderr
        - name: KONG_ROUTER_FLAVOR
          value: traditional

3、部署

kubectl apply -f all-in-one-dbless.yaml

 

 部署konga参考:https://www.cnblogs.com/linjiangCN/p/16982999.html

 

posted @ 2022-12-14 21:29  awks  阅读(208)  评论(0)    收藏  举报