kube

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func ClientConfig(kubeconfig, context string) (*rest.Config, string, error)

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. It also 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

func NewManager(opts Options) (ctrl.Manager, error)

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

func RestConfig(kubeconfig string) (*rest.Config, error)

RestConfig resolves the REST config from an explicit kubeconfig path or the standard in-cluster/KUBECONFIG chain.

func Scheme

func Scheme() *runtime.Scheme

Scheme returns a runtime scheme holding the client-go kinds, batch Jobs, and the patchy API group.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL