k8sutil

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptSecretPasswords added in v1.1.0

func DecryptSecretPasswords(client client.Client, reqLogger logr.Logger, secretName, namespace string, keys []string) (map[string]string, error)

DecryptSecretPasswords decrypts multiple passwords from a Kubernetes Secret, returning a map of key->password

func GetPodCondition

func GetPodCondition(status *corev1.PodStatus, conditionType corev1.PodConditionType) (int, *corev1.PodCondition)

GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodConditionFromList

func GetPodConditionFromList(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) (int, *corev1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func GetPodReadyCondition

func GetPodReadyCondition(status corev1.PodStatus) *corev1.PodCondition

GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func IsPodReady

func IsPodReady(pod *corev1.Pod) bool

IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status corev1.PodStatus) bool

IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.

Types

type ExecOptions

type ExecOptions struct {
	Command []string

	Namespace     string
	PodName       string
	ContainerName string

	Stdin         io.Reader
	CaptureStdout bool
	CaptureStderr bool
	// If false, whitespace in std{err,out} will be removed.
	PreserveWhitespace bool
}

ExecOptions passed to ExecWithOptions.

type IExec

type IExec interface {

	// ExecCommandInContainer executes a command in the specified container.
	ExecCommandInContainer(pod *corev1.Pod, containerName string, cmd ...string) (string, string, error)
}

IExec is an injectable interface for running remote exec commands.

func NewRemoteExec

func NewRemoteExec(restGVKClient rest.Interface, config *rest.Config, logger logr.Logger) IExec

NewRemoteExec returns a new IExec which will exec remote cmd.

type IPodControl

type IPodControl interface {
	// CreatePod creates a Pod in a DistributedRedisCluster.
	CreatePod(*corev1.Pod) error
	// UpdatePod updates a Pod in a DistributedRedisCluster.
	UpdatePod(*corev1.Pod) error
	// DeletePod deletes a Pod in a DistributedRedisCluster.
	DeletePod(*corev1.Pod) error
	DeletePodByName(namespace, name string) error
	// GetPod get Pod in a DistributedRedisCluster.
	GetPod(namespace, name string) (*corev1.Pod, error)
}

IPodControl defines the interface that uses to create, update, and delete Pods.

func NewPodController

func NewPodController(client client.Client) IPodControl

NewPodController creates a concrete implementation of the IPodControl.

type IUnitControl

type IUnitControl interface {

	// UpdateUnit updates a Unit.
	UpdateUnit(*unitv1alpha2.Unit) error

	// GetUnit get Unit.
	GetUnit(namespace, name string) (*unitv1alpha2.Unit, error)
}

IUnitControl defines the interface that uses to update, and get Units.

func NewUnitController

func NewUnitController(cfg *rest.Config) (IUnitControl, error)

NewUnitController creates a concrete implementation of the IUnitControl.

type PodController

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

func (*PodController) CreatePod

func (p *PodController) CreatePod(pod *corev1.Pod) error

CreatePod implement the IPodControl.Interface.

func (*PodController) DeletePod

func (p *PodController) DeletePod(pod *corev1.Pod) error

DeletePod implement the IPodControl.Interface.

func (*PodController) DeletePodByName

func (p *PodController) DeletePodByName(namespace, name string) error

DeletePod implement the IPodControl.Interface.

func (*PodController) GetPod

func (p *PodController) GetPod(namespace, name string) (*corev1.Pod, error)

GetPod implement the IPodControl.Interface.

func (*PodController) UpdatePod

func (p *PodController) UpdatePod(pod *corev1.Pod) error

UpdatePod implement the IPodControl.Interface.

type UnitController

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

func (*UnitController) GetUnit

func (p *UnitController) GetUnit(namespace, name string) (*unitv1alpha2.Unit, error)

GetUnit implement the IPodControl.Interface.

func (*UnitController) UpdateUnit

func (p *UnitController) UpdateUnit(unit *unitv1alpha2.Unit) error

UpdateUnit implement the IPodControl.Interface.

Jump to

Keyboard shortcuts

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