v1

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 24 Imported by: 92

Documentation

Index

Constants

View Source
const (
	PodConditionTypeReady = core.PodConditionType("kubedb.com/Ready")
)

Variables

This section is empty.

Functions

func AddFinalizer

func AddFinalizer(m metav1.ObjectMeta, finalizer string) metav1.ObjectMeta

func CreateOrPatchEvent

func CreateOrPatchEvent(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Event) *core.Event, opts metav1.PatchOptions) (*core.Event, kutil.VerbType, error)

func CreateOrPatchNode

func CreateOrPatchNode(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Node) *core.Node, opts metav1.PatchOptions) (*core.Node, kutil.VerbType, error)

func CreateOrPatchPod

func CreateOrPatchPod(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Pod) *core.Pod, opts metav1.PatchOptions) (*core.Pod, kutil.VerbType, error)

func CreateOrPatchSecret

func CreateOrPatchSecret(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Secret) *core.Secret, opts metav1.PatchOptions, forceSyncType ...bool) (*core.Secret, kutil.VerbType, error)

func CreateOrPatchService

func CreateOrPatchService(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Service) *core.Service, opts metav1.PatchOptions) (*core.Service, kutil.VerbType, error)

func DeleteContainer

func DeleteContainer(containers []core.Container, name string) []core.Container

func EnsureContainerDeleted

func EnsureContainerDeleted(containers []core.Container, name string) []core.Container

func EnsureEnvVarDeleted

func EnsureEnvVarDeleted(vars []core.EnvVar, name string) []core.EnvVar

func EnsureOwnerReference

func EnsureOwnerReference(dependent metav1.Object, owner *metav1.OwnerReference)

EnsureOwnerReference adds owner if absent or syncs owner if already present.

If you are writing a controller or an operator, use the following code snippet for dependent objects. Here, `controller = true` and `blockOwnerDeletion = true`

owner := metav1.NewControllerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")) EnsureOwnerReference(dependent, owner)

If our CRD is not a controller but just want to be a owner, use the following code snippet. Here, `controller = false` and `blockOwnerDeletion = false`

owner := NewOwnerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")) EnsureOwnerReference(dependent, owner)

To understand the impact of `blockOwnerDeletion`, read: - https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#foreground-cascading-deletion - https://github.com/kubernetes/apimachinery/blob/v0.17.0/pkg/apis/meta/v1/types.go#L297-L323

func EnsureVolumeDeleted

func EnsureVolumeDeleted(volumes []core.Volume, name string) []core.Volume

func EnsureVolumeMountDeleted

func EnsureVolumeMountDeleted(mounts []core.VolumeMount, name string) []core.VolumeMount

func EnsureVolumeMountDeletedByPath

func EnsureVolumeMountDeletedByPath(mounts []core.VolumeMount, mountPath string) []core.VolumeMount

func GetContainerByName added in v0.25.41

func GetContainerByName(containers []core.Container, name string) *core.Container

func GetEnvByName added in v0.25.41

func GetEnvByName(envs []core.EnvVar, name string) *core.EnvVar

func GetPodCondition

func GetPodCondition(conditions []core.PodCondition, condType core.PodConditionType) (int, *core.PodCondition)

GetPodCondition returns a pointer to the desired condition referred by "condType". Otherwise, it returns nil.

func GetServiceAccountTokenSecret added in v0.25.36

func GetServiceAccountTokenSecret(kc kubernetes.Interface, sa types.NamespacedName) (*core.Secret, error)

func GetVolumeByName added in v0.25.41

func GetVolumeByName(volumes []core.Volume, name string) *core.Volume

func GetVolumeMountByName added in v0.25.41

func GetVolumeMountByName(volumeMounts []core.VolumeMount, name string) *core.VolumeMount

func HasFinalizer

func HasFinalizer(m metav1.ObjectMeta, finalizer string) bool

func HasPodCondition

func HasPodCondition(conditions []core.PodCondition, condType core.PodConditionType) bool

HasCondition returns "true" if the desired condition provided in "condType" is present in the condition list. Otherwise, it returns "false".

func IsMaster

func IsMaster(node core.Node) bool

IsMaster returns whether a node is a master.

func IsOwnedBy

func IsOwnedBy(dependent metav1.Object, owner metav1.Object) (owned bool, controller bool)

IsOwnedBy checks if the dependent has a owner reference to the given owner

func IsOwnerOfGroup

func IsOwnerOfGroup(ctrl *metav1.OwnerReference, group string) (bool, string, error)

func IsOwnerOfGroupKind

func IsOwnerOfGroupKind(ctrl *metav1.OwnerReference, group, kind string) (bool, error)

func IsPodConditionFalse

func IsPodConditionFalse(conditions []core.PodCondition, condType core.PodConditionType) bool

IsPodConditionFalse returns "true" if the desired condition is in false state. It returns "false" if the desired condition is not in "false" state or is not in the condition list.

func IsPodConditionTrue

func IsPodConditionTrue(conditions []core.PodCondition, condType core.PodConditionType) bool

IsPodConditionTrue returns "true" if the desired condition is in true state. It returns "false" if the desired condition is not in "true" state or is not in the condition list.

func IsPodReady

func IsPodReady(pod *core.Pod) bool

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

func IsServiceAccountToken

func IsServiceAccountToken(secret *core.Secret, sa *core.ServiceAccount) bool

IsServiceAccountToken returns true if the secret is a valid api token for the service account

func MergeLocalObjectReferences

func MergeLocalObjectReferences(l1, l2 []core.LocalObjectReference) []core.LocalObjectReference

func MergeServicePorts

func MergeServicePorts(cur, desired []core.ServicePort) []core.ServicePort

func MustReplaceVolumes

func MustReplaceVolumes(existing []core.Volume, desired ...core.Volume) []core.Volume

func NewOwnerRef

func NewOwnerRef(owner metav1.Object, gvk schema.GroupVersionKind) *metav1.OwnerReference

NewOwnerRef creates an OwnerReference pointing to the given owner.

func NodeReady

func NodeReady(node core.Node) bool

NodeReady returns whether a node is ready.

func ObfuscateSecret

func ObfuscateSecret(in core.Secret) *core.Secret

func PatchEvent

func PatchEvent(ctx context.Context, c kubernetes.Interface, cur *core.Event, transform func(*core.Event) *core.Event, opts metav1.PatchOptions) (*core.Event, kutil.VerbType, error)

func PatchEventObject

func PatchEventObject(ctx context.Context, c kubernetes.Interface, cur, mod *core.Event, opts metav1.PatchOptions) (*core.Event, kutil.VerbType, error)

func PatchNode

func PatchNode(ctx context.Context, c kubernetes.Interface, cur *core.Node, transform func(*core.Node) *core.Node, opts metav1.PatchOptions) (*core.Node, kutil.VerbType, error)

func PatchNodeObject

func PatchNodeObject(ctx context.Context, c kubernetes.Interface, cur, mod *core.Node, opts metav1.PatchOptions) (*core.Node, kutil.VerbType, error)

func PatchPod

func PatchPod(ctx context.Context, c kubernetes.Interface, cur *core.Pod, transform func(*core.Pod) *core.Pod, opts metav1.PatchOptions) (*core.Pod, kutil.VerbType, error)

func PatchPodObject

func PatchPodObject(ctx context.Context, c kubernetes.Interface, cur, mod *core.Pod, opts metav1.PatchOptions) (*core.Pod, kutil.VerbType, error)

func PatchSecret

func PatchSecret(ctx context.Context, c kubernetes.Interface, cur *core.Secret, transform func(*core.Secret) *core.Secret, opts metav1.PatchOptions) (*core.Secret, kutil.VerbType, error)

func PatchSecretObject

func PatchSecretObject(ctx context.Context, c kubernetes.Interface, cur, mod *core.Secret, opts metav1.PatchOptions) (*core.Secret, kutil.VerbType, error)

func PatchService

func PatchService(ctx context.Context, c kubernetes.Interface, cur *core.Service, transform func(*core.Service) *core.Service, opts metav1.PatchOptions) (*core.Service, kutil.VerbType, error)

func PatchServiceObject

func PatchServiceObject(ctx context.Context, c kubernetes.Interface, cur, mod *core.Service, opts metav1.PatchOptions) (*core.Service, kutil.VerbType, error)

func PodRunningAndReady

func PodRunningAndReady(pod core.Pod) (bool, error)

ref: https://github.com/coreos/prometheus-operator/blob/c79166fcff3dae7bb8bc1e6bddc81837c2d97c04/pkg/k8sutil/k8sutil.go#L64 PodRunningAndReady returns whether a pod is running and each container has passed it's ready state.

func RemoveFinalizer

func RemoveFinalizer(m metav1.ObjectMeta, finalizer string) metav1.ObjectMeta

func RemoveOwnerReference

func RemoveOwnerReference(dependent metav1.Object, owner metav1.Object)

func RemovePodCondition

func RemovePodCondition(conditions []core.PodCondition, condType core.PodConditionType) []core.PodCondition

RemovePodCondition remove a condition from the condition list referred by "condType" parameter.

func RemoveToleration

func RemoveToleration(tolerations []core.Toleration, key string) []core.Toleration

func ReplaceVolumes

func ReplaceVolumes(existing []core.Volume, desired ...core.Volume) ([]core.Volume, error)

func RestartPods

func RestartPods(ctx context.Context, c kubernetes.Interface, namespace string, selector *metav1.LabelSelector) error

func SetPodCondition

func SetPodCondition(conditions []core.PodCondition, newCondition core.PodCondition) []core.PodCondition

SetPodCondition add/update the desired condition to the condition list. It does nothing if the condition is already in its desired state.

func TryUpdateConfigMap

func TryUpdateConfigMap(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.ConfigMap) *core.ConfigMap, opts metav1.UpdateOptions) (result *core.ConfigMap, err error)

func TryUpdateEvent

func TryUpdateEvent(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Event) *core.Event, opts metav1.UpdateOptions) (result *core.Event, err error)

func TryUpdateNode

func TryUpdateNode(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Node) *core.Node, opts metav1.UpdateOptions) (result *core.Node, err error)

func TryUpdatePod

func TryUpdatePod(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Pod) *core.Pod, opts metav1.UpdateOptions) (result *core.Pod, err error)

func TryUpdateSecret

func TryUpdateSecret(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Secret) *core.Secret, opts metav1.UpdateOptions) (result *core.Secret, err error)

func TryUpdateService

func TryUpdateService(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Service) *core.Service, opts metav1.UpdateOptions) (result *core.Service, err error)

func TryUpdateServiceAccount

func TryUpdateServiceAccount(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.ServiceAccount) *core.ServiceAccount, opts metav1.UpdateOptions) (result *core.ServiceAccount, err error)

func UpsertContainer

func UpsertContainer(containers []core.Container, upsert core.Container) []core.Container

func UpsertContainers

func UpsertContainers(containers []core.Container, addons []core.Container) []core.Container

func UpsertEnvVars

func UpsertEnvVars(vars []core.EnvVar, nv ...core.EnvVar) []core.EnvVar

func UpsertImagePullSecrets added in v0.25.19

func UpsertImagePullSecrets(refs []core.LocalObjectReference, upsert ...core.LocalObjectReference) []core.LocalObjectReference

func UpsertPodReadinessGateConditionType

func UpsertPodReadinessGateConditionType(readinessGates []core.PodReadinessGate, conditionType core.PodConditionType) []core.PodReadinessGate

func UpsertToleration

func UpsertToleration(tolerations []core.Toleration, upsert core.Toleration) []core.Toleration

func UpsertVolume

func UpsertVolume(volumes []core.Volume, nv ...core.Volume) []core.Volume

func UpsertVolumeClaim

func UpsertVolumeClaim(volumeClaims []core.PersistentVolumeClaim, upsert core.PersistentVolumeClaim) []core.PersistentVolumeClaim

func UpsertVolumeMount

func UpsertVolumeMount(mounts []core.VolumeMount, nv ...core.VolumeMount) []core.VolumeMount

func UpsertVolumeMountByPath

func UpsertVolumeMountByPath(mounts []core.VolumeMount, nv core.VolumeMount) []core.VolumeMount

func WaitUntilPodDeletedBySelector

func WaitUntilPodDeletedBySelector(ctx context.Context, c kubernetes.Interface, namespace string, selector *metav1.LabelSelector) error

func WaitUntilPodRunning

func WaitUntilPodRunning(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilPodRunningBySelector

func WaitUntilPodRunningBySelector(ctx context.Context, c kubernetes.Interface, namespace string, selector *metav1.LabelSelector, count int) error

func WaitUntilRCReady

func WaitUntilRCReady(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error

func WaitUntilServiceDeletedBySelector

func WaitUntilServiceDeletedBySelector(ctx context.Context, c kubernetes.Interface, namespace string, selector *metav1.LabelSelector) error

func WaitUntillPodTerminatedByLabel

func WaitUntillPodTerminatedByLabel(ctx context.Context, c kubernetes.Interface, namespace string, label string) error

WaitUntillPodTerminatedByLabel waits until all pods with the label are terminated. Timeout is 5 minutes.

func WaitUntillServiceAccountDeleted

func WaitUntillServiceAccountDeleted(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error

Types

type Topology

type Topology struct {
	Regions       map[string][]string
	TotalNodes    int
	InstanceTypes map[string]int

	LabelZone         string
	LabelRegion       string
	LabelInstanceType string
}

func DetectTopology

func DetectTopology(ctx context.Context, mc metadata.Interface) (*Topology, error)

func (Topology) ConvertAffinity

func (t Topology) ConvertAffinity(affinity *core.Affinity)

Jump to

Keyboard shortcuts

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