kubeutil

package
v1.53.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	DNS1123NameMaximumLength         = 63
	DNS1123NotAllowedCharacters      = "[^-a-z0-9]"
	DNS1123NotAllowedStartCharacters = "^[^a-z0-9]+"
)
View Source
const (
	ClusterNameEnvVar = "CLUSTER_NAME"
)

Variables

View Source
var (
	ErrNoNamespace = fmt.Errorf("namespace not found for current environment")
)

ErrNoNamespace indicates that a namespace could not be found for the current environment

Functions

func CACrt

func CACrt(ctx context.Context, rc *rest.Config) (string, error)

func ConfigMapData

func ConfigMapData(ctx context.Context, rc *rest.Config, name, namespace string) (map[string]string, error)

func DetectClusterName

func DetectClusterName(restConfig *rest.Config) string
Example (FromEnv)
package main

import (
	"fmt"
	"os"

	"github.com/krateo-platformops/plumbing/kubeutil"
	"k8s.io/client-go/rest"
)

func main() {
	prev := os.Getenv(kubeutil.ClusterNameEnvVar)
	_ = os.Setenv(kubeutil.ClusterNameEnvVar, "dev-eu-1")
	defer func() {
		if prev == "" {
			_ = os.Unsetenv(kubeutil.ClusterNameEnvVar)
			return
		}
		_ = os.Setenv(kubeutil.ClusterNameEnvVar, prev)
	}()

	cluster := kubeutil.DetectClusterName(&rest.Config{Host: "https://10.0.0.1:6443"})
	fmt.Println(cluster)

}
Output:
dev-eu-1
Example (FromRestConfig)
package main

import (
	"fmt"
	"os"

	"github.com/krateo-platformops/plumbing/kubeutil"
	"k8s.io/client-go/rest"
)

func main() {
	_ = os.Unsetenv(kubeutil.ClusterNameEnvVar)

	cluster := kubeutil.DetectClusterName(&rest.Config{Host: "https://123.45.67.89:6443"})
	fmt.Println(cluster)

}
Output:
123.45.67.89

func MakeDNS1123Compatible

func MakeDNS1123Compatible(name string) string

Most resource types require a name that can be used as a DNS subdomain name as defined in RFC 1123.

https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names

func ServiceAccountNamespace

func ServiceAccountNamespace() (string, error)

Types

This section is empty.

Directories

Path Synopsis
Package dynamicwatch registers a controller-runtime watch on a Kind whose GroupVersionKind is not known until runtime (e.g.
Package dynamicwatch registers a controller-runtime watch on a Kind whose GroupVersionKind is not known until runtime (e.g.
Package hasher computes a cumulative, order-dependent hash over arbitrary JSON-marshalable values.
Package hasher computes a cumulative, order-dependent hash over arbitrary JSON-marshalable values.
Package objectclient provides retrying, dynamic.Interface-based create-or-update ("Apply"), Get, and delete-if-present ("Uninstall") helpers for arbitrary Kubernetes objects.
Package objectclient provides retrying, dynamic.Interface-based create-or-update ("Apply"), Get, and delete-if-present ("Uninstall") helpers for arbitrary Kubernetes objects.
Package rbacgen builds least-privilege Role/RoleBinding objects that grant a single ServiceAccount access to an exact, named set of resources (e.g.
Package rbacgen builds least-privilege Role/RoleBinding objects that grant a single ServiceAccount access to an exact, named set of resources (e.g.
Package secretref reads a single key out of a Kubernetes Secret via a dynamic.Interface.
Package secretref reads a single key out of a Kubernetes Secret via a dynamic.Interface.

Jump to

Keyboard shortcuts

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