k8s

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NAMESPACE_DEFAULT string = "default"
)

Functions

func ApplyPodFilter

func ApplyPodFilter(pods []corev1.Pod, filters ...PodFilterFn) (result []corev1.Pod)

Apply filters (if any) to a list of pods

func GetPodNameFromArgs

func GetPodNameFromArgs(args []string) (string, error)

Get pod name from CLI arguments

func MinifyPod

func MinifyPod(pod *corev1.Pod) *corev1.Pod

func SanitizeEditedPod

func SanitizeEditedPod(original, edited *corev1.Pod) (*corev1.Pod, error)

Validate the pod struct from edited manifests

Types

type ContextOptions

type ContextOptions struct {
	context.Context
	Cancel  context.CancelFunc
	SigChan chan os.Signal
}

Represent context with a cancel func

func (*ContextOptions) CancelContext added in v1.3.0

func (opts *ContextOptions) CancelContext()

Cancel execution context

func (*ContextOptions) InitContext added in v1.3.0

func (opts *ContextOptions) InitContext(timeout *string) error

Set up the options with the following steps: * Create a Context with timeout if any. Otherwise, no timeout is set (i.e. context.Background()) * Create a chan os.Signal to handle SIGTERM, SIGINT (Ctrl + C),SIGHUP (terminal is closed)

type KubeClientset added in v1.3.0

type KubeClientset struct {
	kubernetes.Interface
}

func NewClientset

func NewClientset(kubeConfig *KubeConfig) (*KubeClientset, error)

Get a clientset to interact with Kubernetes API Config precedence: * --kubeconfig flag pointing at a file * KUBECONFIG environment variable pointing at a file * $HOME/.kube/config if exists.

func (*KubeClientset) GetPod added in v1.3.0

func (client *KubeClientset) GetPod(ctx context.Context, namespace, name string) (*corev1.Pod, error)

Get pod by name in a specific namespace

func (*KubeClientset) ListPods added in v1.3.0

func (client *KubeClientset) ListPods(ctx context.Context, namespace string, filters ...PodFilterFn) ([]corev1.Pod, error)

List pods by filters in the specified namespace If namespace is empty (i.e. ""), list in all namespaces

func (*KubeClientset) UpdateEphemeralContainersForPod added in v1.3.0

func (client *KubeClientset) UpdateEphemeralContainersForPod(ctx context.Context, pod *corev1.Pod) (*corev1.Pod, error)

Update pod's ephemeralContainer subresource

type KubeConfig

type KubeConfig struct {
	*genericclioptions.ConfigFlags
	*ContextOptions
}

Represent kube client configurations

func NewKubeConfig

func NewKubeConfig() *KubeConfig

Get a new KubeConfig struct

type PodFilterFn

type PodFilterFn func(pod corev1.Pod) bool

Jump to

Keyboard shortcuts

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