kubernetes

package
v0.0.0-...-370a180 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnvVar

func GetEnvVar(podSpec corev1.PodSpec, envName string) *corev1.EnvVar

GetEnvVar find the first EnvVar with the provided environment name from a PodSpec

Types

type Client

type Client interface {
	GetWorkload(args args.KubernetesArgs) (*Workload, error)
	VerifyNoHorizontalPodAutoscaler(args args.KubernetesArgs) error
	Scale(resource *Workload, replicas int32) error
	GetEnvValue(podSpec corev1.PodSpec, namespace string, envName string) (string, error)
	GetPods(workload *Workload) ([]corev1.Pod, error)
}

Client is a wrapper around the client-go package for Kubernetes

type ClientAsync

type ClientAsync interface {
	Sync() Client

	GetWorkloadAsync(channel chan<- WorkloadReturn, args args.KubernetesArgs)
	VerifyNoHorizontalPodAutoscalerAsync(channel chan<- error, args args.KubernetesArgs)
	ScaleAsync(channel chan<- error, resource *Workload, replicas int32)
	GetEnvValueAsync(channel chan<- EnvValueReturn, podSpec corev1.PodSpec, namespace string, envName string)
	GetPodsAsync(channel chan<- Pods, workload *Workload)
}

ClientAsync is a wrapper around the client-go package for Kubernetes

func MakeClient

func MakeClient() (ClientAsync, error)

MakeClient returns a ClientAsync

func MakeFromClient

func MakeFromClient(syncClient Client) ClientAsync

MakeFromClient returns a ClientAsync from the given sync client

type ClientAsyncImpl

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

ClientAsyncImpl is the interface implementation of ClientAsync

func (ClientAsyncImpl) GetEnvValueAsync

func (c ClientAsyncImpl) GetEnvValueAsync(channel chan<- EnvValueReturn, podSpec corev1.PodSpec, namespace string, envName string)

GetEnvValueAsync gets an environment variable value from a pod

func (ClientAsyncImpl) GetPodsAsync

func (c ClientAsyncImpl) GetPodsAsync(channel chan<- Pods, workload *Workload)

GetPodsAsync gets all pods attached to some workload

func (ClientAsyncImpl) GetWorkloadAsync

func (c ClientAsyncImpl) GetWorkloadAsync(channel chan<- WorkloadReturn, args args.KubernetesArgs)

GetWorkloadAsync retrieves a Workload

func (ClientAsyncImpl) ScaleAsync

func (c ClientAsyncImpl) ScaleAsync(channel chan<- error, resource *Workload, replicas int32)

ScaleAsync scales a given Kubernetes resource

func (ClientAsyncImpl) Sync

func (c ClientAsyncImpl) Sync() Client

Sync returns the synchronous client

func (ClientAsyncImpl) VerifyNoHorizontalPodAutoscalerAsync

func (c ClientAsyncImpl) VerifyNoHorizontalPodAutoscalerAsync(channel chan<- error, args args.KubernetesArgs)

VerifyNoHorizontalPodAutoscalerAsync returns an error if the given resource has a HorizontalPodAutoscaler

type ClientImpl

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

ClientImpl is the interface implementation of Client

func (ClientImpl) GetEnvValue

func (c ClientImpl) GetEnvValue(podSpec corev1.PodSpec, namespace string, envName string) (string, error)

GetEnvValue gets an environment variable value from a pod

func (ClientImpl) GetPods

func (c ClientImpl) GetPods(workload *Workload) ([]corev1.Pod, error)

GetPods gets all pods attached to some workload

func (ClientImpl) GetWorkload

func (c ClientImpl) GetWorkload(args args.KubernetesArgs) (*Workload, error)

GetWorkload retrieves a Workload

func (ClientImpl) Scale

func (c ClientImpl) Scale(resource *Workload, replicas int32) error

Scale scales a given Kubernetes resource

func (ClientImpl) VerifyNoHorizontalPodAutoscaler

func (c ClientImpl) VerifyNoHorizontalPodAutoscaler(args args.KubernetesArgs) error

VerifyNoHorizontalPodAutoscaler returns an error if the given resource has a HorizontalPodAutoscaler

type EnvValueReturn

type EnvValueReturn struct {
	Value string
	Err   error
}

EnvValueReturn is a wrapper around string to allow returning multiple values in a channel

type Pods

type Pods struct {
	Pods []corev1.Pod
	Err  error
}

Pods is a wrapper around []corev1.Pod to allow returning multiple values in a channel

type Workload

type Workload struct {
	metav1.ObjectMeta

	metav1.TypeMeta

	// FriendlyName is the name used to reference the resource in the CLI, ex: deployment/myapp
	FriendlyName string

	// The label selector used to match pods
	PodSelector *metav1.LabelSelector

	// If the resource has a pod template, this should be set
	PodTemplateSpec *corev1.PodTemplateSpec
}

Workload represents a "base struct" for Kubernetes workloads

func GetWorkload

func GetWorkload(resource *appsv1.StatefulSet) (*Workload, error)

GetWorkload creates a KubernetesWorkload from a StatefulSet

type WorkloadReturn

type WorkloadReturn struct {
	Resource *Workload
	Err      error
}

WorkloadReturn is used to fix the issue with channels not supporting pair return values

Jump to

Keyboard shortcuts

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