나는 kubeflow를 dex가 아닌 keycloak을 사용해 사내sso인증 idp연동을 통한 kubeflow인증을 하고 있다.
즉 , oidc-authservice ->keycloak->사내sso인증서비스 를 통해 istio gateway에서 인증을 하고 있는데,
문제는 istio injection을 사용하는 모든 namespace의 리소스들이 인증을 요구받게되는점이다.
그래서 이 k8s cluster의 grafana도 redirection을 통해 인증을 요청받게되었고, 이문제를 해결해야했다.
비슷한 상황의 이슈들을 발견하여, 참고하여 조치했다.
https://github.com/kubeflow/kubeflow/issues/4549
Dex EnvoyFilter forces authentication to existing istio services · Issue #4549 · kubeflow/kubeflow
/kind bug What steps did you take and what happened: Created a cluster (IBM's cloud) configured with istio and knative. Created a knative service (behind istio) in the default namespace, confirmed ...
github.com
1. extension provider설정
istio configmap에 적용하고 istiod를 재시작해도된다.
또는 istio operator manifest에 입력하고 istio를 설치해도된다.
-istio configmap에 수정 후 istiod 재시작
data:
mesh: |-
# Add the following content to define the external authorizers.
extensionProviders:
- name: "sample-ext-authz-grpc"
envoyExtAuthzGrpc:
service: "ext-authz.foo.svc.cluster.local"
port: "9000"
- name: "sample-ext-authz-http"
envoyExtAuthzHttp:
service: "ext-authz.foo.svc.cluster.local"
port: "8000"
includeRequestHeadersInCheck: ["x-ext-authz"]
-또는 istiooperator(profile-overay.yaml)에 입력 후 istioctl install -f default.yaml -f profile-overay.yaml 로 설치
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
meshConfig:
extensionProviders:
- name: auth-provider
envoyExtAuthzHttp:
service: "authservice.istio-system.svc.cluster.local
port: "8080"
includeHeadersInCheck: ["authorization", "cookie", "x-auth-token"]
headerToUpstreamOnAllow: ["kubeflow-userid"]
tcpKeepalive:
time: 10s
interval: 5s
probes: 3
2.autorizationpolicy 생성
exterernal authorizer 설정이 된후에는 authorizationpolicy를 생성해서 활용하도록한다.
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
name: auth
spec:
action: CUSTOM
provider:
# The provider name must match the extension provider defined in the mesh config.
# You can also replace this with sample-ext-authz-http to test the other external authorizer definition.
name: auth-provider
rules:
# The rules specify when to trigger the external authorizer.
- to:
- operation:
notPaths:
- /grafana/*
selector:
matchLabels:
istio: ingressgateway