Documentation
¶
Index ¶
- Constants
- Variables
- func CACrt(ctx context.Context, rc *rest.Config) (string, error)
- func ConfigMapData(ctx context.Context, rc *rest.Config, name, namespace string) (map[string]string, error)
- func DetectClusterName(restConfig *rest.Config) string
- func MakeDNS1123Compatible(name string) string
- func ServiceAccountNamespace() (string, error)
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 ConfigMapData ¶
func DetectClusterName ¶
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 ¶
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 ¶
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package content compares Kubernetes objects by content, in the one form the AUDIT-4 ruling defines (snowplow, 2026-11-11): what an object grants or holds, not how it happens to be written.
|
Package content compares Kubernetes objects by content, in the one form the AUDIT-4 ruling defines (snowplow, 2026-11-11): what an object grants or holds, not how it happens to be written. |
|
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. |
Click to show internal directories.
Click to hide internal directories.