k8s

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UsePersistentConfig caches client config to avoid reloads.
	UsePersistentConfig = true
)

Variables

This section is empty.

Functions

func ApplyYaml

func ApplyYaml(client kubernetes.Interface, dynamicClient dynamic.Interface, uri string) error

ApplyYaml applies a yaml manifest to the cluster from the URI. The URI can be a file path or a URL It creates CRDs first and then other objects @TODO: Make this function testable by passing a "uri reader"

func CreateOrUpdate

func CreateOrUpdate(config *KubeConfig, obj client.Object) error

CreateOrUpdate creates or updates a kubernetes object Note: This only really works for Blueprint objects right now.

func Delete

func Delete(config *KubeConfig, obj client.Object) error

Delete deletes a kubernetes object

func DeleteYamlObjects

func DeleteYamlObjects(kc *KubeConfig, uri string) error

DeleteYamlObjects deletes all objects in the cluster that are specified in the yaml

func GetClient

func GetClient(config *KubeConfig) (*kubernetes.Clientset, error)

GetClient returns a kubernetes client

func GetDynamicClient

func GetDynamicClient(config *KubeConfig) (*dynamic.DynamicClient, error)

GetDynamicClient returns a dynamic kubernetes client

func WaitForNodes

func WaitForNodes(client kubernetes.Interface) error

WaitForNodes waits for all nodes to be ready

func WaitForPods

func WaitForPods(client kubernetes.Interface, namespace string) error

WaitForPods waits for all pods in the given namespace to be running

Types

type KubeConfig

type KubeConfig struct {
	// contains filtered or unexported fields
}

KubeConfig tracks a kubernetes configuration.

func NewConfig

NewConfig returns a new k8s config or an error if the flags are invalid.

func (*KubeConfig) ConfigAccess

func (c *KubeConfig) ConfigAccess() clientcmd.ConfigAccess

ConfigAccess return the current kubeconfig api server access configuration.

func (*KubeConfig) CurrentContextName

func (c *KubeConfig) CurrentContextName() (string, error)

CurrentContextName returns the currently active config context.

func (*KubeConfig) DelContext

func (c *KubeConfig) DelContext(n string) error

DelContext remove a given context from the configuration.

func (*KubeConfig) GetConfigPath

func (c *KubeConfig) GetConfigPath() string

func (*KubeConfig) GetContext

func (c *KubeConfig) GetContext(n string) (*clientcmdapi.Context, error)

GetContext fetch a given context or error if it does not exists.

func (*KubeConfig) MergeConfig

func (c *KubeConfig) MergeConfig(newConfig clientcmdapi.Config) error

MergeConfig merges a new config into the existing config and writes it back to disk.

func (*KubeConfig) RESTConfig

func (c *KubeConfig) RESTConfig() (*restclient.Config, error)

func (*KubeConfig) TryLoad

func (c *KubeConfig) TryLoad() error

TryLoad attempts to create a kube client and returns an error if it fails.

Jump to

Keyboard shortcuts

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