본문으로 건너뛰기

Kubeflow 서비스 문제 해결

Kubeflow 서비스 사용 중 발생할 수 있는 문제와 해결 방법을 안내합니다.


KServe 인증 문제 해결

Kubeflow 환경의 KServe는 기본적으로 Dex 인증을 요구합니다. 따라서 인증 세션 authservice_session 쿠키 또는 적절한 인증 헤더 없이 InferenceService 엔드포인트를 호출하면 403 Forbidden 오류가 발생할 수 있습니다.

▶️ 해결 방법

Kserve Inference Service를 인증 없이 퍼블릭 API로 노출하려면, 아래와 같이 이미 존재하는 Istio EnvoyFilter 리소스를 수정해 주세요.

authn-filter 수정 예시
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
annotations:
meta.helm.sh/release-name: <your-auth-release>
meta.helm.sh/release-namespace: auth
generation: 1
labels:
app.kubernetes.io/managed-by: Helm
name: authn-filter
namespace: istio-system
spec:
configPatches:
# [추가] 인증 우회를 위한 특정 서빙 API 엔드포인트 설정
- applyTo: VIRTUAL_HOST
match:
routeConfiguration:
vhost:
name: {isvc_name}.{namespace}.{your_domain}:80 # 예: lb-predictor.kbm-u-example.example.com:80
patch:
operation: MERGE
value:
typed_per_filter_config:
envoy.filters.http.ext_authz:
'@type': >-
type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
disabled: true
# 기존 인증 필터 설정 (변경 없음)
- applyTo: HTTP_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: envoy.http_connection_manager
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.ext_authz
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
transport_api_version: V3
http_service:
authorization_request:
allowed_headers:
patterns:
- exact: authorization
- exact: cookie
- exact: x-auth-token
authorization_response:
allowed_upstream_headers:
patterns:
- exact: kubeflow-userid
server_uri:
cluster: outbound|8080||authservice.istio-system.svc.cluster.local
timeout: 10s
uri: http://authservice.istio-system.svc.cluster.local
workloadSelector:
labels:
istio: ingressgateway

▶️ 적용 확인 및 반영 명령어

설정이 Istio IngressGateway에 정상적으로 반영되었는지 확인하려면 다음 명령어를 사용하세요.

kubectl get envoyfilter authn-filter -n istio-system -o json | \
jq '.spec.configPatches[] | select(.applyTo == "VIRTUAL_HOST" and .match.routeConfiguration.vhost.name == "{isvc_name}.{project_id}.kubeflow.{your_domain}:80")'

출력 예시:

{
"applyTo": "VIRTUAL_HOST",
"match": {
"routeConfiguration": {
"vhost": {
"name": "{isvc_name}.{project_id}.kubeflow.{your_domain}:80"
}
}
},
"patch": {
"operation": "MERGE",
"value": {
"typed_per_filter_config": {
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"disabled": true
}
}
}
}
}

필요 시 아래 명령어로 직접 리소스를 편집할 수 있습니다. Helm으로 배포된 리소스를 직접 편집하는 경우, 향후 Helm 업그레이드 시 설정이 덮어씌워질 수 있으니 주의하세요.

kubectl edit envoyfilter authn-filter -n istio-system

변경 사항이 반영되지 않은 경우에는 istio-ingressgateway 파드를 재시작하여 적용 상태를 확인하세요.

kubectl rollout restart deployment istio-ingressgateway -n istio-system

▶️ 인증 우회 엔드포인트 테스트 (예시 요청)

수정이 완료되면 아래와 같은 방식으로 curl을 통해 인증 없이 추론 API를 호출할 수 있습니다.

curl --insecure --location 'https://{your_domain}/v1/models/{model_name}:predict' \
-H 'Host: {isvc_name}.{namespace}.{your_domain}' \
-H 'Content-Type: application/json' \
-d '{"instances": [[0.1, 0.1, 0.1, 0.1]]}'
주의 사항

위 예시는 트래픽 예측 모델용 샘플로 사용하는 모델에 따라 페이로드 형식이 다를 수 있습니다. 해당 모델의 입력 스펙을 반드시 확인하고 요청 구조를 조정하세요.