Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- /*
Egress to the login identity provider for the in-cluster MCP backends that
validate tokens themselves (networkPolicy.mcpBackends.<key>.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 }}
20 changes: 20 additions & 0 deletions helm/agent-platform-connectivity/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
7 changes: 6 additions & 1 deletion helm/agent-platform-connectivity/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}
Expand Down
65 changes: 59 additions & 6 deletions helm/agent-platform/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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) -}}
Expand Down Expand Up @@ -4906,15 +4902,72 @@ 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" (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))))) -}}
{{- 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 -}}

{{/*
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
(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 -}}
{{- $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 -}}
{{- 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 -}}

{{/*
The values the default agent's release (components.default-agent)
takes from the platform, merged over agents/default-agent/values.yaml: the
Expand Down
3 changes: 3 additions & 0 deletions tests/golden/meta-ci-engine-off.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/verify-default-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions tests/verify-idp-egress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading
Loading