forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for kserve with authorino
* Activate extauth for grpc traffic * Set host on requests from activator to trigger authconfig * Temp Authorization header fix to workaround https://issues.redhat.com/browse/OSSM-4873 Related to: opendatahub-io#614
- Loading branch information
1 parent
cb6ca7c
commit a660c77
Showing
5 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
pkg/feature/templates/servicemesh/kserve/activator-envoyfilter.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: EnvoyFilter | ||
metadata: | ||
labels: | ||
app: odh | ||
name: activator-host-header | ||
namespace: {{ .Mesh.Namespace }} | ||
spec: | ||
priority: 20 | ||
workloadSelector: | ||
labels: | ||
component: predictor | ||
configPatches: | ||
- applyTo: HTTP_FILTER | ||
match: | ||
listener: | ||
filterChain: | ||
filter: | ||
name: envoy.filters.network.http_connection_manager | ||
patch: | ||
operation: INSERT_BEFORE | ||
value: | ||
name: envoy.filters.http.lua | ||
typed_config: | ||
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua | ||
inlineCode: | | ||
function envoy_on_request(request_handle) | ||
local headers = request_handle:headers() | ||
if not headers then | ||
return | ||
end | ||
|
||
local original_host = headers:get("k-original-host") | ||
if original_host then | ||
|
||
port_seperator = string.find(original_host, ":", 7) | ||
if port_seperator then | ||
original_host = string.sub(original_host, 0, port_seperator-1) | ||
end | ||
headers:replace('host', original_host) | ||
end | ||
end |
79 changes: 79 additions & 0 deletions
79
pkg/feature/templates/servicemesh/kserve/envoy-oauth-temp-fix.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# https://issues.redhat.com/browse/OSSM-4873 | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: EnvoyFilter | ||
metadata: | ||
name: envoy-oauth-temp-fix-before | ||
namespace: {{ .Mesh.Namespace }} | ||
labels: | ||
app: odh | ||
temp: hack | ||
spec: | ||
workloadSelector: | ||
labels: | ||
istio: ingressgateway | ||
priority: 20 | ||
configPatches: | ||
- applyTo: HTTP_FILTER | ||
match: | ||
listener: | ||
filterChain: | ||
filter: | ||
name: envoy.filters.network.http_connection_manager | ||
patch: | ||
operation: INSERT_BEFORE | ||
value: | ||
name: envoy.filters.http.lua | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua | ||
inlineCode: | | ||
function envoy_on_request(request_handle) | ||
local headers = request_handle:headers() | ||
if not headers then | ||
return | ||
end | ||
|
||
local auth = headers:get("authorization") | ||
if auth then | ||
headers:replace("x-authorization", auth) | ||
end | ||
end | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: EnvoyFilter | ||
metadata: | ||
name: envoy-oauth-temp-fix-after | ||
namespace: {{ .Mesh.Namespace }} | ||
labels: | ||
app: odh | ||
temp: hack | ||
spec: | ||
workloadSelector: | ||
labels: | ||
istio: ingressgateway | ||
priority: 5 | ||
configPatches: | ||
- applyTo: HTTP_FILTER | ||
match: | ||
listener: | ||
filterChain: | ||
filter: | ||
name: envoy.filters.network.http_connection_manager | ||
patch: | ||
operation: INSERT_BEFORE | ||
value: | ||
name: envoy.filters.http.lua | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua | ||
inlineCode: | | ||
function envoy_on_request(request_handle) | ||
local headers = request_handle:headers() | ||
if not headers then | ||
return | ||
end | ||
|
||
local xauth = headers:get("x-authorization") | ||
if xauth then | ||
headers:replace("authorization", xauth) | ||
headers.remove("x-authorization") | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
pkg/feature/templates/servicemesh/kserve/grpc-authorizationpolicy.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: security.istio.io/v1beta1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: kserve-predicator | ||
namespace: {{ .Mesh.Namespace }} | ||
spec: | ||
action: CUSTOM | ||
provider: | ||
name: opendatahub-odh-auth-provider | ||
rules: | ||
- to: | ||
- operation: | ||
notPaths: | ||
- /healthz* | ||
ports: | ||
- "8013" | ||
selector: | ||
matchLabels: | ||
component: predictor |