콘텐츠로 이동

Knative Serving

Interactive Diagram

새 탭 ↗
항목값
versionKnative 1.22.0
공식 문서Knative Serving
upstream 소스common/knative/knative-serving, common/istio/cluster-local-gateway

Knative는 Kubernetes 위에 serverless workload model을 제공한다. Kubeflow에서는 주로 KServe가 InferenceService를 serverless 형태로 띄우고 routing, revision, scale-to-zero, activator 경유 처리를 맡기기 위해 Knative Serving을 사용한다. 이 문서는 KServe serving의 기반이 되는 Knative Serving에 집중한다.

Knative Serving의 Activator, Autoscaler, Controller, Webhook과 Ingress, Queue-Proxy를 둔 user Pod의 관계 출처: Knative 문서, Knative Serving Architecture, The Knative Authors, Apache-2.0

  • Knative Serving control plane: activator, autoscaler, controller, webhook과 net-istio-controller, net-istio-webhook을 설치한다.
  • Serving CRD: services.serving.knative.dev, revisions.serving.knative.dev, routes.serving.knative.dev, configurations.serving.knative.dev 등 KServe serverless runtime이 의존하는 API를 제공한다.
  • Kubeflow gateway 연결: 기본 knative-ingress-gateway를 제거하고, config-istio가 kubeflow/kubeflow-gateway와 istio-ingressgateway를 사용하도록 patch한다.
  • cluster-local-gateway 연결: knative-local-gateway라는 Service/Gateway 이름은 유지하되 selector를 cluster-local-gateway workload로 돌려 KServe 내부 serving hop을 처리한다.
  • Serving M2M 2-hop JWT 검증: cluster-local-gateway-jwt RequestAuthentication에 legacy ServiceAccount token issuer를 추가해 외부 serving 호출의 두 번째 gateway hop도 통과하게 한다.

upstream Knative는 자체 ingress gateway를 만들 수 있지만, 이 배포는 Kubeflow web app과 serving traffic을 Istio/Kubeflow gateway 체계 안에서 관리한다. 그래서 Knative Serving base는 knative-ingress-gateway를 제거하고 config-istio에 gateway.kubeflow.kubeflow-gateway: istio-ingressgateway.istio-system.svc.cluster.local을 추가한다.

config-deployment의 progressDeadline은 600s로 늘려 둔다. 큰 모델 image pull이나 container 시작 시간이 기본값보다 길어질 수 있기 때문이다.

KServe는 모델 serving workload를 단순 Deployment로만 다루지 않는다. InferenceService가 predictor revision을 만들고, 요청량에 따라 activator와 autoscaler가 관여하며, route와 domain 설정을 통해 외부/내부 endpoint를 구성한다. 이 serverless layer가 없으면 KServe의 serverless serving 경로와 scale-to-zero, revision 기반 rollout이 성립하지 않는다.

  • KServe serverless substrate: KServe controller가 InferenceService를 Knative Service/Revision/Route로 구체화할 수 있는 API와 controller를 제공한다.
  • Istio routing 통합: Knative가 만든 Route/VirtualService가 Kubeflow gateway와 local gateway 체계를 사용하도록 맞춘다.
  • 내부 serving hop 보안: cluster-local-gateway에도 JWT 검증과 AuthorizationPolicy를 둬서 KServe serving의 두 번째 hop을 익명으로 열어 두지 않는다.
  • Kubeflow RBAC 확장: Knative namespaced admin/edit/view ClusterRole에 aggregation label을 붙여 kubeflow-admin, kubeflow-edit, kubeflow-view에 권한이 합쳐지게 한다.

이 저장소의 dev overlay는 upstream common overlay를 얇게 감싼다. Serving은 본체와 cluster-local-gateway M2M auth를 분리해서 적용한다.

overlays/dev/knative-serving/overlays/gateways
-> common/knative/knative-serving/overlays/gateways
-> common/knative/knative-serving/base
overlays/dev/knative-serving/overlays/cluster-local-gateway
-> common/istio/cluster-local-gateway/overlays/m2m-auth
-> common/istio/cluster-local-gateway/base
-> dev patch: legacy issuer kubernetes/serviceaccount
적용 단위주요 내용이유
knative-serving/overlays/gatewaysServing core, net-istio, Kubeflow gateway patch, Knative local gateway selector patchKServe serverless serving의 control plane과 routing 기반
knative-serving/overlays/cluster-local-gatewaycluster-local-gateway workload, Gateway, RequestAuthentication, AuthorizationPolicyKServe serving 내부 hop과 2-hop JWT 검증
항목값 / 동작의미
config-istiogateway.kubeflow.kubeflow-gateway -> istio-ingressgateway.istio-system.svc.cluster.localKnative external gateway를 Kubeflow gateway로 연결
knative-ingress-gateway삭제별도 Knative ingress gateway를 만들지 않음
knative-local-gateway Serviceselector app: cluster-local-gateway, istio: cluster-local-gateway이름은 Knative/KServe가 기대하는 값을 유지하고 실제 Pod는 cluster-local-gateway 사용
knative-local-gateway Gatewayselector app: cluster-local-gateway, istio: cluster-local-gatewaylocal gateway traffic을 cluster-local-gateway workload로 전달
cluster-local-gateway-jwtbound token issuer 2개 + legacy issuer kubernetes/serviceaccountKServe serving 2-hop JWT 검증
config-domainexample.com: ""Knative 기본 domain placeholder
namespaceresource이름역할
knative-servingDeploymentactivatorscale-to-zero 상태의 revision 앞에서 요청을 받아 Pod 활성화
knative-servingDeploymentautoscalerrequest metric 기반 revision scale 조정
knative-servingDeploymentcontrollerKnative Service, Route, Revision, Configuration reconcile
knative-servingDeploymentwebhookServing resource validation/defaulting
knative-servingDeploymentnet-istio-controller, net-istio-webhookKnative Route를 Istio VirtualService/Gateway와 연결
knative-servingConfigMapconfig-istio, config-domain, config-deploymentgateway, domain, deployment deadline 설정
knative-servingGatewayknative-local-gatewaylocal serving route가 참조하는 Istio Gateway 이름
istio-systemServiceknative-local-gateway실제 selector는 cluster-local-gateway Pod를 가리킴
istio-systemDeployment + Servicecluster-local-gatewayKServe serving 내부 route의 두 번째 gateway hop
istio-systemRequestAuthenticationcluster-local-gateway-jwtcluster-local-gateway에서 Bearer token 검증
istio-systemAuthorizationPolicycluster-local-gateway, cluster-local-gateway-require-jwtJWT principal이 있는 요청만 허용하고 익명 요청 거부
(cluster)CRD*.serving.knative.dev 등Knative Serving API
(cluster)ClusterRoleknative-serving-namespaced-*Kubeflow aggregated RBAC에 합쳐지는 user-facing 권한

PlantUML 원본:

PlantUML Diagram
  • 선행: Istio control plane과 istio-ingressgateway, kubeflow-gateway, cluster JWKS proxy, Kubeflow aggregated RBAC 기준 role.
  • 후행: KServe controller와 KServe InferenceService runtime.
  • 같이 봐야 하는 문서: serving 외부 host와 dashboard host 분리는 Kubeflow Istio Resources, M2M 2-hop 인증은 인증 흐름, user namespace 권한과 serving predictor ALLOW 정책은 멀티테넌시와 User Profile에서 다룬다.

KServe가 InferenceService를 reconcile하면 Knative Serving API를 통해 Service, Revision, Route가 만들어지고, Serving controller와 net-istio-controller가 이를 Pod, Service, Istio VirtualService로 구체화한다. scale-to-zero 상태에서는 activator가 요청을 받아 revision Pod 활성화를 유도하고, autoscaler가 request metric에 따라 replica 수를 조정한다.

외부 serving 요청은 kserve.10.x.x.x.nip.io host로 들어와 istio-ingressgateway에서 1차 JWT 검증을 받고, KServe/Knative route가 내부 predictor host로 넘기면서 cluster-local-gateway를 2차 경유한다. 이때 cluster-local-gateway-jwt에도 legacy issuer kubernetes/serviceaccount가 있어야 platform-api-token 같은 legacy ServiceAccount token이 통과한다. RequestAuthentication과 AuthorizationPolicy 변경은 xDS로 push되므로 Pod 재기동 없이 반영된다.

  • config-istio: Knative가 사용할 external gateway를 Kubeflow gateway로 지정한다.
  • knative-local-gateway Service/Gateway: 이름은 Knative/KServe가 기대하는 local gateway지만 실제 workload는 cluster-local-gateway다.
  • cluster-local-gateway-jwt: serving 2-hop의 JWT 검증 지점. bound token issuer와 legacy issuer를 모두 신뢰한다.
  • cluster-local-gateway-require-jwt: health/metrics path를 제외하고 JWT principal이 없는 요청을 거부한다.
  • activator, autoscaler, controller, webhook: Knative Serving runtime과 API lifecycle의 핵심 control plane.
  • Knative namespaced ClusterRole: Kubeflow aggregated RBAC에 합쳐져 Profile namespace 사용자가 Knative/KServe 관련 resource를 다룰 수 있게 한다.

다음 표는 deployment에 적용되는 추가 보정을 정리한다.

AdjustmentTargetWhy it exists
Remove knative-ingress-gatewayKnative gateway resourcesavoid creating a second, separate ingress gateway stack
Patch config-istioKnative configmap gateway.kubeflow.kubeflow-gateway to istio-ingressgateway.istio-system.svc.cluster.local
Keep knative-local-gateway namesService and Gatewaypreserve the names Knative and KServe expect
Redirect selectors to cluster-local-gatewayService and Gateway selectorsmake the actual traffic land on the repository’s shared local-gateway workload
Add legacy issuer support to cluster-local-gateway-jwtRequestAuthenticationallow the second hop to accept legacy ServiceAccount tokens such as platform-api-token
Extend progressDeadline to 600sconfig-deploymentlarge model images can need longer pulls and slower startup