Documentation
¶
Overview ¶
Package k8s wraps all Kubernetes access. Everything goes through the user's kubeconfig and client-go — donkey never shells out to kubectl.
Index ¶
- Variables
- func Ping(ctx context.Context, kubeContext string) (string, error)
- type AppRef
- type Client
- func (c *Client) AppNetwork(ctx context.Context, namespace, objectName, space, app string) (*rt.NetworkState, error)
- func (c *Client) AppStatus(ctx context.Context, namespace, objectName, space, app string) (*rt.AppStatus, error)
- func (c *Client) Apply(ctx context.Context, objs []runtime.Object) error
- func (c *Client) CheckNamespaceFree(ctx context.Context, namespace, space string) error
- func (c *Client) Confined() bool
- func (c *Client) DeleteAddon(ctx context.Context, namespace, space, addon string, keepData bool) error
- func (c *Client) DeleteAppResources(ctx context.Context, namespace, space, app string, keepData bool) error
- func (c *Client) DeleteAppRoute(ctx context.Context, namespace, space, app string) error
- func (c *Client) DeleteAppTraffic(ctx context.Context, namespace, space, app string) error
- func (c *Client) DeleteLegacySystemConfig(ctx context.Context, namespace string) error
- func (c *Client) DeleteObject(ctx context.Context, kind, namespace, name string, identity map[string]string) error
- func (c *Client) DeleteObsoleteAppTraffic(ctx context.Context, namespace, space, app string, ...) error
- func (c *Client) DeleteObsoleteSystemTraffic(ctx context.Context, namespace string, keepCertificate, keepDNS bool) error
- func (c *Client) DeleteSpace(ctx context.Context, namespace, space string) error
- func (c *Client) DeleteSpaceIsolation(ctx context.Context, namespace, space string) error
- func (c *Client) DeleteSpaceObjects(ctx context.Context, namespace, space string) error
- func (c *Client) DeleteSpaceTraffic(ctx context.Context, namespace, space string) error
- func (c *Client) DeploymentAnnotation(ctx context.Context, namespace, name, space, app, key string) (string, error)
- func (c *Client) DeploymentIdentity(ctx context.Context, namespace, name string) (map[string]string, bool, error)
- func (c *Client) DetachAddon(ctx context.Context, namespace, space, app, addon string) error
- func (c *Client) ForInstallation(system, workload string) *Client
- func (c *Client) GetEnv(ctx context.Context, namespace, space, app, objectName string) (map[string]string, error)
- func (c *Client) GetOwnedSecretData(ctx context.Context, namespace, name string, identity map[string]string) (map[string]string, error)
- func (c *Client) GetSecretData(ctx context.Context, namespace, name string) (map[string]string, error)
- func (c *Client) HasDataClaim(ctx context.Context, namespace, objectName, space, app string) bool
- func (c *Client) HasDefaultStorageClass(ctx context.Context) (bool, error)
- func (c *Client) HasResource(groupVersion, kind string) (bool, error)
- func (c *Client) ListAddonAttachments(ctx context.Context, namespace, space, addon string) ([]string, error)
- func (c *Client) ListAddonBindings(ctx context.Context, namespace, space, app string) ([]rt.ServiceBindingInfo, error)
- func (c *Client) ListApps(ctx context.Context) ([]AppRef, error)
- func (c *Client) ListFiles(ctx context.Context, namespace, objectName, space, app, subPath string) ([]rt.FileEntry, error)
- func (c *Client) ListGatewayConfigMaps(ctx context.Context) ([]corev1.ConfigMap, error)
- func (c *Client) ListManagedRoutes(ctx context.Context) ([]corev1.ConfigMap, error)
- func (c *Client) ListRouteNames(ctx context.Context, namespace, space, app string) ([]string, error)
- func (c *Client) ListSpaceMarkers(ctx context.Context, namespace string) ([]AppRef, error)
- func (c *Client) ListSpaces(ctx context.Context) ([]AppRef, error)
- func (c *Client) MakeDir(ctx context.Context, namespace, objectName, space, app, subPath string) error
- func (c *Client) MigrateGatewaySecrets(ctx context.Context, namespace string) error
- func (c *Client) MoveFile(ctx context.Context, namespace, objectName, space, app, from, to string) error
- func (c *Client) NamespaceLabels(ctx context.Context, name string) (map[string]string, bool, error)
- func (c *Client) ReadFile(ctx context.Context, namespace, objectName, space, app, subPath string, ...) error
- func (c *Client) RemoveFile(ctx context.Context, namespace, objectName, space, app, subPath string) error
- func (c *Client) RemoveFilesHelper(ctx context.Context, namespace, objectName, space, app string) error
- func (c *Client) RestartApp(ctx context.Context, namespace, objectName, space, app string) (bool, error)
- func (c *Client) RolloutEvidenceFor(ctx context.Context, namespace, objectName, space, app string) rt.Evidence
- func (c *Client) ServiceEndpoint(ctx context.Context, namespace, name, space, addon string) (string, int32, error)
- func (c *Client) SetAddonEnvFrom(ctx context.Context, namespace, objectName, space, app, secret string, ...) (bool, error)
- func (c *Client) SetAnnotations(ctx context.Context, kind, namespace, name string, identity map[string]string, ...) error
- func (c *Client) SetAppNetworkMetadata(ctx context.Context, namespace, name, space, app, mode, cors string) error
- func (c *Client) SetEnv(ctx context.Context, namespace, space, app, objectName string, ...) error
- func (c *Client) SharedBindingValues(ctx context.Context, key, matchKey, matchValue string) ([]string, error)
- func (c *Client) StorageFolders(ctx context.Context, namespace, objectName, space, app string) ([]rt.StorageFolder, error)
- func (c *Client) StreamLogs(ctx context.Context, namespace, space, app string, opts rt.LogOptions, ...) error
- func (c *Client) SwitchToRecreate(ctx context.Context, namespace, name, space, app string) error
- func (c *Client) SystemSecretData(ctx context.Context, namespace string) (map[string]string, error)
- func (c *Client) UpdateSecurity(ctx context.Context, namespace, name, space, app, image, security string) error
- func (c *Client) WaitForRollout(ctx context.Context, namespace, name string, identity map[string]string) error
- func (c *Client) WaitForRolloutWithin(ctx context.Context, namespace, name string, identity map[string]string, ...) error
- func (c *Client) WithInstallation(installation string, namespaces ...string) *Client
- func (c *Client) WriteFile(ctx context.Context, namespace, objectName, space, app, subPath string, ...) error
- type GatewayAdapter
- func (g *GatewayAdapter) GatewayCA(ctx context.Context, create func() ([]byte, []byte, error)) ([]byte, []byte, error)
- func (g *GatewayAdapter) GatewayCertificateCache() autocert.Cache
- func (g *GatewayAdapter) GatewayCertificates(ctx context.Context) ([]rt.GatewayCertificate, error)
- func (g *GatewayAdapter) GatewaySnapshot(ctx context.Context) (rt.GatewaySnapshot, error)
- func (g *GatewayAdapter) PrepareGateway(ctx context.Context) error
- type Options
- type Runtime
- func (r *Runtime) AIProxyTokens(ctx context.Context) ([]string, error)
- func (r *Runtime) AppMeta(ctx context.Context, space, app, key string) (string, error)
- func (r *Runtime) AppSummaries(ctx context.Context) ([]rt.AppSummary, error)
- func (r *Runtime) ApplyNetwork(ctx context.Context, cfg *config.AppConfig) (string, error)
- func (r *Runtime) AttachService(ctx context.Context, space, app, name string, binding map[string]string) (bool, error)
- func (r *Runtime) CheckSpaceFree(ctx context.Context, space string) error
- func (r *Runtime) Checks(ctx context.Context) []rt.Check
- func (r *Runtime) Client() *Client
- func (r *Runtime) CreateSpace(ctx context.Context, space string) error
- func (r *Runtime) DeleteSpace(ctx context.Context, space string) error
- func (r *Runtime) Deploy(ctx context.Context, spec rt.DeploySpec, out rt.Progress) error
- func (r *Runtime) Destroy(ctx context.Context, space, app string, keepData bool) error
- func (r *Runtime) DetachService(ctx context.Context, space, app, name string) error
- func (r *Runtime) EndpointStatus(ctx context.Context, space, app, host string) rt.EndpointStatus
- func (r *Runtime) EnsureService(ctx context.Context, space string, spec rt.ServiceSpec) (map[string]string, map[string]any, error)
- func (r *Runtime) EnsureSpaceConfigs(ctx context.Context) error
- func (r *Runtime) Evidence(ctx context.Context, space, app string) rt.Evidence
- func (r *Runtime) ExaProxyTokens(ctx context.Context) ([]string, error)
- func (r *Runtime) FinishConfigMigration(ctx context.Context) error
- func (r *Runtime) GetEnv(ctx context.Context, space, app string) (map[string]string, error)
- func (r *Runtime) HasData(ctx context.Context, space, app string) bool
- func (r *Runtime) InitPlatformConfig(ctx context.Context, initial config.PlatformConfig) (config.PlatformConfig, error)
- func (r *Runtime) InternalURL(space, app string, port int) string
- func (r *Runtime) InvalidateAppSummaries()
- func (r *Runtime) ListApps(ctx context.Context) ([]rt.AppRef, error)
- func (r *Runtime) ListFiles(ctx context.Context, space, app, path string) ([]rt.FileEntry, error)
- func (r *Runtime) ListServices(ctx context.Context, space, owner string) ([]rt.ServiceBindingInfo, error)
- func (r *Runtime) ListSpaceConfigs(ctx context.Context) (map[string]config.SpaceConfig, error)
- func (r *Runtime) ListSpaces(ctx context.Context) ([]string, error)
- func (r *Runtime) Logs(ctx context.Context, space, app string, opts rt.LogOptions, out io.Writer) error
- func (r *Runtime) MakeDir(ctx context.Context, space, app, path string) error
- func (r *Runtime) MigrateSystemConfig(ctx context.Context) error
- func (r *Runtime) MoveFile(ctx context.Context, space, app, from, to string) error
- func (r *Runtime) Network(ctx context.Context, space, app string) (*rt.NetworkState, error)
- func (r *Runtime) PlatformConfig(ctx context.Context) (config.PlatformConfig, error)
- func (r *Runtime) ReadFile(ctx context.Context, space, app, path string, out io.Writer) error
- func (r *Runtime) ReconcileAppRoutes(ctx context.Context, space, app string, protect bool) error
- func (r *Runtime) ReconcileAppTraffic(ctx context.Context) error
- func (r *Runtime) ReconcileSpaceIsolation(ctx context.Context) error
- func (r *Runtime) RemoveFile(ctx context.Context, space, app, path string) error
- func (r *Runtime) RemoveService(ctx context.Context, space, name string, keepData, force bool) ([]string, error)
- func (r *Runtime) Render(spec rt.DeploySpec) (string, error)
- func (r *Runtime) ResourceSamples(ctx context.Context) ([]rt.ResourceSample, error)
- func (r *Runtime) Restart(ctx context.Context, space, app string) (bool, error)
- func (r *Runtime) ServiceAttachments(ctx context.Context, space, name string) ([]string, error)
- func (r *Runtime) ServiceBinding(ctx context.Context, space, owner, name string) (map[string]string, error)
- func (r *Runtime) ServiceConnection(ctx context.Context, space, name string) (rt.ServiceConnection, error)
- func (r *Runtime) ServiceEndpoint(ctx context.Context, space, name string) (string, int32, error)
- func (r *Runtime) ServiceProxyAccess(ctx context.Context, sourceIP, offering string) (bool, error)
- func (r *Runtime) ServiceProxySpaceAccess(ctx context.Context, space, offering string) (bool, error)
- func (r *Runtime) SetAppMeta(ctx context.Context, space, app, key string, value *string) error
- func (r *Runtime) SetEnv(ctx context.Context, space, app string, env map[string]string) error
- func (r *Runtime) SetPlatformConfig(ctx context.Context, settings config.PlatformConfig) error
- func (r *Runtime) SetSpaceConfig(ctx context.Context, space string, settings config.SpaceConfig) error
- func (r *Runtime) SpaceConfig(ctx context.Context, space string) (config.SpaceConfig, error)
- func (r *Runtime) Status(ctx context.Context, space, app string) (*rt.AppStatus, error)
- func (r *Runtime) StorageFolders(ctx context.Context, space, app string) ([]rt.StorageFolder, error)
- func (r *Runtime) UpdateSecurity(ctx context.Context, space, app, image, security string) error
- func (r *Runtime) ValidateApp(space, app string) error
- func (r *Runtime) ValidateExistingNames(ctx context.Context) error
- func (r *Runtime) ValidateSpace(space string) error
- func (r *Runtime) WriteFile(ctx context.Context, space, app, path string, in io.Reader) error
Constants ¶
This section is empty.
Variables ¶
var ( // FilesHelperImage is the default toolbox for clients without an explicit // image. Installations configure their mirror through busyboxImage. FilesHelperImage = config.DefaultBusyboxImage )
Functions ¶
Types ¶
type Client ¶
type Client struct {
Dynamic dynamic.Interface
Clientset k8sclient.Interface
Config *rest.Config
// Installation is the installation this client speaks for — the control
// plane's namespace, which is unique per installation by construction.
// Everything applied is stamped with it and every cluster-wide sweep
// requires it, so two donkeys on one cluster stay out of each other's
// objects. Empty means the default installation.
Installation string
// Namespaces narrows every sweep that would otherwise cross the whole
// cluster. Empty means the cluster, which is what an installation with a
// namespace per space needs — and has the rights for. An installation
// confined to namespaces it was given lists only those: it holds no
// cluster-scoped permission, so a cluster-wide List would not merely
// return too much, it would be refused.
Namespaces []string
// contains filtered or unexported fields
}
Client bundles the two client flavors donkey uses: dynamic for server-side apply of anything, typed for reads (pods, logs, rollout status).
func NewInCluster ¶
NewInCluster is used by donkey-server, which runs inside the cluster it manages.
func (*Client) AppNetwork ¶
func (*Client) Apply ¶
Apply server-side-applies every object with donkey as field manager. It is idempotent: create and update are the same operation.
func (*Client) CheckNamespaceFree ¶
CheckNamespaceFree refuses to move into a namespace that exists but isn't donkey's — a space name must never let donkey take over (or later delete) somebody else's namespace. Only the managed annotation counts: a label somebody put on their own namespace must not turn it into one donkey may delete.
func (*Client) Confined ¶
Confined reports whether this installation lives in namespaces it was given rather than ones it made. A confined donkey must not create or delete a namespace — and must not read one either, since its rights stop at the namespace boundary and the attempt would simply be refused.
func (*Client) DeleteAddon ¶
func (c *Client) DeleteAddon(ctx context.Context, namespace, space, addon string, keepData bool) error
DeleteAddon removes one space service and optionally keeps its disk.
func (*Client) DeleteAppResources ¶
func (c *Client) DeleteAppResources(ctx context.Context, namespace, space, app string, keepData bool) error
DeleteAppResources deletes only one logical app. A space is a separate lifecycle boundary and is removed only through DeleteSpace.
func (*Client) DeleteAppRoute ¶
DeleteAppRoute removes the app's own-hostname route by immutable identity. The path-route cleanup separately deletes names obtained from an owned label query, but this route starts from a deterministic name and therefore must not grant that name deletion authority by itself.
func (*Client) DeleteAppTraffic ¶
DeleteAppTraffic retracts one app's system-namespace traffic objects. Labels, rather than deterministic names, are the deletion authority.
func (*Client) DeleteLegacySystemConfig ¶
Run only after the new manifests have rolled out: old pods may still read the previous Secret while the update is in progress.
func (*Client) DeleteObject ¶
func (c *Client) DeleteObject(ctx context.Context, kind, namespace, name string, identity map[string]string) error
DeleteObject removes one named object only after its immutable identity matches. Missing objects are fine. The caller gets the name from an owned query, but the second check closes the list/delete race.
func (*Client) DeleteObsoleteAppTraffic ¶
func (c *Client) DeleteObsoleteAppTraffic(ctx context.Context, namespace, space, app string, keepCertificate, keepDNS bool) error
DeleteObsoleteAppTraffic retracts objects omitted by the active certificate and DNS settings after their replacements have been applied.
func (*Client) DeleteObsoleteSystemTraffic ¶
func (c *Client) DeleteObsoleteSystemTraffic(ctx context.Context, namespace string, keepCertificate, keepDNS bool) error
DeleteObsoleteSystemTraffic retracts installation-host objects omitted by the active certificate and DNS settings. Named, ownership-checked deletes avoid touching the gateway's separate ACME cache or built-in CA Secrets, which carry the same system role.
func (*Client) DeleteSpace ¶
DeleteSpace removes an owned space namespace and everything in it. The namespace ownership annotation is the deletion authority; labels alone are never enough to make somebody else's namespace deletable.
func (*Client) DeleteSpaceIsolation ¶
DeleteSpaceIsolation retracts only the space's network fence when an installation turns isolation off. The deterministic policy name is not deletion authority; installation + logical space + role are.
func (*Client) DeleteSpaceObjects ¶
DeleteSpaceObjects removes a logical space from a shared namespace. The installation + space selector keeps every other tenant and installation outside the deletion boundary.
func (*Client) DeleteSpaceTraffic ¶
DeleteSpaceTraffic retracts Certificates, generated TLS Secrets and DNS records from the system namespace before their workload namespace disappears.
func (*Client) DeploymentAnnotation ¶
func (c *Client) DeploymentAnnotation(ctx context.Context, namespace, name, space, app, key string) (string, error)
DeploymentAnnotation reads one annotation off a Deployment; a missing Deployment (or annotation) is "".
func (*Client) DeploymentIdentity ¶
func (c *Client) DeploymentIdentity(ctx context.Context, namespace, name string) (map[string]string, bool, error)
DeploymentIdentity reports the stable role of a named Deployment.
func (*Client) DetachAddon ¶
DetachAddon removes only one app's copy of a space service binding.
func (*Client) ForInstallation ¶
ForInstallation is WithInstallation spelled from an installation's settings: confined to the two namespaces it was given when a workload namespace is named, cluster-wide otherwise. The one rule the server and the gateway must agree on, so it is written once.
func (*Client) GetEnv ¶
func (c *Client) GetEnv(ctx context.Context, namespace, space, app, objectName string) (map[string]string, error)
GetEnv returns the app's current env vars from its env secret.
func (*Client) GetOwnedSecretData ¶
func (c *Client) GetOwnedSecretData(ctx context.Context, namespace, name string, identity map[string]string) (map[string]string, error)
GetOwnedSecretData reads a donkey-created Secret only after its complete immutable identity matches. GetSecretData remains for explicitly configured source Secrets that belong to the cluster operator, not donkey.
func (*Client) GetSecretData ¶
func (c *Client) GetSecretData(ctx context.Context, namespace, name string) (map[string]string, error)
GetSecretData returns a secret's data as strings; a missing secret is an empty map.
func (*Client) HasDataClaim ¶
HasDataClaim reports whether the app's data volume exists — used to tell the user about a disk left over from an earlier configuration.
func (*Client) HasDefaultStorageClass ¶
HasDefaultStorageClass reports whether the cluster can provision volumes without naming a class — what app storage and provisioned addons rely on.
func (*Client) HasResource ¶
HasResource reports whether the cluster serves a kind — how the installer finds out, before applying anything, that a configuration names a CRD (Certificate or DNSEndpoint) whose operator isn't installed. An absent group is an answer, not an error.
func (*Client) ListAddonAttachments ¶
func (c *Client) ListAddonAttachments(ctx context.Context, namespace, space, addon string) ([]string, error)
ListAddonAttachments names the apps holding a copy of the shared addon's binding.
The space is part of the selector, not a nicety: where every space shares one namespace, "addon-postgres" is a binding name several spaces have, and without it removing one space's database would detach another's apps.
func (*Client) ListAddonBindings ¶
func (c *Client) ListAddonBindings(ctx context.Context, namespace, space, app string) ([]rt.ServiceBindingInfo, error)
ListAddonBindings finds the app's addon binding Secrets. An empty app selects the space's canonical bindings, which deliberately have no pseudo-app label.
func (*Client) ListApps ¶
ListApps finds every deployed donkey app in the cluster, grouped later by space. Apps are their Deployments — a namespace alone says nothing now that a space holds many apps.
func (*Client) ListFiles ¶
func (c *Client) ListFiles(ctx context.Context, namespace, objectName, space, app, subPath string) ([]rt.FileEntry, error)
ListFiles returns the entries of one folder on the app's disk. An empty subPath lists the root of the volume, where each app storage path has its own folder.
func (*Client) ListGatewayConfigMaps ¶
ListGatewayConfigMaps returns the installation's routes and access policies together so the gateway rebuilds them from the same snapshot.
The installation label is the ownership boundary. Do not select on app.kubernetes.io/managed-by here: a route may be managed by Helm or GitOps even though donkey-gateway serves it. A route.yaml data entry identifies a route; legacy backend annotations remain readable during upgrades.
func (*Client) ListManagedRoutes ¶
ListManagedRoutes returns only routing entries from the gateway snapshot.
func (*Client) ListRouteNames ¶
func (c *Client) ListRouteNames(ctx context.Context, namespace, space, app string) ([]string, error)
ListRouteNames returns the shared-address routes an app currently owns — the ones donkey renders from `routes:` in donkey.yaml.
func (*Client) ListSpaceMarkers ¶
ListSpaceMarkers finds the spaces of an installation that shares one namespace, where a space is an object rather than a namespace. A space with apps has them; one holding only services — or nothing at all, freshly made in the console — has only this.
func (*Client) ListSpaces ¶
ListSpaces finds every donkey space namespace, including ones holding no app — a space can carry only services now, and it must not vanish from view for that.
func (*Client) MakeDir ¶
func (c *Client) MakeDir(ctx context.Context, namespace, objectName, space, app, subPath string) error
MakeDir creates one folder. Its parent must already exist, so a typo makes a folder in the wrong place impossible rather than merely unlikely.
func (*Client) MigrateGatewaySecrets ¶
MigrateGatewaySecrets runs before the gateway starts issuing certificates, including when an operator applies a rendered bundle instead of the CLI. The original cache stays available to gateway pods during their rollout.
func (*Client) MoveFile ¶
func (c *Client) MoveFile(ctx context.Context, namespace, objectName, space, app, from, to string) error
MoveFile renames or moves something on the disk. A destination that is an existing folder means "move it in there", as everywhere else.
func (*Client) NamespaceLabels ¶
NamespaceLabels returns a namespace's labels and whether it exists at all. The installer reads them to find out what Pod Security Standard a namespace it was given enforces — the one thing that silently stops donkey after a clean install, because admission rejects the pod and the Deployment just never produces one.
func (*Client) ReadFile ¶
func (c *Client) ReadFile(ctx context.Context, namespace, objectName, space, app, subPath string, w io.Writer) error
ReadFile streams one file off the disk into w. Nothing is buffered, so a large file costs the server no memory.
func (*Client) RemoveFile ¶
func (c *Client) RemoveFile(ctx context.Context, namespace, objectName, space, app, subPath string) error
RemoveFile deletes a file or a whole folder. Deleting something that isn't there is not an error — the point is that it is gone.
func (*Client) RemoveFilesHelper ¶
func (c *Client) RemoveFilesHelper(ctx context.Context, namespace, objectName, space, app string) error
RemoveFilesHelper stops the app's helper pod if one is running. Destroying an app must call this: a pod still holding the volume keeps the disk from being released.
func (*Client) RestartApp ¶
func (c *Client) RestartApp(ctx context.Context, namespace, objectName, space, app string) (bool, error)
RestartApp triggers a fresh rollout so pods pick up changed env vars. Returns false when the app isn't deployed yet (nothing to restart).
func (*Client) RolloutEvidenceFor ¶
func (c *Client) RolloutEvidenceFor(ctx context.Context, namespace, objectName, space, app string) rt.Evidence
RolloutEvidenceFor collects the same pod summaries, problem-pod logs and warning events a failed rollout reports — for on-demand diagnosis of an app that is currently unhealthy.
func (*Client) ServiceEndpoint ¶
func (c *Client) ServiceEndpoint(ctx context.Context, namespace, name, space, addon string) (string, int32, error)
ServiceEndpoint returns the in-cluster host and port of a space service ("" when none runs) — donkey-server sits in the cluster and can dial it directly, which is what the tunnel rides on.
func (*Client) SetAddonEnvFrom ¶
func (c *Client) SetAddonEnvFrom(ctx context.Context, namespace, objectName, space, app, secret string, add bool) (bool, error)
SetAddonEnvFrom adds or removes an addon's binding secret on the app Deployment's envFrom and removes aliases when detached, so a change reaches the running app without a deploy (the template change triggers the rollout). Returns false when the app isn't deployed yet — the next deploy wires it instead.
func (*Client) SetAnnotations ¶
func (c *Client) SetAnnotations(ctx context.Context, kind, namespace, name string, identity map[string]string, annotations map[string]*string) error
SetAnnotations merge-patches annotations on one object; a nil value removes the annotation. Used for the console's own records (donkey.local/console on the Deployment) — a patch instead of an apply, so the field stays out of the deploy's server-side-apply ownership and survives the next deploy untouched.
func (*Client) SetAppNetworkMetadata ¶
func (c *Client) SetAppNetworkMetadata(ctx context.Context, namespace, name, space, app, mode, cors string) error
SetAppNetworkMetadata records network choices on the workload as well as its route. Internal apps have no own route, so the Deployment is the source that lets status and the console retain their mode and CORS policy.
func (*Client) SetEnv ¶
func (c *Client) SetEnv(ctx context.Context, namespace, space, app, objectName string, env map[string]string) error
SetEnv replaces the app's env secret with the given variables.
func (*Client) SharedBindingValues ¶
func (c *Client) SharedBindingValues(ctx context.Context, key, matchKey, matchValue string) ([]string, error)
SharedBindingValues collects a key only from canonical bindings matching the expected endpoint, so another provider's credentials are never accepted.
func (*Client) StorageFolders ¶
func (c *Client) StorageFolders(ctx context.Context, namespace, objectName, space, app string) ([]rt.StorageFolder, error)
StorageFolders reports which folder of the disk belongs to which path inside the app — the volume root is a list of subPath folders, and only the Deployment knows that "app-data" is the app's /app/data.
func (*Client) StreamLogs ¶
func (c *Client) StreamLogs(ctx context.Context, namespace, space, app string, opts rt.LogOptions, out io.Writer) error
StreamLogs writes the logs of every pod of the selected Donkey role to out, prefixed with the pod name when there is more than one.
func (*Client) SwitchToRecreate ¶
SwitchToRecreate clears a Deployment's rolling-update settings so its strategy can become Recreate. Kubernetes defaults spec.strategy.rollingUpdate for rolling deployments and then refuses that field together with type: Recreate — so an app that gains storage (and must stop before its replacement starts, since a disk attaches to one machine at a time) would otherwise be stuck on its old strategy. A missing Deployment is fine: the first deploy renders Recreate directly.
func (*Client) SystemSecretData ¶
SystemSecretData retains credentials when upgrading to the shared donkey resource name. An ownership or read error must never rotate session keys.
func (*Client) UpdateSecurity ¶
func (*Client) WaitForRollout ¶
func (c *Client) WaitForRollout(ctx context.Context, namespace, name string, identity map[string]string) error
WaitForRollout polls the Deployment until the new generation is fully available, or fails with collected evidence.
func (*Client) WaitForRolloutWithin ¶
func (c *Client) WaitForRolloutWithin(ctx context.Context, namespace, name string, identity map[string]string, timeout time.Duration) error
WaitForRolloutWithin is WaitForRollout with a deadline of the caller's. donkey-orchestrator needs one: with Recreate its new pod only starts once the old one has finished the deploys it was running.
func (*Client) WithInstallation ¶
WithInstallation returns the client bound to one installation, sweeping only the given namespaces (none means the whole cluster). The installer and the server both call it once they know where the control plane lives.
func (*Client) WriteFile ¶
func (c *Client) WriteFile(ctx context.Context, namespace, objectName, space, app, subPath string, r io.Reader) error
WriteFile stores r at subPath, replacing whatever was there. The upload lands in a temporary file next to the target and is moved into place only once it arrived complete — a broken connection never destroys the old file.
type GatewayAdapter ¶
GatewayAdapter confines all edge access to this installation's runtime.
func (*GatewayAdapter) GatewayCertificateCache ¶
func (g *GatewayAdapter) GatewayCertificateCache() autocert.Cache
func (*GatewayAdapter) GatewayCertificates ¶
func (g *GatewayAdapter) GatewayCertificates(ctx context.Context) ([]rt.GatewayCertificate, error)
func (*GatewayAdapter) GatewaySnapshot ¶
func (g *GatewayAdapter) GatewaySnapshot(ctx context.Context) (rt.GatewaySnapshot, error)
func (*GatewayAdapter) PrepareGateway ¶
func (g *GatewayAdapter) PrepareGateway(ctx context.Context) error
type Options ¶
type Options struct {
// Placement decides where a space's objects live and what they are
// called: a namespace per space, or one namespace for the installation.
Placement manifests.Placement
// SystemNamespace is where the control plane lives. It is also this
// installation's identity — see manifests.LabelInstallation.
SystemNamespace string
// Domain serves apps as <app>.<space>.<domain>.
Domain string
// Registry feeds the per-app image pull secret.
Registry config.Registry
// AddonImages are direct repository overrides for managed services.
AddonImages config.InstallAddonImages
CommonOfferings config.CommonOfferings
// BusyboxImage is the file-browser helper's toolbox.
BusyboxImage string
// AddonImagePullSecrets are existing secrets referenced by managed service
// and file-helper pods when Kubernetes pulls their images.
AddonImagePullSecrets []string
// TLS selects the certificate source. cert-manager mode creates one
// exact-host Certificate per exposed app.
TLS config.InstallTLS
// ExternalDNS optionally creates exact-host DNSEndpoints at the gateway
// LoadBalancer's configured target.
ExternalDNS config.InstallExternalDNS
// TelemetryKey derives an app-scoped OTLP credential. It is the
// installation key already held by donkey-server, never exposed directly.
TelemetryKey []byte
// IsolateSpaces fences every space with an ingress NetworkPolicy — see
// manifests.SpaceIsolationPolicy.
IsolateSpaces bool
// RestrictEgress adds the egress half of that fence — only meaningful
// together with IsolateSpaces.
RestrictEgress bool
}
Options is what the Kubernetes runtime needs to know about the installation — how spaces map to namespaces, where apps are served, and which certificate and DNS settings their public hostnames use.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime runs donkey's apps on a Kubernetes cluster. It deliberately does not embed Client: every Provider verb takes a space where the Client takes a namespace, and an inherited method with the wrong meaning would satisfy the interface silently.
func NewRuntime ¶
func (*Runtime) AIProxyTokens ¶
func (*Runtime) AppSummaries ¶
AppSummaries makes five lists per sweep namespace, regardless of app count. Only display values survive the read: no Secret data or management policies enter this cache. A lock coalesces concurrent portal refreshes, including the initial read, and serializes invalidation with an in-flight snapshot.
func (*Runtime) ApplyNetwork ¶
ApplyNetwork changes how the app is reached — without a deploy. The route and optional Certificate/DNSEndpoint are re-rendered from cluster state; existing shared-address routes keep serving under their existing names.
func (*Runtime) AttachService ¶
func (*Runtime) CheckSpaceFree ¶
func (*Runtime) Client ¶
Client exposes the underlying cluster client for Kubernetes-specific callers (the installer, the gateway) that need more than the Provider.
func (*Runtime) CreateSpace ¶
func (*Runtime) DeleteSpace ¶
func (*Runtime) Deploy ¶
Deploy applies the app's objects with the given image and waits for the rollout (unless spec.NoWait). Everything the Deployment needs — secrets, the disk, addon bindings — goes first, so the new version comes up with its configuration already in place.
func (*Runtime) DetachService ¶
func (*Runtime) EndpointStatus ¶
EndpointStatus checks the asynchronous pieces behind one live public hostname. Every failure stays local to its row in the console: an API or resolver hiccup must not turn the app's workload status into a 502.
func (*Runtime) EnsureService ¶
func (r *Runtime) EnsureService(ctx context.Context, space string, spec rt.ServiceSpec) (map[string]string, map[string]any, error)
EnsureService creates (or re-applies) one service of the space — provisioned in-cluster, or external as a binding-only Secret — and returns its binding values.
func (*Runtime) EnsureSpaceConfigs ¶
func (*Runtime) ExaProxyTokens ¶
func (*Runtime) FinishConfigMigration ¶
FinishConfigMigration runs after the new control plane is ready. A binding still referenced by a Pod is retained until its Deployment finishes rolling. Re-running an install or deploying that app retries cleanup safely.
func (*Runtime) InitPlatformConfig ¶
func (r *Runtime) InitPlatformConfig(ctx context.Context, initial config.PlatformConfig) (config.PlatformConfig, error)
Creation is atomic: simultaneous first sign-ins all use the one saved list. Subsequent saves deliberately use last-write-wins semantics.
func (*Runtime) InvalidateAppSummaries ¶
func (r *Runtime) InvalidateAppSummaries()
func (*Runtime) ListServices ¶
func (*Runtime) ListSpaceConfigs ¶
ListSpaceConfigs keeps fleet authorization fresh with one ConfigMap list and, for per-space placement, one namespace list. It shares no policy cache with the workload overview. Legacy or conflicting markers use the existing ownership-checked reader, so a bulk read cannot bypass migration or RBAC.
func (*Runtime) MigrateSystemConfig ¶
MigrateSystemConfig copies platform settings before the installer removes legacy resources. A new installation has no settings until first sign-in.
func (*Runtime) PlatformConfig ¶
func (*Runtime) ReconcileAppRoutes ¶
ReconcileAppRoutes changes only access fields, preserving addresses and backends.
func (*Runtime) ReconcileAppTraffic ¶
ReconcileAppTraffic brings every deployed app's Certificate and optional DNSEndpoint in line with installation settings. The route ConfigMap records the exact hostname, so an install can change certificate source or DNS publication without reconstructing donkey.yaml.
The installer calls this after applying the control plane. Ordinary deploy, network and destroy operations reconcile the same objects for one app.
func (*Runtime) ReconcileSpaceIsolation ¶
ReconcileSpaceIsolation applies (or retracts) every existing space's fence. The installer calls it, so toggling kubernetes.isolateSpaces takes effect at install time rather than at each space's next deploy.
func (*Runtime) RemoveFile ¶
func (*Runtime) RemoveService ¶
func (*Runtime) Render ¶
func (r *Runtime) Render(spec rt.DeploySpec) (string, error)
Render renders the app's objects without touching the cluster.
func (*Runtime) ResourceSamples ¶
ResourceSamples joins pod usage from metrics.k8s.io with the web container identities from the core API. The resource metrics API deliberately provides only fresh snapshots; donkey's telemetry service turns those snapshots into retained history.
func (*Runtime) ServiceAttachments ¶
func (*Runtime) ServiceBinding ¶
func (*Runtime) ServiceConnection ¶
func (*Runtime) ServiceEndpoint ¶
func (*Runtime) ServiceProxyAccess ¶
ServiceProxyAccess uses current pod and binding records, never forwarded headers or an IP-to-space cache that could outlive an IP's previous owner.
func (*Runtime) ServiceProxySpaceAccess ¶
func (*Runtime) SetAppMeta ¶
func (*Runtime) SetPlatformConfig ¶
func (*Runtime) SetSpaceConfig ¶
func (*Runtime) SpaceConfig ¶
func (*Runtime) StorageFolders ¶
func (*Runtime) UpdateSecurity ¶
func (*Runtime) ValidateApp ¶
ValidateApp checks a space and app name together. Apart they are both valid; joined into one object name they may be too long, which is something only the pair can answer.
func (*Runtime) ValidateExistingNames ¶
ValidateExistingNames catches incompatible logical names before an upgrade mutates any resource. Spaces, apps and services are never silently renamed.
func (*Runtime) ValidateSpace ¶
Source Files
¶
- addon_plugins.go
- addons.go
- apply.go
- apps.go
- client.go
- config_migration.go
- deploy.go
- endpoint_status.go
- env.go
- files.go
- fleet.go
- gateway.go
- gateway_tls.go
- isolation_migration.go
- logs.go
- membership_migration.go
- platform_config.go
- resources.go
- routes.go
- runtime.go
- service_proxy.go
- services.go
- shared_migration.go
- space_config.go
- spaces.go
- status.go
- storage.go
- system_config.go
- traffic_migration.go
- wait.go