kubeutil

package
v0.60.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServerBurst is the default number of queries per second for server.
	DefaultServerQPS float32 = 200.0
	// DefaultServerBurst is the default number of queries k8sclient handles concurrently for server.
	DefaultServerBurst int = 200

	// DefaultCLIQPS is the default number of queries per second for CLI.
	DefaultCLIQPS float32 = 50.0
	// DefaultCLIBurst is the default number of queries k8sclient handles concurrently for CLI.
	DefaultCLIBurst int = 100

	// TargetKubeconfigEnvVar is the environment variable that points at a kubeconfig
	// file for an external target cluster. When set, Radius deploys application
	// resources (both recipe-provisioned and directly-rendered output resources) to
	// that cluster instead of the control-plane cluster it runs on. This is the
	// multi-cluster v1 contract; the kubeconfig is supplied (and refreshed) out of
	// band by the workflow that mounts it.
	TargetKubeconfigEnvVar = "RADIUS_TARGET_KUBECONFIG"
)

Variables

This section is empty.

Functions

func DeploymentTargetRuntimeClient

func DeploymentTargetRuntimeClient(controlPlane runtimeclient.Client) (runtimeclient.Client, error)

DeploymentTargetRuntimeClient returns the controller-runtime client that application resources (including the application namespace) should be created with. It returns controlPlane unchanged unless RADIUS_TARGET_KUBECONFIG is set, in which case it builds a runtime client for the external cluster named by that kubeconfig. This keeps application namespaces on the same cluster the application's resources deploy to, so in multi-cluster mode the control-plane cluster is not populated with per-application namespaces.

func LoadConfigFile

func LoadConfigFile(configFilePath string) (*api.Config, error)

LoadConfigFile loads the Kubernetes config file from the given path, or will load the default config from the home directory if no path is provided.

func NewClientConfig

func NewClientConfig(options *ConfigOptions) (*rest.Config, error)

NewClientConfig builds a Kubernetes client config from either in-cluster or local configuration, and sets the QPS and Burst values if provided. It returns an error if the config cannot be built.

func NewClientConfigForTargetCluster

func NewClientConfigForTargetCluster(kubeconfigPath string) (*rest.Config, error)

NewClientConfigForTargetCluster builds a Kubernetes client config from the kubeconfig file at kubeconfigPath, using its current context and the server QPS/Burst defaults. It is used to target an external cluster (for example an AKS or EKS cluster) when the Radius control plane runs on a separate cluster.

func NewClientConfigFromLocal

func NewClientConfigFromLocal(options *ConfigOptions) (*rest.Config, error)

NewClientConfigFromLocal builds a Kubernetes client config from a ConfigOptions instance, loading the config file from the ConfigFilePath and setting the QPS and Burst values if specified. It returns an error if the config file cannot be loaded or the client config cannot be initialized.

func NewRuntimeClient

func NewRuntimeClient(config *rest.Config) (runtimeclient.Client, error)

NewRuntimeClient creates a new runtime client using the given config and adds the required resource schemes to the client.

func PatchNamespace

func PatchNamespace(ctx context.Context, client runtime_client.Client, namespace string) error

PatchNamespace creates a new namespace with the given name and labels it with the given label, then applies it to the cluster. It returns an error if the patch operation fails.

func TargetClusterDefaultNamespace

func TargetClusterDefaultNamespace() string

TargetClusterDefaultNamespace returns the namespace that application resources should default to on the deployment-target cluster when the environment does not specify one. When RADIUS_TARGET_KUBECONFIG is set, it is the namespace pinned by that kubeconfig's current context (an operator may scope the target credential to a namespace); otherwise, or when the context pins no namespace or the kubeconfig cannot be read, it falls back to "default", which exists on every Kubernetes cluster.

Types

type Clients

type Clients struct {
	// RuntimeClient is the Kubernetes controller runtime client.
	RuntimeClient runtimeclient.Client

	// ClientSet is the Kubernetes client-go strongly-typed client.
	ClientSet *kubernetes.Clientset

	// DiscoveryClient is the Kubernetes client-go discovery client.
	DiscoveryClient *discovery.DiscoveryClient

	// DynamicClient is the Kubernetes client-go dynamic client.
	DynamicClient dynamic.Interface
}

Clients is a collection of Kubernetes clients.

func NewClients

func NewClients(config *rest.Config) (*Clients, error)

NewClients creates a new Kubernetes client set and controller runtime client using the given config.

type ConfigOptions

type ConfigOptions struct {
	ConfigFilePath string
	QPS            float32
	Burst          int
	ContextName    string
}

ConfigOptions is custom options to configure kubernetes client config.

type ObjectManifest

type ObjectManifest map[schema.GroupVersionKind][]runtime.Object

ObjectManifest is a map of runtime.Object slice where the key is GroupVersionKind for the resource.

func ParseManifest

func ParseManifest(data []byte) (ObjectManifest, error)

ParseManifest parses the given manifest and returns a map of runtime.Object slice where the key is GroupVersionKind for the resource. It returns an error if the given manifest is invalid.

func (ObjectManifest) Get

Get returns a runtime.Object slice for the given key.

func (ObjectManifest) GetFirst

GetFirst returns the first runtime.Object for the given key.

Jump to

Keyboard shortcuts

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