mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 07:03:45 +09:00
Defaults set by the administrator have to reach every application kind, including ones from external catalogs, and give the same result for the dashboard, Terraform and kubectl, so the merge runs in the API server on create instead of in each client. User values win over installation defaults, which win over the developer defaults of the chart. Only objects with declared properties merge recursively. Arrays, dictionaries and free-form objects are replaced whole, so a pool that sets its own registry mirrors never receives the platform entries. The entry is checked against the application's OpenAPI schema before merging. CEL rules are left out of that check, since a rule such as an immutability test has no meaning on a partial object. The ConfigMap is read through a cache limited to that one object, so the API does not hold a watch on every ConfigMap in the cluster. A missing ConfigMap means no defaults. One that cannot be read, or an invalid configuration or entry, skips the defaults and the create goes on with a warning, because a configuration mistake must not stop applications from being created. Updates never apply defaults. The ConfigMap rule the API already has covers the read, and its comment now names this second user. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
98 lines
4.2 KiB
YAML
98 lines
4.2 KiB
YAML
kind: ClusterRole
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
metadata:
|
|
name: cozystack-api
|
|
rules:
|
|
- apiGroups: [""]
|
|
resources: ["namespaces", "secrets", "services"]
|
|
verbs: ["get", "watch", "list"]
|
|
# Hierarchical tenant quota admission reads the rendered ResourceQuota usage of
|
|
# a parent tenant's pool to carve a child's allocation out of what is actually
|
|
# left (see pkg/registry/apps/application/quota.go).
|
|
- apiGroups: [""]
|
|
resources: ["resourcequotas"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["rbac.authorization.k8s.io"]
|
|
resources: ["rolebindings"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: [""]
|
|
resources: ["secrets"]
|
|
verbs: ["create", "update", "patch", "delete"]
|
|
# A mint or revoke records an Event on the application naming the account and
|
|
# the caller, never the value.
|
|
- apiGroups: [""]
|
|
resources: ["events"]
|
|
verbs: ["create"]
|
|
- apiGroups: ["admissionregistration.k8s.io"]
|
|
resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations", "validatingadmissionpolicies", "validatingadmissionpolicybindings"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["flowcontrol.apiserver.k8s.io"]
|
|
resources: ["prioritylevelconfigurations", "flowschemas"]
|
|
verbs: ["list", "watch"]
|
|
- apiGroups: ["cozystack.io"]
|
|
resources: ["*"]
|
|
verbs: ["get", "watch", "list"]
|
|
# Marketplace Tap resource: disconnecting a tap deletes its (cluster-scoped)
|
|
# PackageSource and the tap-managed registration Package that de-registers its
|
|
# apps. The tap's Flux OCIRepository is read here for List/Get/Watch; its write
|
|
# verbs are scoped to a namespaced Role in cozy-system (see tap-source-role.yaml),
|
|
# since the API only ever manages tap sources there.
|
|
- apiGroups: ["cozystack.io"]
|
|
resources: ["packagesources", "packages"]
|
|
verbs: ["delete"]
|
|
- apiGroups: ["source.toolkit.fluxcd.io"]
|
|
resources: ["ocirepositories"]
|
|
verbs: ["get", "list", "watch"]
|
|
- apiGroups: ["helm.toolkit.fluxcd.io"]
|
|
resources: ["*"]
|
|
verbs: ["*"]
|
|
# Read-only sources for the Option (dropdown) resource providers.
|
|
- apiGroups: [""]
|
|
resources: ["nodes", "persistentvolumeclaims"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["kubevirt.io"]
|
|
resources: ["kubevirts"]
|
|
verbs: ["get", "watch", "list"]
|
|
# The image picker drops golden images whose import failed or keeps failing.
|
|
- apiGroups: ["cdi.kubevirt.io"]
|
|
resources: ["datavolumes"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["instancetype.kubevirt.io"]
|
|
resources: ["virtualmachineclusterinstancetypes", "virtualmachineclusterpreferences"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["k8s.cni.cncf.io"]
|
|
resources: ["network-attachment-definitions"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["storage.k8s.io"]
|
|
resources: ["storageclasses"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["backups.cozystack.io"]
|
|
resources: ["backupclasses", "plans", "backups"]
|
|
verbs: ["get", "watch", "list"]
|
|
- apiGroups: ["apps.cozystack.io"]
|
|
resources: ["vmdisks"]
|
|
verbs: ["get", "watch", "list"]
|
|
# The sourceRef picker on a VMImportTask is an Option provider, which lists
|
|
# the sources through the dynamic client under this ServiceAccount. Without
|
|
# the group here the provider registers and then answers with an empty list,
|
|
# so the form offers no connection to import from.
|
|
- apiGroups: ["forklift.cozystack.io"]
|
|
resources: ["vmimportsources"]
|
|
verbs: ["get", "watch", "list"]
|
|
# The VM picker reads the machine list the migration controller publishes for
|
|
# each source. Read-only, and only ever fetched by a name derived from the
|
|
# source the tenant already chose. The create path also keeps a cache of the
|
|
# ConfigMap cozy-system/cozystack-application-defaults for installation
|
|
# defaults. The cache asks the server for that one object with a metadata.name
|
|
# field selector, which a Role with resourceNames could match, but this rule
|
|
# covers every ConfigMap. Without it every create waits up to five seconds for
|
|
# the cache, then goes on without defaults and returns a warning.
|
|
- apiGroups: [""]
|
|
resources: ["configmaps"]
|
|
verbs: ["get", "watch", "list"]
|
|
# The SecurityGroup resource is a projection over CiliumNetworkPolicy: the
|
|
# storage CRUDs these objects with the cozystack-api ServiceAccount.
|
|
- apiGroups: ["cilium.io"]
|
|
resources: ["ciliumnetworkpolicies"]
|
|
verbs: ["get", "watch", "list", "create", "update", "patch", "delete"]
|