k8s

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const ConditionTypeReady = "Ready"

ConditionTypeReady is the condition type for overall readiness.

Variables

This section is empty.

Functions

func AnnotationsMergePatch added in v0.1.2

func AnnotationsMergePatch(annotations map[string]any) ([]byte, error)

AnnotationsMergePatch builds a merge patch for annotation updates.

func DecodeUnstructured added in v0.1.1

func DecodeUnstructured[T any](u *unstructured.Unstructured) (*T, error)

DecodeUnstructured converts an Unstructured object into a typed struct.

func DetectNodeIP added in v0.1.4

func DetectNodeIP() string

DetectNodeIP returns the first non-loopback IPv4 address, or "127.0.0.1" if none found.

func EnvBool added in v0.1.4

func EnvBool(key string, fallback bool) bool

EnvBool parses a boolean env var, falling back to fallback when unset or invalid.

func EnvDuration added in v0.1.4

func EnvDuration(key string, fallback time.Duration) time.Duration

EnvDuration parses a duration env var, falling back to fallback when unset or invalid.

func EnvOrDefault added in v0.1.4

func EnvOrDefault(key, fallback string) string

EnvOrDefault returns os.Getenv(key), falling back to fallback when unset or empty.

func GenerateSelfSignedCert added in v0.1.4

func GenerateSelfSignedCert(hostname, ip string) (tls.Certificate, error)

GenerateSelfSignedCert creates an in-memory ECDSA P-256 self-signed cert for hostname and ip.

func LoadConfig

func LoadConfig() (*rest.Config, error)

LoadConfig returns a client config from $KUBECONFIG, ~/.kube/config, or in-cluster (first match wins).

func LoadOrGenerateCert added in v0.1.4

func LoadOrGenerateCert(certPath, keyPath, hostname, ip string) (tls.Certificate, string, error)

LoadOrGenerateCert loads a TLS keypair from disk, falling back to a self-signed cert. Returns a source label for logging ("disk <path>" or "self-signed").

func NewReadyCondition added in v0.1.4

func NewReadyCondition(generation int64, status metav1.ConditionStatus, reason, message string) metav1.Condition

NewReadyCondition builds a Ready condition. LastTransitionTime is left zero so apimeta.SetStatusCondition preserves the existing timestamp on no-op updates.

func PatchHibernateState added in v0.1.4

func PatchHibernateState(ctx context.Context, cli client.Client, pod *corev1.Pod, state bool) error

PatchHibernateState patches the hibernate annotation, short-circuiting if already at the desired state.

func PatchStatus added in v0.1.4

func PatchStatus[T DeepCopyObject[T]](ctx context.Context, cli client.Client, obj T, mutate func(T)) error

PatchStatus applies mutate under a MergeFrom patch on the /status subresource.

func SleepCtx added in v0.1.4

func SleepCtx(ctx context.Context, d time.Duration) bool

SleepCtx blocks for d or until ctx is canceled. Returns false if ctx fired first.

func StatusMergePatch added in v0.1.1

func StatusMergePatch(status any) ([]byte, error)

StatusMergePatch builds a merge patch for a status subresource update.

Types

type DeepCopyObject added in v0.1.4

type DeepCopyObject[T any] interface {
	client.Object
	DeepCopy() T
}

DeepCopyObject is client.Object with a typed DeepCopy() method.

Directories

Path Synopsis
Package admission provides shared admission-webhook helpers: decode/dispatch/encode, allow/deny builders, and JSON patch utilities.
Package admission provides shared admission-webhook helpers: decode/dispatch/encode, allow/deny builders, and JSON patch utilities.

Jump to

Keyboard shortcuts

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