Kong Ingress Controller(KIC)

cloud2000·2025년 3월 30일
0

Kong Ingress Controller는 Kong Gateway를 Kubernetes Ingress로 실행하여 Kubernetes 클러스터에 대한 인바운드 요청을 담당할 수 있도록 한다. KIC는 Ingress 또는 HTTPRoute와 같은 k8s resource를 생성하면 유효한 Kong gateway configuration으로 변환시켜준다.

아키텍처

  • Kong controller는 ingress 정보로 kong gateway 설정을 동적으로 변경시키며, 클라이언트 트랙픽은 Kong controller를 거치지 않고 Kong gateway로 직접 연결된다. 즉, kube-proxy를 거치지 않는다.
  • 클라이언트 트래픽은 Kong의 Route에 정의된 rule에 따라 Service -> Upstream 객체를 통해 Target pod로 연결된다.

Kong Gateway Operator

설치

helm repo add kong https://charts.konghq.com
helm repo update

helm upgrade -n kong-system -i --create-namespace kgo kong/gateway-operator

kubectl -n kong-system wait --for=condition=Available-true --timeout=120s deployment/kgo-gateway-operator-controller-manager

설치

  1. k8s Gateway-api CRD 생성
    Gateway api는 standard와 experimental이 있으며 experimetal에는 standard에는 없는 tcproute, tlsroute, udproute등의 CRD가 추가로 정의되어 있음.

    standardexperimetal
    gatewayclasses.gateway.networking.k8s.iogatewayclasses.gateway.networking.k8s.io
    gateways.gateway.networking.k8s.iogateways.gateway.networking.k8s.io
    grpcroutes.gateway.networking.k8s.iogrpcroutes.gateway.networking.k8s.io
    httproutes.gateway.networking.k8s.iohttproutes.gateway.networking.k8s.io
    referencegrants.gateway.networking.k8s.ioreferencegrants.gateway.networking.k8s.io
    tcproutes.gateway.networking.k8s.io
    tlsroutes.gateway.networking.k8s.io
    udproutes.gateway.networking.k8s.io
    backendlbpolicies.gateway.networking.k8s.io
    backendtlspolicies.gateway.networking.k8s.io
  2. 글 작성시점에 v1.2.1이 최신버전이나 kong문서에는 v1.1.0을 사용하도록 되어 있음.

  • standard
$ kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml
  • experimetal (tcproute 기능을 사용하고자 이 버전을 설치함)
$ kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/experimental-install.yaml
  1. Gatewayclass와 gateway instanace 생성
echo "
---
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
 name: kong
 annotations:
   konghq.com/gatewayclass-unmanaged: 'true'
spec:
 controllerName: konghq.com/kic-gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
 name: kong
spec:
 gatewayClassName: kong
 listeners:
 - name: proxy
   port: 80
   protocol: HTTP
   allowedRoutes:
     namespaces:
        from: All
"_텍스트_ | kubectl apply -f -
  1. kong controller와 kong gateway 설치
$ helm repo add kong https://charts.konghq.com
$ helm repo update
$ helm install kong kong/ingress -n kong --create-namespace 
  1. 확인
$ kubectl -n kong get pods
NAME                               READY   STATUS    RESTARTS        AGE
kong-gateway-dcff885c4-mkq5t       1/1     Running   0               3h48m
kong-controller-596d4d6995-thm8k   1/1     Running   2 (3h48m ago)   3h48m

$ kubectl -n kong get svc
NAME                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
kong-gateway-admin                   ClusterIP   None            <none>        8444/TCP                        3h48m
kong-controller-metrics              ClusterIP   10.43.177.67    <none>        10255/TCP,10254/TCP             3h48m
kong-controller-validation-webhook   ClusterIP   10.43.208.206   <none>        443/TCP                         3h48m
kong-gateway-manager                 NodePort    10.43.246.102   <none>        8002:30003/TCP,8445:30004/TCP   3h48m
kong-gateway-proxy                   NodePort    10.43.55.222    <none>        80:30005/TCP,443:30006/TCP      3h48m

기능

  1. Kong은 k8s ingress resource를 당분간 계속 지원하기는 하지만, Gateway API resource가 클러스터 인바운드 라우팅을 구성하는 데 선호되는 방식임으로 가급적 Gateway API를 사용하는 것이 좋다.

참고

profile
클라우드쟁이

0개의 댓글