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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The right to manage `Organization` objects is bound by the installation: it bind
In the namespace the operator keeps, from the first reconcile on:

- the network policies `networkPolicy.names`, copied from `platformNamespace`;
- the agent chart's OCIRepository (`agentChart.*`), named after the chart (`agent`);
- the agent chart's OCIRepository (`agentChart.*`), named after the chart (`agent`). Every reconcile resets its `spec.url`, `spec.interval` and `spec.ref` to `agentChart.*` (other fields and labels stay). A move of `spec.ref` to a higher major (`2.x` to `3.x`) waits per organization until agent-manager's migrate sets `agent-platform.giantswarm.io/agent-chart-ready-major` to the new major on the report ConfigMap (`agentChart.migrationReport`), with `agent-platform.giantswarm.io/agent-chart-ready-releases` naming every HelmRelease on the source and `agent-platform.giantswarm.io/agent-chart-ready-release-versions` recording each one's UID and `metadata.generation` as the run left it. A release recreated under the same name or whose spec changed after the run (or a mark without the versions) holds the move, naming the release, until migrate runs again; an organization with no HelmRelease on the source moves at once. While it waits the organization is not Ready (`ChartSourceHeld`) and is rechecked every `agentChart.migrationPoll`. A range of no release major (a pre-release alone) or of several (`>=2.6.0`) creates and moves no source: `ChartRangeInvalid`. Organizations do not pin their own chart version;
- the Helm ServiceAccount `helmReleaseServiceAccount`, which the organization's HelmReleases run as, with a RoleBinding to the ClusterRole `agent-platform-tenant-flux`;
- the RoleBinding `organization-admins`, which binds the ClusterRole `agent-platform:admin` to the Users and Groups of the organization's `spec.admins`, in their order. It follows the list while the Agent Platform is on, and an edit of it is reverted. With no admins the operator empties its binding and deletes it (emptied first, so a finalizer that holds the binding keeps no access), the organization has no such binding, and that is no error: the platform team manages the organization. A RoleBinding `organization-admins` that the operator did not write is left as it is, and the organization is `AgentPlatformReady=False NameTaken` while it has admins. The operator writes no binding in other namespaces from the list (no `cluster-admin`);
- the ResourceQuota `agent-platform-organization-objects` on object counts (`objectQuota`), so one organization cannot flood the API server with objects;
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/giantswarm/agent-platform-operator
go 1.26.0

require (
github.com/Masterminds/semver/v3 v3.4.0
github.com/aws/aws-sdk-go-v2 v1.48.2
github.com/aws/aws-sdk-go-v2/config v1.33.23
github.com/aws/aws-sdk-go-v2/service/s3 v1.117.0
Expand Down
4 changes: 3 additions & 1 deletion helm/agent-platform-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Reconciles each Organization (security.giantswarm.io) with the Agent Platform en
| platformNamespace | string | `"kagent"` | The platform namespace (kagent's) the network policies are copied from. |
| networkPolicy.flavor | string | `""` | Kind of the network policies copied into every organization namespace: `kubernetes` (NetworkPolicy) or `cilium` (CiliumNetworkPolicy). Empty copies none. |
| networkPolicy.names | list | `[]` | Names of the network policies in `platformNamespace` copied into every organization namespace (the platform's worker policy, `substrate-workers` with Cilium, `substrate-workers-ingress` with Kubernetes network policies). |
| agentChart.ociUrl | string | `"oci://gsoci.azurecr.io/charts/giantswarm/agent"` | OCI URL of the agent chart. The OCIRepository kept in every organization namespace is named after its last segment (`agent`); the organization's HelmReleases reference it by that name. Empty keeps none. |
| agentChart.ociUrl | string | `"oci://gsoci.azurecr.io/charts/giantswarm/agent"` | OCI URL of the agent chart. The OCIRepository kept in every organization namespace is named after its last segment (`agent`); the organization's HelmReleases reference it by that name. Every reconcile resets its url, interval and ref to these values. Empty keeps none. |
| agentChart.semver | string | `"2.x"` | Semver range the OCIRepository tracks. |
| agentChart.semverFilter | string | `""` | Regular expression the chart's tags must match before the range is evaluated (the OCIRepository's `ref.semverFilter`); empty filters nothing. |
| agentChart.interval | string | `"30m"` | OCIRepository.spec.interval. |
| agentChart.ociRepositoryApiVersion | string | `"source.toolkit.fluxcd.io/v1"` | source.toolkit.fluxcd.io API version of the OCIRepository. |
| agentChart.migrationReport | string | `"agent-manager-migrate-report"` | agent-manager migrate's report ConfigMap in an organization namespace. A move to a higher major (`2.x` to `3.x`) waits until migrate annotates it `agent-platform.giantswarm.io/agent-chart-ready-major` with the new major (organization not Ready, `ChartSourceHeld`, meanwhile). The operator reads this one ConfigMap name only. |
| agentChart.migrationPoll | string | `"1m"` | How often a waiting organization looks for migrate's annotation again. |
| helmReleaseServiceAccount | string | `"kagent-flux"` | The ServiceAccount the organization's HelmReleases run as (`spec.serviceAccountName`, which helm-controller impersonates), kept in every organization namespace and bound there to the ClusterRole `agent-platform-tenant-flux`. The same name as agent-manager's `flux.helmReleaseServiceAccount`. Empty keeps none. |
| serviceAccountBindings | list | `[]` | ClusterRoles bound to a ServiceAccount of another namespace in every organization namespace, such as Substrate's credential providers' Secret readers, which read the Secret an actor's credential names there. Each ClusterRole is bound by a RoleBinding named after it (listed once, not the Helm or Flux binding's name), and the operator gets `bind` on it; a ClusterRole removed from the list loses its bindings. The agent-platform chart's admission policy holds which ServiceAccounts the operator binds there. |
| snapshots.bucket | string | `""` | Bucket of the organizations' worker snapshots: an organization's `status.capabilities.agentPlatform.snapshotPrefix` is `s3://<bucket>/<uid>`. Empty leaves it empty. |
Expand Down
2 changes: 2 additions & 0 deletions helm/agent-platform-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
{{- end }}
- --ocirepository-interval={{ .Values.agentChart.interval }}
- --flux-ocirepository-api-version={{ .Values.agentChart.ociRepositoryApiVersion }}
- --agent-chart-migration-report={{ .Values.agentChart.migrationReport }}
- --agent-chart-migration-poll={{ .Values.agentChart.migrationPoll }}
- --helmrelease-service-account={{ .Values.helmReleaseServiceAccount }}
{{- with .Values.serviceAccountBindings }}
- {{ printf "--service-account-bindings=%s" (include "serviceAccountBindings" $) | quote }}
Expand Down
22 changes: 21 additions & 1 deletion helm/agent-platform-operator/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ The operator's own permissions.

RBAC cannot select namespaces by label, so the ClusterRole lets the
ServiceAccount create namespaces and write RoleBindings, ServiceAccounts,
OCIRepositories, network policies and ResourceQuotas in every namespace, and
OCIRepositories (updates only of the agent chart's name), network policies
and ResourceQuotas in every namespace, and
with curated.enabled write and delete Agents, AgentTemplates, Harnesses,
RemoteMCPServers and WorkerPools in every namespace, the platform namespace's
curated sources included. The erasure of a deleted organization deletes
Expand Down Expand Up @@ -87,9 +88,26 @@ rules:
resources: ["serviceaccounts"]
verbs: ["update"]
{{- end }}
{{- with .Values.agentChart.ociUrl }}
# The agent chart's OCIRepository: created, and brought back to
# agentChart.* on every reconcile. RBAC cannot name the object of a create;
# an update is held to the chart's name (the last segment of
# agentChart.ociUrl), so without the platform chart's scope policy a leaked
# token still cannot repoint another Flux source.
- apiGroups: ["source.toolkit.fluxcd.io"]
resources: ["ocirepositories"]
verbs: ["get", "create"]
- apiGroups: ["source.toolkit.fluxcd.io"]
resources: ["ocirepositories"]
resourceNames: [{{ base . | quote }}]
verbs: ["update"]
# agent-manager migrate's report, read before the source moves to a higher
# agent chart major (agentChart.migrationReport); no other ConfigMap.
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: [{{ $.Values.agentChart.migrationReport | quote }}]
verbs: ["get"]
{{- end }}
# The organization's Flux Kustomization: kept in commit mode, deleted by
# the erasure; with the installation's set, the one that applied each
# organization is read for the AgentPlatformOrphaned condition, in any
Expand All @@ -109,6 +127,8 @@ rules:
- "create"
- "update"
{{- end }}
# The HelmReleases are listed too before a move of the chart source to a
# higher major: one with no release on it moves without migrate's mark.
- apiGroups: ["helm.toolkit.fluxcd.io"]
resources: ["helmreleases"]
verbs: ["list", "delete"]
Expand Down
10 changes: 9 additions & 1 deletion helm/agent-platform-operator/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@
"type": "string",
"description": "OCIRepository.spec.interval."
},
"migrationPoll": {
"type": "string",
"description": "How often a waiting organization looks for migrate's annotation again."
},
"migrationReport": {
"type": "string",
"description": "agent-manager migrate's report ConfigMap in an organization namespace. A move to a higher major (`2.x` to `3.x`) waits until migrate annotates it `agent-platform.giantswarm.io/agent-chart-ready-major` with the new major (organization not Ready, `ChartSourceHeld`, meanwhile). The operator reads this one ConfigMap name only."
},
"ociRepositoryApiVersion": {
"type": "string",
"description": "source.toolkit.fluxcd.io API version of the OCIRepository."
},
"ociUrl": {
"type": "string",
"description": "OCI URL of the agent chart. The OCIRepository kept in every organization namespace is named after its last segment (`agent`); the organization's HelmReleases reference it by that name. Empty keeps none."
"description": "OCI URL of the agent chart. The OCIRepository kept in every organization namespace is named after its last segment (`agent`); the organization's HelmReleases reference it by that name. Every reconcile resets its url, interval and ref to these values. Empty keeps none."
},
"semver": {
"type": "string",
Expand Down
11 changes: 10 additions & 1 deletion helm/agent-platform-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ networkPolicy:
agentChart:
# -- OCI URL of the agent chart. The OCIRepository kept in every
# organization namespace is named after its last segment (`agent`); the
# organization's HelmReleases reference it by that name. Empty keeps none.
# organization's HelmReleases reference it by that name. Every reconcile
# resets its url, interval and ref to these values. Empty keeps none.
ociUrl: oci://gsoci.azurecr.io/charts/giantswarm/agent
# -- Semver range the OCIRepository tracks.
semver: "2.x"
Expand All @@ -42,6 +43,14 @@ agentChart:
interval: 30m
# -- source.toolkit.fluxcd.io API version of the OCIRepository.
ociRepositoryApiVersion: source.toolkit.fluxcd.io/v1
# -- agent-manager migrate's report ConfigMap in an organization namespace.
# A move to a higher major (`2.x` to `3.x`) waits until migrate annotates it
# `agent-platform.giantswarm.io/agent-chart-ready-major` with the new major
# (organization not Ready, `ChartSourceHeld`, meanwhile). The operator reads
# this one ConfigMap name only.
migrationReport: agent-manager-migrate-report
# -- How often a waiting organization looks for migrate's annotation again.
migrationPoll: 1m

# -- The ServiceAccount the organization's HelmReleases run as
# (`spec.serviceAccountName`, which helm-controller impersonates), kept in
Expand Down
Loading
Loading