Documentation
¶
Overview ¶
Package kube is the shared controller-runtime scaffolding: the scheme with every API group the controllers touch, manager construction honoring the --kubeconfig flag, leader election, and the logr→slog bridge. Every CRD-watching binary builds its manager here so the knobs stay uniform.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientConfig ¶ added in v0.6.1
ClientConfig resolves the REST config the way kubectl does — the standard loading rules (explicit path, then $KUBECONFIG, then ~/.kube/config), with an optional context override — and additionally returns the namespace that context selects.
Controllers use RestConfig: they run with a ServiceAccount and one identity. ClientConfig is for the CLI, which carries a human's kubeconfig and has to honour --context and the per-context namespace the same way every other Kubernetes tool does. The namespace follows kubectl's rule exactly, including its "default" when nothing declares one, so `patchy get` and `kubectl get` never disagree about where they are looking.
func NewManager ¶
NewManager builds a controller manager per Options. Secrets are never cached: provider/forge secretRefs are read on demand through the API reader, so no controller needs a namespace-wide secret list/watch grant.
func RestConfig ¶
RestConfig resolves the REST config from an explicit kubeconfig path or the standard in-cluster/KUBECONFIG chain.
Types ¶
type Options ¶
type Options struct {
// Kubeconfig is the path to a kubeconfig file; empty means in-cluster
// config (with the usual KUBECONFIG/service-account fallbacks).
Kubeconfig string
// LeaderElectionID is the Lease name; empty disables leader election.
// Deployments stay replicas:1 + Recreate — the lease is cheap insurance
// against two replicas racing during a botched rollout.
LeaderElectionID string
// LeaderElectionNamespace holds the Lease; required when running outside
// the cluster (in-cluster it defaults to the pod's namespace).
LeaderElectionNamespace string
// Namespaces scopes the cache; empty watches the manager's default.
Namespaces []string
// AgentNamespace confines the Job and Pod informers to the agents
// namespace instead of Namespaces. The job controllers' RBAC grants
// jobs/pods only there (Role patchy-agent-jobs) — caching those kinds in
// the release namespace too would need grants the controllers must not
// have, and caching the CR kinds in the agents namespace trips forbidden
// list/watch errors that keep the cache from ever syncing. Empty leaves
// every kind on Namespaces.
AgentNamespace string
// MetricsAddr for controller-runtime's own metrics server; empty disables
// it (patchy's telemetry is OpenTelemetry via internal/telemetry).
MetricsAddr string
// HealthAddr serves /healthz and /readyz for kubelet probes; empty
// disables the endpoint.
HealthAddr string
// Log is bridged to controller-runtime's logr. nil discards.
Log *slog.Logger
}
Options configure a controller manager.