kubeutil

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 22 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
)

Variables

This section is empty.

Functions

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

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