From 81a0c719a530a903ed84197e2369a8686c568826 Mon Sep 17 00:00:00 2001 From: Jose Armesto Date: Thu, 12 Nov 2026 14:22:14 +0100 Subject: [PATCH 1/4] fix(skill-manager): reach the login provider on a private installation The skill-manager's MCP backend entry carries its issuer (identityProvider), and the connectivity chart renders a CiliumNetworkPolicy for its pods with the managers' identity-provider egress: the issuer's host by name on 443 and the cluster entity on 443 and 10443. On Cilium the chart's own ipBlock rule matches no in-cluster endpoint, so a Dex reached through the in-cluster Gateway was unreachable. verify-manager-identity.py checks the identity-provider egress of every manager and fails a component with an oauth block that it does not check. --- docs/reference.md | 1 + .../networkpolicy-mcp-backend-idp-egress.yaml | 37 ++++++++++++++++ .../values.schema.json | 20 +++++++++ helm/agent-platform-connectivity/values.yaml | 7 ++- helm/agent-platform/templates/_helpers.tpl | 28 ++++++++++++ tests/golden/meta-ci-engine-off.yaml | 3 ++ tests/verify-manager-identity.py | 43 +++++++++++++++++++ 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 helm/agent-platform-connectivity/templates/networkpolicy-mcp-backend-idp-egress.yaml diff --git a/docs/reference.md b/docs/reference.md index 0ceb513e..ef4ef410 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -309,6 +309,7 @@ The default agent is `default-agent` in the kagent namespace, shown as `defaultA - `components.skill-manager` follows `components.agent-manager`. `enabled: false` leaves it out. `dependsOn: [muster]`. Nothing waits for it: agent-manager and the default agent install while it fails. - Its `sources` are derived: the platform source, then `skillManager.sources`. An own `skill-manager.sources` fails the render. - It is an OAuth resource server like the managers: the issuer, client, secret and CA come from `skill-manager.oauth`, else from `global.identity`. Anything still unset is filled from muster's OAuth server block (`muster.muster.oauth.server.dex.*`, `.existingSecret`). +- Its egress to that login is the managers' (Cilium): its MCP backend entry carries the issuer (`networkPolicy.mcpBackends.skill-manager.identityProvider`), and the connectivity chart allows its pods the issuer's host by name on 443 and the `cluster` entity on 443 and 10443, the path to a Dex behind an in-cluster Gateway on a private installation. - GitHub access goes in `skill-manager.github` (`app.secretName` or `tokenSecret.name`). Empty reads public repositories anonymously. - agent-manager gets `skillManager.url`, the skill-manager's Service, from `agent-platform.agentManager.skillManagerFloor` on, `installation` (`backstage.installationName`), which `get_info` reports for the default agent's start links, and `defaultAgentModel.agent: default-agent` while the default agent is on. Below it, or with the skill-manager off, agent-manager gets `skills.repositories` as URLs, without the platform source. `agent-manager.skills.repositories` set while agent-manager uses the skill-manager fails the render. - Its NetworkPolicy admits its callers' namespaces (`networkPolicy.ingressNamespaces`, derived: muster's, the portal's, agent-manager's, the kagent namespace). The connectivity chart registers it as muster's MCP backend and opens agent-manager's and its migrate run's egress to it. diff --git a/helm/agent-platform-connectivity/templates/networkpolicy-mcp-backend-idp-egress.yaml b/helm/agent-platform-connectivity/templates/networkpolicy-mcp-backend-idp-egress.yaml new file mode 100644 index 00000000..3e94ccec --- /dev/null +++ b/helm/agent-platform-connectivity/templates/networkpolicy-mcp-backend-idp-egress.yaml @@ -0,0 +1,37 @@ +{{- /* +Egress to the login identity provider for the in-cluster MCP backends that +validate tokens themselves (networkPolicy.mcpBackends..identityProvider): +the skill-manager's entry carries it from the meta chart. The same rules the +managers' egress policies carry (agent-platform.idpEgress.cilium): the issuer's +hosts by name on 443, and the cluster entity on 443 and 10443 — an issuer whose +name resolves to an in-cluster Gateway (a private installation) is `cluster` at +policy time, which a backend chart's own ipBlock rule never matches on Cilium. +Cilium flavour only, and additive: a backend's own NetworkPolicy keeps its +rules, this one allows more for its pods (podSelector, required). The vanilla +flavour adds nothing: a backend's own ipBlock on 443 is what the managers get +there. +*/ -}} +{{- if and .Values.networkPolicy.enabled (eq (include "agent-platform.networkPolicyFlavor" .) "cilium") }} +{{- range $key, $b := .Values.networkPolicy.mcpBackends }} +{{- with $b.identityProvider }} +{{- if not $b.podSelector }} +{{- fail (printf "networkPolicy.mcpBackends.%s.identityProvider needs the entry's podSelector: the egress policy selects the backend's pods, never its whole namespace" $key) }} +{{- end }} +--- +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: {{ include "name" $ }}-mcp-backend-{{ $key }}-idp-egress + namespace: {{ $b.namespace }} + labels: + {{- include "labels.common" $ | nindent 4 }} +spec: + endpointSelector: + matchLabels: + {{- toYaml $b.podSelector | nindent 6 }} + egress: + {{- include "agent-platform.dnsEgressWithProxy" $ | nindent 4 }} + {{- include "agent-platform.idpEgress.cilium" (dict "provider" (.provider | default "dex") "issuerUrl" .issuerUrl) | trim | nindent 4 }} +{{- end }} +{{- end }} +{{- end }} diff --git a/helm/agent-platform-connectivity/values.schema.json b/helm/agent-platform-connectivity/values.schema.json index 72f1f2a8..fab9b0f8 100644 --- a/helm/agent-platform-connectivity/values.schema.json +++ b/helm/agent-platform-connectivity/values.schema.json @@ -1583,6 +1583,26 @@ } } }, + "identityProvider": { + "type": "object", + "required": [ + "issuerUrl" + ], + "additionalProperties": false, + "properties": { + "issuerUrl": { + "type": "string", + "minLength": 1 + }, + "provider": { + "type": "string", + "enum": [ + "dex", + "google" + ] + } + } + }, "metrics": { "type": "boolean" }, diff --git a/helm/agent-platform-connectivity/values.yaml b/helm/agent-platform-connectivity/values.yaml index d26dc720..65496274 100644 --- a/helm/agent-platform-connectivity/values.yaml +++ b/helm/agent-platform-connectivity/values.yaml @@ -807,7 +807,12 @@ networkPolicy: # app.kubernetes.io/name: envoy # podSelector (a matchLabels map) narrows the policy to the backend's pods; # without it the policy selects every pod in the namespace. - mcpBackends: {} # @schema type: object; additionalProperties: {"type": "object", "required": ["namespace", "ports"], "additionalProperties": false, "properties": {"namespace": {"type": "string", "minLength": 1}, "ports": {"type": "array", "minItems": 1, "items": {"type": "integer"}}, "podSelector": {"type": "object", "additionalProperties": {"type": "string"}}, "metrics": {"type": "boolean"}, "additionalPeers": {"type": "array", "items": {"type": "object", "required": ["namespace", "matchLabels"], "additionalProperties": false, "properties": {"namespace": {"type": "string", "minLength": 1}, "matchLabels": {"type": "object", "minProperties": 1, "additionalProperties": {"type": "string"}}}}}}}; skipProperties: true + # identityProvider ({issuerUrl, provider: dex|google}, cilium flavour) opens + # the backend's egress to the login it validates tokens of, as the managers' + # egress policies do: the issuer's hosts by name on 443 and the cluster + # entity on 443 and 10443 (an issuer behind an in-cluster Gateway). Needs + # podSelector. The meta chart sets it for the skill-manager. + mcpBackends: {} # @schema type: object; additionalProperties: {"type": "object", "required": ["namespace", "ports"], "additionalProperties": false, "properties": {"namespace": {"type": "string", "minLength": 1}, "ports": {"type": "array", "minItems": 1, "items": {"type": "integer"}}, "identityProvider": {"type": "object", "required": ["issuerUrl"], "additionalProperties": false, "properties": {"provider": {"type": "string", "enum": ["dex", "google"]}, "issuerUrl": {"type": "string", "minLength": 1}}}, "podSelector": {"type": "object", "additionalProperties": {"type": "string"}}, "metrics": {"type": "boolean"}, "additionalPeers": {"type": "array", "items": {"type": "object", "required": ["namespace", "matchLabels"], "additionalProperties": false, "properties": {"namespace": {"type": "string", "minLength": 1}, "matchLabels": {"type": "object", "minProperties": 1, "additionalProperties": {"type": "string"}}}}}}}; skipProperties: true # The metrics collectors an mcpBackends entry with `metrics: true` admits on # its ports: the observability platform's alloy-metrics by default. mcpBackendScrapers: # @schema item: object; itemRequired: [namespace, matchLabels]; itemProperties: {"namespace": {"type": "string", "minLength": 1}, "matchLabels": {"type": "object", "minProperties": 1, "additionalProperties": {"type": "string"}}} diff --git a/helm/agent-platform/templates/_helpers.tpl b/helm/agent-platform/templates/_helpers.tpl index 2c045092..ee4735d9 100644 --- a/helm/agent-platform/templates/_helpers.tpl +++ b/helm/agent-platform/templates/_helpers.tpl @@ -4911,10 +4911,38 @@ Usage: include "agent-platform.skillManager.mcpBackend" . | fromJson {{- if and (include "agent-platform.agentManager.viaSkillManager" .) (ne $amNs $ns) -}} {{- $_ := set $out "additionalPeers" (list (dict "namespace" $amNs "matchLabels" (dict "app.kubernetes.io/name" (dig "nameOverride" "agent-manager" (index .Values "agent-manager" | default dict))))) -}} {{- end -}} +{{- with include "agent-platform.skillManager.issuerUrl" . -}} +{{- $_ := set $out "identityProvider" (dict "provider" "dex" "issuerUrl" .) -}} +{{- end -}} {{- end -}} {{- $out | toJson -}} {{- end -}} +{{/* +The issuer the skill-manager validates tokens of, while its OAuth is on: its +own oauth.dex.issuerURL, else global.identity.issuerUrl, else muster's login +(muster.muster.oauth.server.dex.issuerUrl, while that server is on with the dex +provider) — the order its chart and agent-platform.identity.apply resolve it +in. Its MCP backend entry carries it (identityProvider), so the connectivity +chart opens the pods' egress to it as it does for the other managers +(agent-platform.idpEgress.cilium): by name, and the cluster entity on 443 and +10443 for an issuer served through an in-cluster Gateway — on Cilium the +chart's own NetworkPolicy, an ipBlock on 443, matches no in-cluster endpoint. +Empty with its OAuth off or no issuer named. +Usage: include "agent-platform.skillManager.issuerUrl" . +*/}} +{{- define "agent-platform.skillManager.issuerUrl" -}} +{{- $sm := index .Values "skill-manager" | default dict -}} +{{- if dig "oauth" "enabled" false $sm -}} +{{- $server := dig "muster" "oauth" "server" dict (.Values.muster | default dict) -}} +{{- $login := "" -}} +{{- if and (dig "enabled" true $server) (eq (toString (dig "provider" "dex" $server)) "dex") -}} +{{- $login = dig "dex" "issuerUrl" "" $server -}} +{{- end -}} +{{- dig "oauth" "dex" "issuerURL" "" $sm | default (dig "identity" "issuerUrl" "" (.Values.global | default dict)) | default $login -}} +{{- end -}} +{{- end -}} + {{/* The values the default agent's release (components.default-agent) takes from the platform, merged over agents/default-agent/values.yaml: the diff --git a/tests/golden/meta-ci-engine-off.yaml b/tests/golden/meta-ci-engine-off.yaml index fa25e4e3..415d42ce 100644 --- a/tests/golden/meta-ci-engine-off.yaml +++ b/tests/golden/meta-ci-engine-off.yaml @@ -1242,6 +1242,9 @@ spec: namespace: kube-system mcpBackends: skill-manager: + identityProvider: + issuerUrl: https://dex.ci.example.com + provider: dex namespace: default podSelector: app.kubernetes.io/name: skill-manager diff --git a/tests/verify-manager-identity.py b/tests/verify-manager-identity.py index 4d5a46e5..ff6bf2c0 100755 --- a/tests/verify-manager-identity.py +++ b/tests/verify-manager-identity.py @@ -25,10 +25,18 @@ MANAGERS = ("model-manager", "agent-manager", "vm-manager", "cluster-manager", "skill-manager") # Blocks the connectivity release does not receive (components.agent-platform-connectivity.omitKeys). NOT_IN_CONNECTIVITY = ("skill-manager",) +# Components with an oauth block that this script does not render, and where they are covered. +EXEMPT = {"workspace-manager": "needs the workspaces fixture; verify-workspace-manager and verify-idp-egress cover it"} ROUTED = {"model-manager": "/model-manager", "agent-manager": "/agent-manager"} ISSUER = "https://dex.ci.example.com" CLIENT = "muster-acme" SECRET = "muster-oauth" +# agent-platform.idpEgress.cilium for a Dex issuer: its host by name, and the cluster entity on the +# ports an in-cluster Gateway serves it on (a private installation's Dex resolves there). +IDP_EGRESS = [ + {"toFQDNs": [{"matchName": "dex.ci.example.com"}], "toPorts": [{"ports": [{"port": "443", "protocol": "TCP"}]}]}, + {"toEntities": ["cluster"], "toPorts": [{"ports": [{"port": "443", "protocol": "TCP"}, {"port": "10443", "protocol": "TCP"}]}]}, +] def sets(*pairs: str) -> list[str]: @@ -120,6 +128,22 @@ def roster_covered(meta: str) -> None: sys.exit(f"FAIL: roster: {missing} forward an oauth block but are not in agent-platform.identity.apply's list") if not set(MANAGERS) <= with_oauth: sys.exit(f"FAIL: roster: {sorted(set(MANAGERS) - with_oauth)} have no oauth block in values.yaml") + # Every one of them is rendered below (its client and its identity-provider egress), or exempt with a reason. + unchecked = sorted(with_oauth - set(MANAGERS) - set(EXEMPT)) + if unchecked: + sys.exit(f"FAIL: roster: {unchecked} forward an oauth block but are not in MANAGERS: add them, so their login and identity-provider egress are checked") + + +def idp_rules(docs: list[dict], name: str) -> list[dict]: + """The identity-provider egress rules (toFQDNs, the cluster entity) of the Cilium policies selecting 's pods.""" + rules = [] + for d in docs: + if d.get("kind") != "CiliumNetworkPolicy": + continue + if d["spec"].get("endpointSelector", {}).get("matchLabels", {}).get("app.kubernetes.io/name") != name: + continue + rules += [r for r in d["spec"].get("egress", []) if "toFQDNs" in r or "cluster" in r.get("toEntities", [])] + return rules def main() -> None: @@ -157,6 +181,25 @@ def main() -> None: sys.exit("FAIL: derived: model-manager's egress does not reach the derived issuer") print("ok: derived") + print("--> identity-provider egress: every manager's pods reach the login by name and through an in-cluster gateway (cluster on 443 and 10443)") + docs = [d for d in yaml.safe_load_all(result.stdout) if d] + for name in MANAGERS: + rules = idp_rules(docs, name) + for want in IDP_EGRESS: + if want not in rules: + sys.exit(f"FAIL: idp egress: no Cilium policy gives {name}'s pods {want}; it has {rules}") + print("ok: idp egress") + + print("--> skill-manager off: no policy selects its pods") + rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets("components.skill-manager.enabled=false")]) + result = connectivity(conn, rels["agent-platform-connectivity"], base) + if result.returncode != 0: + sys.exit(f"FAIL: skill-manager off: the connectivity render failed\n{result.stderr}") + if any(d.get("kind") == "CiliumNetworkPolicy" and "skill-manager" in d["metadata"]["name"] + for d in yaml.safe_load_all(result.stdout) if d): + sys.exit("FAIL: skill-manager off: a skill-manager policy still renders") + print("ok: skill-manager off") + print("--> agent-manager's route hostname override is its base URL's host; model-manager, which has no route, keeps agentgateway.") rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets("agentManager.route.hostname=agents.ci.example.com")]) expect("agent-manager oauth.baseURL", oauth(rels, "agent-manager").get("baseURL"), "https://agents.ci.example.com/agent-manager") From d6564ab6c9ed50bae1abe240f72db1708ac8a3db Mon Sep 17 00:00:00 2001 From: Jose Armesto Date: Thu, 12 Nov 2026 14:27:24 +0100 Subject: [PATCH 2/4] fix(skill-manager): open the login egress only beside its own NetworkPolicy The identity-provider entry is derived only while skill-manager.networkPolicy.enabled, so the added Cilium policy never makes the pods default-deny alone. muster's login is read through one helper (agent-platform.identity.musterLogin) by agent-platform.identity.apply and the skill-manager's issuer. The pod selector follows skill-manager.nameOverride. Tests pin the issuer order, the off switches, the podSelector guard and the kubernetes flavour. --- Makefile.custom.mk | 2 +- helm/agent-platform/templates/_helpers.tpl | 36 +++++++++++++++------- tests/verify-idp-egress.py | 23 ++++++++++++++ tests/verify-manager-identity.py | 19 ++++++++++-- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/Makefile.custom.mk b/Makefile.custom.mk index 255b86d5..00a88fef 100644 --- a/Makefile.custom.mk +++ b/Makefile.custom.mk @@ -1646,7 +1646,7 @@ verify-substrate-idp-netpol: ## Assert the path to Substrate's actor-JWT issuer @echo "substrate idp network path verified." .PHONY: verify-idp-egress -verify-idp-egress: ## Assert the identity provider egress of the services that validate tokens themselves (giantswarm/agent-platform#1169), cilium flavour: the workspace-, cluster-, agent-, vm- and model-manager egress policies and the portal's open, for an issuer on accounts.google.com, exactly accounts.google.com, www.googleapis.com (JWKS), openidconnect.googleapis.com (userinfo) and oauth2.googleapis.com (token) on 443, whatever provider their block names; for a Dex issuer its host alone. HELM selects the binary. +verify-idp-egress: ## Assert the identity provider egress of the services that validate tokens themselves (giantswarm/agent-platform#1169), cilium flavour: the workspace-, cluster-, agent-, vm- and model-manager egress policies and the portal's open, for an issuer on accounts.google.com, exactly accounts.google.com, www.googleapis.com (JWKS), openidconnect.googleapis.com (userinfo) and oauth2.googleapis.com (token) on 443, whatever provider their block names; for a Dex issuer its host alone. An MCP backend entry with identityProvider (the skill-manager's) gets the same rules for its pods, the cluster entity on 443 and 10443 included, fails the render without a podSelector, and renders nothing in the kubernetes flavour. HELM selects the binary. @echo "====> $@ ($(CONNECTIVITY_DIR))" @python3 tests/verify-idp-egress.py $(CONNECTIVITY_DIR) @echo "identity provider egress verified." diff --git a/helm/agent-platform/templates/_helpers.tpl b/helm/agent-platform/templates/_helpers.tpl index ee4735d9..4bd937bc 100644 --- a/helm/agent-platform/templates/_helpers.tpl +++ b/helm/agent-platform/templates/_helpers.tpl @@ -4327,11 +4327,7 @@ Usage: include "agent-platform.identity.apply" (dict "values" $shaped) {{- $global := index $v "global" | default dict -}} {{- $identity := dig "identity" dict $global -}} {{- $domain := dig "domain" "" $global -}} -{{- $server := dig "muster" "oauth" "server" dict (index $v "muster" | default dict) -}} -{{- $login := dict -}} -{{- if and (dig "enabled" true $server) (eq (toString (dig "provider" "dex" $server)) "dex") -}} -{{- $login = dict "issuerURL" (dig "dex" "issuerUrl" "" $server) "clientID" (dig "dex" "clientId" "" $server) "existingSecret" (dig "existingSecret" "" $server) -}} -{{- end -}} +{{- $login := include "agent-platform.identity.musterLogin" $v | fromJson -}} {{- range $name, $wiring := dict "model-manager" "modelManager" "agent-manager" "agentManager" "vm-manager" "" "cluster-manager" "" "workspace-manager" "" "skill-manager" "" -}} {{- $block := index $v $name -}} {{- if and (kindIs "map" $block) (kindIs "map" (index $block "oauth")) (dig "oauth" "enabled" false $block) -}} @@ -4906,15 +4902,20 @@ Usage: include "agent-platform.skillManager.mcpBackend" . | fromJson {{- if include "agent-platform.componentEnabled" (dict "root" . "name" "skill-manager") -}} {{- $sm := index .Values "skill-manager" | default dict -}} {{- $ns := dig "skill-manager" "targetNamespace" "" .Values.components | default (include "agent-platform.targetNamespace" .) -}} -{{- $out = dict "namespace" $ns "ports" (list (int (dig "service" "port" 8080 $sm))) "podSelector" (dict "app.kubernetes.io/name" "skill-manager") -}} +{{- $out = dict "namespace" $ns "ports" (list (int (dig "service" "port" 8080 $sm))) "podSelector" (dict "app.kubernetes.io/name" (dig "nameOverride" "skill-manager" $sm)) -}} {{- $amNs := dig "agent-manager" "targetNamespace" "" .Values.components | default (include "agent-platform.targetNamespace" .) -}} {{- if and (include "agent-platform.agentManager.viaSkillManager" .) (ne $amNs $ns) -}} {{- $_ := set $out "additionalPeers" (list (dict "namespace" $amNs "matchLabels" (dict "app.kubernetes.io/name" (dig "nameOverride" "agent-manager" (index .Values "agent-manager" | default dict))))) -}} {{- end -}} +{{- /* Only while the chart's own NetworkPolicy selects the pods: the entry's +egress policy only adds to it, and alone it would deny the pods' other egress +(GitHub, the registries, OTLP). */ -}} +{{- if dig "networkPolicy" "enabled" true $sm -}} {{- with include "agent-platform.skillManager.issuerUrl" . -}} {{- $_ := set $out "identityProvider" (dict "provider" "dex" "issuerUrl" .) -}} {{- end -}} {{- end -}} +{{- end -}} {{- $out | toJson -}} {{- end -}} @@ -4934,13 +4935,26 @@ Usage: include "agent-platform.skillManager.issuerUrl" . {{- define "agent-platform.skillManager.issuerUrl" -}} {{- $sm := index .Values "skill-manager" | default dict -}} {{- if dig "oauth" "enabled" false $sm -}} -{{- $server := dig "muster" "oauth" "server" dict (.Values.muster | default dict) -}} -{{- $login := "" -}} -{{- if and (dig "enabled" true $server) (eq (toString (dig "provider" "dex" $server)) "dex") -}} -{{- $login = dig "dex" "issuerUrl" "" $server -}} +{{- $login := include "agent-platform.identity.musterLogin" .Values | fromJson -}} +{{- dig "oauth" "dex" "issuerURL" "" $sm | default (dig "identity" "issuerUrl" "" (.Values.global | default dict)) | default ($login.issuerURL | default "") -}} {{- end -}} -{{- dig "oauth" "dex" "issuerURL" "" $sm | default (dig "identity" "issuerUrl" "" (.Values.global | default dict)) | default $login -}} {{- end -}} + +{{/* +muster's login, the platform's one login, as the managers take it: the +issuer, client and Secret of muster.muster.oauth.server while that server is on +with the dex provider; {} otherwise. Read by agent-platform.identity.apply and +agent-platform.skillManager.issuerUrl, so the issuer a manager runs with and the +one its egress opens follow one rule. +Usage: include "agent-platform.identity.musterLogin" $values | fromJson +*/}} +{{- define "agent-platform.identity.musterLogin" -}} +{{- $server := dig "muster" "oauth" "server" dict (index . "muster" | default dict) -}} +{{- $login := dict -}} +{{- if and (dig "enabled" true $server) (eq (toString (dig "provider" "dex" $server)) "dex") -}} +{{- $login = dict "issuerURL" (dig "dex" "issuerUrl" "" $server) "clientID" (dig "dex" "clientId" "" $server) "existingSecret" (dig "existingSecret" "" $server) -}} +{{- end -}} +{{- $login | toJson -}} {{- end -}} {{/* diff --git a/tests/verify-idp-egress.py b/tests/verify-idp-egress.py index 0fda5cc3..d94a538e 100755 --- a/tests/verify-idp-egress.py +++ b/tests/verify-idp-egress.py @@ -75,6 +75,29 @@ def main() -> int: if hosts != [DEX]: fail(f"a Dex issuer: {name} opens {hosts}, expected [{DEX!r}] alone") ok(f"a Dex issuer: each policy opens {DEX} alone and no Google host") + + # An MCP backend entry with identityProvider (the skill-manager's, from the meta chart): + # its pods get the same rules, cilium only, and never a whole namespace. + entry = ["--set", "networkPolicy.mcpBackends.x.namespace=mcp-x", "--set", "networkPolicy.mcpBackends.x.ports[0]=8080", + "--set", f"networkPolicy.mcpBackends.x.identityProvider.issuerUrl=https://{DEX}"] + selector = ["--set", "networkPolicy.mcpBackends.x.podSelector.app\\.kubernetes\\.io/name=x"] + base = [HELM, "template", "t", chart, *FLAGS, "--set", f"global.identity.issuerUrl=https://{DEX}", *entry] + name = f"{PREFIX}-mcp-backend-x-idp-egress" + r = subprocess.run([*base, *selector], capture_output=True, text=True) + if r.returncode != 0: + fail(f"an MCP backend with identityProvider: the render failed\n{r.stderr}") + doc = next((d for d in r.stdout.split("\n---\n") if re.search(rf"^ name: {re.escape(name)}$", d, re.M)), None) + if doc is None or IDP_HOSTS.findall(doc) != [DEX] or '- port: "10443"' not in doc or "- cluster" not in doc: + fail(f"an MCP backend with identityProvider: {name} does not open {DEX} and the cluster entity on 443 and 10443\n{doc}") + ok(f"an MCP backend with identityProvider: {name} opens {DEX} and the cluster entity on 443 and 10443") + r = subprocess.run(base, capture_output=True, text=True) + if r.returncode == 0 or "needs the entry's podSelector" not in r.stderr: + fail(f"an MCP backend with identityProvider and no podSelector did not fail the render\n{r.stderr}") + ok("an MCP backend with identityProvider and no podSelector fails the render") + r = subprocess.run([*base, *selector, "--set", "networkPolicy.flavor=kubernetes"], capture_output=True, text=True) + if r.returncode != 0 or name in r.stdout: + fail(f"kubernetes flavour: the render failed or still has {name}\n{r.stderr}") + ok("kubernetes flavour: an MCP backend's identityProvider renders nothing") return 0 diff --git a/tests/verify-manager-identity.py b/tests/verify-manager-identity.py index ff6bf2c0..ce4e0e93 100755 --- a/tests/verify-manager-identity.py +++ b/tests/verify-manager-identity.py @@ -195,11 +195,24 @@ def main() -> None: result = connectivity(conn, rels["agent-platform-connectivity"], base) if result.returncode != 0: sys.exit(f"FAIL: skill-manager off: the connectivity render failed\n{result.stderr}") - if any(d.get("kind") == "CiliumNetworkPolicy" and "skill-manager" in d["metadata"]["name"] - for d in yaml.safe_load_all(result.stdout) if d): - sys.exit("FAIL: skill-manager off: a skill-manager policy still renders") + if idp_rules([d for d in yaml.safe_load_all(result.stdout) if d], "skill-manager"): + sys.exit("FAIL: skill-manager off: a policy still gives its pods identity-provider egress") print("ok: skill-manager off") + print("--> skill-manager's identity provider entry: the issuer it runs with, only while its OAuth and its own NetworkPolicy are on") + def entry(*extra: str) -> dict | None: + rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets(*extra)]) + return rels["agent-platform-connectivity"]["networkPolicy"]["mcpBackends"]["skill-manager"].get("identityProvider") + for what, extra, want in ( + ("muster's login", (), ISSUER), + ("global.identity wins over muster's", ("global.identity.issuerUrl=https://global.example.com",), "https://global.example.com"), + ("its own issuer wins", ("global.identity.issuerUrl=https://global.example.com", "skill-manager.oauth.dex.issuerURL=https://own.example.com"), "https://own.example.com"), + ): + expect(f"skill-manager identityProvider, {what}", entry(*extra), {"provider": "dex", "issuerUrl": want}) + expect("skill-manager identityProvider with its OAuth off", entry("skill-manager.oauth.enabled=false"), None) + expect("skill-manager identityProvider with its NetworkPolicy off", entry("skill-manager.networkPolicy.enabled=false"), None) + print("ok: skill-manager's identity provider entry") + print("--> agent-manager's route hostname override is its base URL's host; model-manager, which has no route, keeps agentgateway.") rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets("agentManager.route.hostname=agents.ci.example.com")]) expect("agent-manager oauth.baseURL", oauth(rels, "agent-manager").get("baseURL"), "https://agents.ci.example.com/agent-manager") From ee13ec242a3e05bf3c3b681c0bbf48bfde6153f9 Mon Sep 17 00:00:00 2001 From: Jose Armesto Date: Thu, 12 Nov 2026 14:33:19 +0100 Subject: [PATCH 3/4] fix(skill-manager): select its pods by the chart's own name rule The MCP backend entry's podSelector follows skill-manager.name: nameOverride, an empty one meaning skill-manager, cut to 63 characters without a trailing hyphen. An explicitly empty nameOverride no longer gives app.kubernetes.io/name: "", which selected no pod and left the skill-manager's ingress open. --- helm/agent-platform/templates/_helpers.tpl | 13 ++++++++++++- tests/verify-manager-identity.py | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/helm/agent-platform/templates/_helpers.tpl b/helm/agent-platform/templates/_helpers.tpl index 4bd937bc..6a7fdd86 100644 --- a/helm/agent-platform/templates/_helpers.tpl +++ b/helm/agent-platform/templates/_helpers.tpl @@ -4902,7 +4902,7 @@ Usage: include "agent-platform.skillManager.mcpBackend" . | fromJson {{- if include "agent-platform.componentEnabled" (dict "root" . "name" "skill-manager") -}} {{- $sm := index .Values "skill-manager" | default dict -}} {{- $ns := dig "skill-manager" "targetNamespace" "" .Values.components | default (include "agent-platform.targetNamespace" .) -}} -{{- $out = dict "namespace" $ns "ports" (list (int (dig "service" "port" 8080 $sm))) "podSelector" (dict "app.kubernetes.io/name" (dig "nameOverride" "skill-manager" $sm)) -}} +{{- $out = dict "namespace" $ns "ports" (list (int (dig "service" "port" 8080 $sm))) "podSelector" (dict "app.kubernetes.io/name" (include "agent-platform.skillManager.name" $sm)) -}} {{- $amNs := dig "agent-manager" "targetNamespace" "" .Values.components | default (include "agent-platform.targetNamespace" .) -}} {{- if and (include "agent-platform.agentManager.viaSkillManager" .) (ne $amNs $ns) -}} {{- $_ := set $out "additionalPeers" (list (dict "namespace" $amNs "matchLabels" (dict "app.kubernetes.io/name" (dig "nameOverride" "agent-manager" (index .Values "agent-manager" | default dict))))) -}} @@ -4919,6 +4919,17 @@ egress policy only adds to it, and alone it would deny the pods' other egress {{- $out | toJson -}} {{- end -}} +{{/* +The skill-manager pods' app.kubernetes.io/name label, as its chart's +skill-manager.name renders it: nameOverride, an empty one meaning the chart +name, cut to 63 characters without a trailing hyphen. The MCP backend entry's +podSelector, so its ingress and egress policies select the running pods. +Usage: include "agent-platform.skillManager.name" (index .Values "skill-manager" | default dict) +*/}} +{{- define "agent-platform.skillManager.name" -}} +{{- dig "nameOverride" "" . | default "skill-manager" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + {{/* The issuer the skill-manager validates tokens of, while its OAuth is on: its own oauth.dex.issuerURL, else global.identity.issuerUrl, else muster's login diff --git a/tests/verify-manager-identity.py b/tests/verify-manager-identity.py index ce4e0e93..890b849c 100755 --- a/tests/verify-manager-identity.py +++ b/tests/verify-manager-identity.py @@ -213,6 +213,14 @@ def entry(*extra: str) -> dict | None: expect("skill-manager identityProvider with its NetworkPolicy off", entry("skill-manager.networkPolicy.enabled=false"), None) print("ok: skill-manager's identity provider entry") + print("--> skill-manager's pod selector is its chart's name label: nameOverride, an empty one meaning the chart name, cut to 63 without a trailing hyphen") + long = "s" * 62 + "-x" + for override, want in (("", "skill-manager"), ("sm", "sm"), (long, "s" * 62)): + rels = releases(meta, [*base, *ALL_ON, *LOGIN, "--set-string", f"skill-manager.nameOverride={override}"]) + got = rels["agent-platform-connectivity"]["networkPolicy"]["mcpBackends"]["skill-manager"].get("podSelector") + expect(f"skill-manager podSelector with nameOverride {override!r}", got, {"app.kubernetes.io/name": want}) + print("ok: skill-manager's pod selector") + print("--> agent-manager's route hostname override is its base URL's host; model-manager, which has no route, keeps agentgateway.") rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets("agentManager.route.hostname=agents.ci.example.com")]) expect("agent-manager oauth.baseURL", oauth(rels, "agent-manager").get("baseURL"), "https://agents.ci.example.com/agent-manager") From f701b6421c5db924d8f00b37102fbb863705f6b7 Mon Sep 17 00:00:00 2001 From: Jose Armesto Date: Thu, 12 Nov 2026 14:48:51 +0100 Subject: [PATCH 4/4] test(skill-manager): expect the login in its MCP backend entry verify-default-agent pins the skill-manager's MCP backend entry; it now carries identityProvider. --- tests/verify-default-agent.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/verify-default-agent.py b/tests/verify-default-agent.py index d1e42d92..13be2c92 100755 --- a/tests/verify-default-agent.py +++ b/tests/verify-default-agent.py @@ -304,7 +304,9 @@ def package(tmp: str, version: str, stamp: bool) -> str: "muster.mcpServer": (v["muster"]["mcpServer"], {"enabled": True, "auth": {"forwardToken": True, "requiredAudiences": ["dex-k8s-authenticator"]}}), "oauth.enabled": (v["oauth"]["enabled"], True), "MCP backend": (find(docs, "HelmRelease", "agent-platform-connectivity")["spec"]["values"]["networkPolicy"]["mcpBackends"]["skill-manager"], - {"namespace": "agent-platform", "ports": [8080], "podSelector": {"app.kubernetes.io/name": "skill-manager"}}), + {"namespace": "agent-platform", "ports": [8080], "podSelector": {"app.kubernetes.io/name": "skill-manager"}, + # Its login, for its identity-provider egress (verify-managers pins the issuer order). + "identityProvider": {"provider": "dex", "issuerUrl": "https://dex.example.com"}}), } for what, (got, want) in checks.items(): if got != want: