k8s

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKindNamespaceNameFormat = fmt.Errorf("invalid format")
	ErrInvalidKind                    = fmt.Errorf("invalid kind")
)

Functions

func GetDeployment

func GetDeployment(ctx context.Context, client *kubernetes.Clientset, service KindNamespaceName) (*appsv1.Deployment, error)

func GetPods added in v0.3.0

func GetPods(ctx context.Context, client *kubernetes.Clientset, namespace string, selector map[string]string) ([]corev1.Pod, error)

GetPods returns a list of pods, identified by the selectors

func GetStatefulset

func GetStatefulset(ctx context.Context, client *kubernetes.Clientset, service KindNamespaceName) (*appsv1.StatefulSet, error)

func RestartService

func RestartService(ctx context.Context, clientset *kubernetes.Clientset, lock *lock.Lock, service KindNamespaceName) error

Types

type KindNamespaceName

type KindNamespaceName struct {
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

func KindNamespaceNameFromString added in v0.2.0

func KindNamespaceNameFromString(s string) (*KindNamespaceName, error)

KindNamespaceNameFromString parses a string into a KindNamespaceName The string should be in the format of "Kind/Namespace/Name"

Example:

KindNamespaceNameFromString("Deployment/my-namespace/my-deployment")

This will return a KindNamespaceName with Kind: Deployment, Namespace: my-namespace, Name: my-deployment

func (KindNamespaceName) String

func (s KindNamespaceName) String() string

type PodStatus

type PodStatus map[corev1.PodPhase]int

func PodStatuses added in v0.3.0

func PodStatuses(pods []corev1.Pod) (PodStatus, bool)

PodStatuses checks if the restart for the deployment or statefulset is complete It returns a map of pod status and the number of pods with that status as well as a boolean indicating if the restart is complete. If the passed pod list is empty, we treat the restart as complete If from the passed pod list, the first pod doesn't have an owner reference, we treat the restart as complete If from the passed pod list, the first pod doesn't have an owner reference of kind replicaset or statefulset, we treat the restart as complete In all other cases, we check the status of the pod and add it to the map If there are no pods, we treat the restart as complete

Jump to

Keyboard shortcuts

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