External access to KServe
The ML scenarios section is being refined. Individual steps and examples may be added. If you have questions, contact the Shturval platform team.
KServe is part of the Kubeflow installation. From a Notebook in the same cluster the model is available by the internal service name. The steps on this page are needed only when the model is called from outside — another system, CI, or a user service.
The external address looks like this: http://kserve.<commonName>/serving/<profile-namespace>/<model-name>/v1/models/<model-name>:predict. If you do not need inference from outside, skip this page. It does not affect Kubeflow, profiles, or GPU.
Change a service specification only through a ShturvalServicePatch (SSP). Do not add customvalues to the kubeflow-step-1 and kubeflow-step-2 SSCs that were created during installation.
What you should get
- Knative Serving knows the cluster domain and does not turn an image tag into a digest for the listed registries. If the registry CA is not in the Knative controller trust store, the registry root CA is mounted into the controller.
- KServe publishes models on one host and the path
/serving/<namespace>/<name>. - External nginx accepts
kserve.<commonName>, replaces Host with<commonName>, and sends traffic toistio-ingressgateway:80. - An AuthorizationPolicy allows the inference paths. The request from outside carries the Kubeflow session cookie. The policy itself limits paths and does not check the cookie.
Requirements
Create the Kubernetes resources in the client cluster. Run the check request in step 6 from the external host for which you are opening access.
kubeflow-step-0…kubeflow-step-4are installed, mode Auto, state Healthy;<commonName>is known —status.appliedCustomValues.controller.shturval.commonNameof SSCshturval-ingress-controller;- DNS
kserve.<commonName>points to the client cluster Ingress (the same one askubeflow.<commonName>); - a Kubeflow Profile and its namespace exist. Do not use
defaultandkubeflow-systemas the workspace; - the registry has the model runtime image (in the example,
sklearnserver); <registry-host>is known — the FQDN of the registry the cluster pulls this image from (often the mirror FQDN).
Substitute your own values:
| Placeholder | Where to get it |
|---|---|
<commonName> | SSC shturval-ingress-controller, controller.shturval.commonName |
<registry-host> | host from the runtime image URL, without the scheme and the path |
<profile-namespace> | Profile name / team namespace |
<tag> | tag of the sklearnserver image in your registry |
<model-URI> | URI of the model artifact (S3 or another storage the cluster can see) |
Where to put <commonName>:
| Where | Value |
|---|---|
Knative configDomain | <commonName> |
KServe ingressDomain | <commonName> |
Ingress host | kserve.<commonName> |
Ingress upstream-vhost | <commonName> |
Do not put kserve.<commonName> in configDomain and ingressDomain: nginx replaces Host with the bare <commonName>, and the KServe VirtualService must match that Host.
Step 1. Mirror root CA
The cluster downloads model images from the mirror. The connection is HTTPS, so the cluster must trust the mirror certificate.
If the mirror certificate was issued by a CA that the Knative controller does not trust, attach the mirror root CA.
If the mirror and the cluster already use the same CA, skip this step: do not create the ConfigMap, and remove the controller block from the SSP in step 2.
Ask the mirror administrator for the root certificate. For diagnostics you can get the certificate chain with the command below. Substitute the mirror FQDN:
echo | openssl s_client -showcerts -servername <mirror-host> -connect <mirror-host>:443 2>/dev/null
Do not decide which certificate is the root only by its place in the output: the server may not send the root CA. Before you add it, check the certificate subject, issuer, and fingerprint. Save the confirmed root certificate to a file, for example mirror-root-ca.pem.
The knative-serving namespace appears after Kubeflow is installed. Create a ConfigMap with the certificate in that namespace.
- Open the client cluster.
- Import the ConfigMap. Paste the certificate text instead of the placeholder:
apiVersion: v1
kind: ConfigMap
metadata:
name: registry-root-ca
namespace: knative-serving
data:
ca-bundle.pem: |
-----BEGIN CERTIFICATE-----
<mirror-root-CA-PEM>
-----END CERTIFICATE-----
- Namespace
knative-serving→ Config Maps:registry-root-cais there, keyca-bundle.pem.
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" -n knative-serving create configmap registry-root-ca \
--from-file=ca-bundle.pem=<path>/mirror-root-ca.pem
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" -n knative-serving get configmap registry-root-ca
Manifest parameters
| Parameter | Why it is needed |
|---|---|
name: registry-root-ca | ConfigMap name. The SSP in step 2 refers to it (controller.caBundle.configMapName). |
namespace: knative-serving | Knative Serving namespace. It appears after Kubeflow is installed. |
key ca-bundle.pem | Mirror root certificate in PEM. |
Step 2. SSP for Knative Serving
The SSP sets the cluster domain, the list of registries that skip the tag check, and (if you did step 1) the volume with the CA.
- Open the client cluster.
- Import the SSP:
apiVersion: ops.shturval.tech/v1beta2
kind: ShturvalServicePatch
metadata:
name: knative-for-kserve-external
spec:
patchOrder: 100
shturvalServiceConfigName: kubeflow-step-1
customvalues:
knative-serving1:
configDomain:
domains:
- "<commonName>": {}
configDeployment:
extraArgs:
registries-skipping-tag-resolving: "r.shturval.tech,<registry-host>,kind.local,ko.local,dev.local"
controller:
caBundle:
configMapName: registry-root-ca
key: ca-bundle.pem
path: ca-bundle.pem
mountPath: /etc/ssl/custom-certs
- Installed services →
kubeflow-step-1→ ShturvalServicePatch tab:knative-for-kserve-externalis listed. Wait until the service is Healthy.
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" apply -f - <<'EOF'
apiVersion: ops.shturval.tech/v1beta2
kind: ShturvalServicePatch
metadata:
name: knative-for-kserve-external
spec:
patchOrder: 100
shturvalServiceConfigName: kubeflow-step-1
customvalues:
knative-serving1:
configDomain:
domains:
- "<commonName>": {}
configDeployment:
extraArgs:
registries-skipping-tag-resolving: "r.shturval.tech,<registry-host>,kind.local,ko.local,dev.local"
controller:
caBundle:
configMapName: registry-root-ca
key: ca-bundle.pem
path: ca-bundle.pem
mountPath: /etc/ssl/custom-certs
EOF
Substitute <commonName> and <registry-host> before you apply the manifest. If you did not create the ConfigMap, remove the controller block from the manifest.
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get shturvalservicepatch knative-for-kserve-external
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get ssc kubeflow-step-1
Manifest parameters
| Parameter | Why it is needed |
|---|---|
shturvalServiceConfigName: kubeflow-step-1 | The SSP is applied to SSC kubeflow-step-1. The SSC created at install time is not edited by hand. |
configDomain.domains | Knative accepts requests on <commonName> after the Host rewrite. |
registries-skipping-tag-resolving | Knative does not turn an image tag into a digest for these registries. The node container runtime still pulls the image. Keep r.shturval.tech and the service values kind.local,ko.local,dev.local, and add your <registry-host>. |
controller.caBundle | Mounts ConfigMap registry-root-ca with the mirror CA. Remove the whole controller block if you skipped step 1. |
Step 3. SSP for KServe
The SSP sets pathTemplate and ingressDomain so that different models are reached on one host and different paths. Put <commonName> only in ingressDomain. Leave the other fields as in the example: the Istio gateway, class istio, scheme http, path /serving/{{ "{{ .Namespace }}" }}/{{ "{{ .Name }}" }}.
- Open the client cluster.
- Import the SSP:
apiVersion: ops.shturval.tech/v1beta2
kind: ShturvalServicePatch
metadata:
name: kserve-path-template
spec:
patchOrder: 100
shturvalServiceConfigName: kubeflow-step-2
customvalues:
kserve:
inferenceserviceConfig:
ingress: |-
{
"enableGatewayApi": false,
"kserveIngressGateway": "istio-system/istio-ingressgateway",
"ingressGateway" : "kubeflow/kubeflow-gateway",
"localGateway" : "knative-serving/knative-local-gateway",
"localGatewayService" : "knative-local-gateway.istio-system.svc.cluster.local",
"ingressDomain" : "<commonName>",
"ingressClassName" : "istio",
"domainTemplate": "{{ "{{ .Name }}-{{ .Namespace }}.{{ .IngressDomain }}" }}",
"pathTemplate": "{{ "/serving/{{ .Namespace }}/{{ .Name }}" }}",
"urlScheme": "http",
"disableIstioVirtualHost": false,
"disableIngressCreation": false
}
- Installed services →
kubeflow-step-2→ ShturvalServicePatch tab:kserve-path-templateis listed. Wait until the service is Healthy.
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" apply -f - <<'EOF'
apiVersion: ops.shturval.tech/v1beta2
kind: ShturvalServicePatch
metadata:
name: kserve-path-template
spec:
patchOrder: 100
shturvalServiceConfigName: kubeflow-step-2
customvalues:
kserve:
inferenceserviceConfig:
ingress: |-
{
"enableGatewayApi": false,
"kserveIngressGateway": "istio-system/istio-ingressgateway",
"ingressGateway" : "kubeflow/kubeflow-gateway",
"localGateway" : "knative-serving/knative-local-gateway",
"localGatewayService" : "knative-local-gateway.istio-system.svc.cluster.local",
"ingressDomain" : "<commonName>",
"ingressClassName" : "istio",
"domainTemplate": "{{ "{{ .Name }}-{{ .Namespace }}.{{ .IngressDomain }}" }}",
"pathTemplate": "{{ "/serving/{{ .Namespace }}/{{ .Name }}" }}",
"urlScheme": "http",
"disableIstioVirtualHost": false,
"disableIngressCreation": false
}
EOF
Substitute <commonName> before apply.
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get shturvalservicepatch kserve-path-template
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get ssc kubeflow-step-2
Manifest parameters
| Parameter | Why it is needed |
|---|---|
shturvalServiceConfigName: kubeflow-step-2 | The SSP is applied to SSC kubeflow-step-2. |
ingressDomain | Cluster domain <commonName>. Do not use kserve.<commonName>. |
pathTemplate | Path to the model: /serving/<namespace>/<name>. The external URL is built from it. |
domainTemplate | KServe host template. Leave it as in the example. |
urlScheme: http | The external Ingress in the example has no TLS. |
ingressClassName: istio | Inside the cluster, traffic goes through Istio. |
kserveIngressGateway / ingressGateway / localGateway | Istio and Knative gateways. Leave them as in the example. |
enableGatewayApi: false | Gateway API is not used. |
disableIstioVirtualHost / disableIngressCreation | The KServe VirtualService is created. Leave false. |
Step 4. Ingress and AuthorizationPolicy
Two objects in namespace istio-system:
- Ingress
kserve-external— the external nginx entry point on hostkserve.<commonName>; - AuthorizationPolicy
kserve-inference-access— allows the inference service paths on the model pods.
In the example the external Ingress has no TLS, scheme http. The Kubeflow UI stays at https://kubeflow.<commonName>/.
Use this HTTP variant only in an isolated test environment. Do not send a production session cookie over an untrusted network. For production, configure TLS and authentication checks on the external entry point.
- Open the client cluster.
- Replace
<commonName>in the manifest and load both objects in one file: Importing manifests → paste the YAML → Check → Save.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kserve-external
namespace: istio-system
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/upstream-vhost: "<commonName>"
spec:
ingressClassName: nginx
rules:
- host: kserve.<commonName>
http:
paths:
- path: /serving/
pathType: Prefix
backend:
service:
name: istio-ingressgateway
port:
number: 80
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: kserve-inference-access
namespace: istio-system
labels:
app.kubernetes.io/part-of: kserve-integration
spec:
action: ALLOW
rules:
- to:
- operation:
paths:
- /v1/models/*
- /v2/models/*
- /v2/health/*
- Namespace
istio-system→ Network → Ingresses: Ingresskserve-externalis there, hostkserve.<commonName>, path/serving/. - Administration → Custom resources → group
security.istio.io→ AuthorizationPolicy →kserve-inference-accessin namespaceistio-system.
Substitute <commonName> and run:
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kserve-external
namespace: istio-system
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/upstream-vhost: "<commonName>"
spec:
ingressClassName: nginx
rules:
- host: kserve.<commonName>
http:
paths:
- path: /serving/
pathType: Prefix
backend:
service:
name: istio-ingressgateway
port:
number: 80
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: kserve-inference-access
namespace: istio-system
labels:
app.kubernetes.io/part-of: kserve-integration
spec:
action: ALLOW
rules:
- to:
- operation:
paths:
- /v1/models/*
- /v2/models/*
- /v2/health/*
EOF
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get ingress kserve-external -n istio-system
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get authorizationpolicy kserve-inference-access -n istio-system
Manifest parameters
| Parameter | Resource | Why it is needed |
|---|---|---|
host: kserve.<commonName> | Ingress | The name used from outside. DNS kserve.<commonName> must point to the client cluster Ingress. |
path: /serving/ | Ingress | KServe in Serverless mode looks up the model by /serving/<namespace>/<name>. Do not strip the prefix, or the model will not be found. |
backend.service: istio-ingressgateway:80 | Ingress | nginx does not go to the model pod directly: first Istio, then KServe. |
upstream-vhost: "<commonName>" | Ingress | Rewrites Host kserve.<commonName> to the bare <commonName> so the VirtualService that KServe creates matches. |
proxy-read-timeout / proxy-send-timeout: 3600 | Ingress | A long model response (including a stream) is not cut off after a minute. |
ingressClassName: nginx | Ingress | shturval-ingress-controller handles the request, the same class as Kubeflow. |
action: ALLOW and paths /v1/models/*, /v2/models/*, /v2/health/* | AuthorizationPolicy | The predictor accepts predict/explain and health. A policy in istio-system applies to the whole mesh. |
Source (from.source) is not set | AuthorizationPolicy | The Knative activator calls the predictor without mTLS. A rule that checks the source would drop that request. This policy does not check the cookie and does not authenticate the external request by itself. |
Step 5. Test model
Create an InferenceService in the Profile namespace. minReplicas: 1 keeps the revision from scaling to zero before the check. Take the runtime image from your registry.
Set <model-URI> — the address of a compatible model artifact in storage the cluster can reach. The runtime image is set separately in image.
- Open the client cluster.
- Import the manifest. Substitute the namespace, the image, and the URI:
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
namespace: <profile-namespace>
spec:
predictor:
minReplicas: 1
sklearn:
image: <registry-host>/kubeflow/kserve/sklearnserver:<tag>
storageUri: "<model-URI>"
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
- Administration → Custom resources → group
serving.kserve.io→ InferenceService:sklearn-irisis Ready.
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" apply -f - <<'EOF'
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
namespace: <profile-namespace>
spec:
predictor:
minReplicas: 1
sklearn:
image: <registry-host>/kubeflow/kserve/sklearnserver:<tag>
storageUri: "<model-URI>"
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
EOF
Wait until it is Ready:
kubectl --kubeconfig "${KUBECONFIG_CLIENT}" get inferenceservice sklearn-iris -n <profile-namespace> -w
Status True / Ready means the model is up inside the cluster. This is not yet a check of the external HTTP call.
If the revision does not become Ready, check the predictor pod events: ImagePull errors, the x509 certificate check, and access to storage. Compare <registry-host> with registries-skipping-tag-resolving, and check that the CA ConfigMap exists if the Knative controller does not trust the registry CA.
Manifest parameters
| Parameter | Why it is needed |
|---|---|
name: sklearn-iris | Model name. It is part of the external path /serving/…/sklearn-iris/…. |
namespace | Profile namespace, not default. |
minReplicas: 1 | The revision does not scale to zero before the check. |
image | Runtime image from the mirror. |
storageUri | Where the runtime reads the model artifact. |
resources | CPU and memory requests and limits for the test predictor. |
Step 6. Check the external call
A call to the model is a POST, not opening the address in a browser. oauth2-proxy issues the session cookie after you sign in to the Kubeflow UI.
The cookie value is a secret. Do not paste it into documentation, tickets, or screenshots. Treat the cookie as a secret until it expires or the session is revoked. Run the command below only in an isolated test environment.
- In a browser, open
https://kubeflow.<commonName>/and sign in. - Open the developer tools → Cookies (Chrome: Application → Cookies, Firefox: Storage → Cookies) for the host
kubeflow.<commonName>. - Copy the value of the cookie
oauth2_proxy_kubeflow.
export COOKIE='oauth2_proxy_kubeflow=<cookie-value>'
curl -sS -D - -X POST \
-H "Cookie: ${COOKIE}" \
-H 'Content-Type: application/json' \
-d '{"instances": [[6.8, 2.8, 4.8, 1.4]]}' \
"http://kserve.<commonName>/serving/<profile-namespace>/sklearn-iris/v1/models/sklearn-iris:predict"
Expect HTTP 200 and a predictions field in the response body. The value depends on the model in <model-URI>.
If there is no response:
| Symptom | What to check |
|---|---|
| No route, timeout | DNS kserve.<commonName>, Ingress kserve-external |
| 404 | pathTemplate, path /serving/<namespace>/<name>/v1/models/<name>:predict, upstream-vhost equals <commonName> |
| 401 / 403 | cookie oauth2_proxy_kubeflow, AuthorizationPolicy |
| 503, empty predictor | InferenceService is not Ready yet, minReplicas |
Related pages: