kube

package
v1.7.14 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const LastAppliedAnnotation = "crdb.io/last-applied"

Variables

View Source
var IgnoreNotFound = client.IgnoreNotFound
View Source
var IsNotFound = apierrors.IsNotFound

Functions

func CreateOrUpdateAnnotated

func CreateOrUpdateAnnotated(ctx context.Context, c client.Client, obj client.Object, f MutateFn) (upserted bool, err error)

func ExecInPod

func ExecInPod(scheme *runtime.Scheme, config *rest.Config, namespace string, name string, container string, cmd []string) (string, string, error)

func FindContainer

func FindContainer(container string, spec *corev1.PodSpec) (*corev1.Container, error)

func GeContainerStatusFromList

func GeContainerStatusFromList(containerStatuses []corev1.ContainerStatus, image string) (int, *corev1.ContainerStatus)

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

func Get

func Get(ctx context.Context, cl client.Client, obj client.Object) error

func GetClusterCA

func GetClusterCA(ctx context.Context, config *rest.Config) ([]byte, error)

func GetContainerStatus

func GetContainerStatus(status *corev1.PodStatus, image string) (int, *corev1.ContainerStatus)

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

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 HandleStsError added in v1.7.7

func HandleStsError(err error, l logr.Logger, stsName string, ns string) error

func IsImagePullBackOff

func IsImagePullBackOff(pod *corev1.Pod, image string) bool

IsImagePullBackOff returns true if a container status has the waiting state with reason ImagePullBackOff

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.

func WaitUntilAllStsPodsAreReady added in v1.7.7

func WaitUntilAllStsPodsAreReady(ctx context.Context, clientset *kubernetes.Clientset, l logr.Logger, stsname, stsnamespace string, podUpdateTimeout, podMaxPollingInterval time.Duration) error

WaitUntilAllStsPodsAreReady waits until all pods in the statefulset are in the ready state. The ready state implies all nodes are passing node liveness.

Types

type KubernetesDistribution added in v1.7.6

type KubernetesDistribution interface {
	Get(ctx context.Context, config *rest.Config, log logr.Logger) (string, error)
}

func MockKubernetesDistribution added in v1.7.6

func MockKubernetesDistribution() KubernetesDistribution

func NewKubernetesDistribution added in v1.7.6

func NewKubernetesDistribution() KubernetesDistribution

type MutateFn

type MutateFn func() error

MutateFn is a function which mutates the existing object into it's desired state.

type PersistFn

type PersistFn func(context.Context, client.Client, client.Object, MutateFn) (upserted bool, err error)
var AnnotatingPersister PersistFn = func(ctx context.Context, cl client.Client, obj client.Object, f MutateFn) (upserted bool, err error) {
	return CreateOrUpdateAnnotated(ctx, cl, obj, func() error {
		return f()
	})
}
var DefaultPersister PersistFn = func(ctx context.Context, cl client.Client, obj client.Object, f MutateFn) (upserted bool, err error) {
	result, err := ctrl.CreateOrUpdate(ctx, cl, obj, func() error {
		return f()
	})

	return result == ctrlutil.OperationResultCreated || result == ctrlutil.OperationResultUpdated, err
}

type PodDialer

type PodDialer struct {
	Namespace string
	Config    *rest.Config
	ClientSet kubernetes.Interface
	Transport http.RoundTripper
	Upgrader  spdy.Upgrader
	// contains filtered or unexported fields
}

PodDialer uses kubernetes' portforwarding protocol to create a net.Conn to a pod in the given kubernetes clusters

func NewPodDialer

func NewPodDialer(config *rest.Config, namespace string) (*PodDialer, error)

NewPodDialer creates a PodDailer that allows for a database connection to flow through a connection created by a kube-proxy like connection.

func (*PodDialer) Dial

func (k *PodDialer) Dial(network, addr string) (net.Conn, error)

Dial connects to a port in a kubernetes pod specified by addr. network must be TCP Implmentation adapted from:

https://github.com/kubernetes/kubernetes/blob/27c70773add99e43464a4e525e3bddfc8b602a3d/staging/src/k8s.io/client-go/tools/portforward/portforward.go
https://github.com/kubernetes/kubernetes/blob/27c70773add99e43464a4e525e3bddfc8b602a3d/staging/src/k8s.io/kubectl/pkg/cmd/portforward/portforward.go

func (*PodDialer) DialContext

func (k *PodDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*PodDialer) DialTimeout

func (k *PodDialer) DialTimeout(network, addr string, d time.Duration) (net.Conn, error)

DialTimeout implements pq.Dialer

Jump to

Keyboard shortcuts

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