kubernetes

package
v1.44.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrReplaceEnv added in v1.36.0

func CreateOrReplaceEnv(container *v1.Container, name, value string)

func GetContainerByName added in v1.40.0

func GetContainerByName(name string, deployment *appsv1.Deployment) *v1.Container

GetContainerByName returns a pointer to the Container within the given Deployment. If none found, returns nil.

func GetDeploymentUnavailabilityMessage added in v1.36.0

func GetDeploymentUnavailabilityMessage(deployment *appsv1.Deployment) string

GetDeploymentUnavailabilityMessage returns a string explaining why the given deployment is unavailable. If empty, there's no replica failure. Note that the Deployment might be available, but a second replica failed to scale. Always check IsDeploymentAvailable.

See: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#failed-deployment

func GetLastGeneration added in v1.40.0

func GetLastGeneration(namespace string, name string, c client.Client, ctx context.Context) int64

func IsDeploymentAvailable added in v1.35.0

func IsDeploymentAvailable(deployment *appsv1.Deployment) bool

IsDeploymentAvailable verifies if the Deployment conditions match the Available status

func IsDeploymentFailed added in v1.40.1

func IsDeploymentFailed(deployment *appsv1.Deployment) bool

IsDeploymentFailed returns true in case of Deployment not available (IsDeploymentAvailable returns false) or it has a condition of DeploymentReplicaFailure == true.

func IsDeploymentMinimumReplicasUnavailable added in v1.43.0

func IsDeploymentMinimumReplicasUnavailable(deployment *appsv1.Deployment) bool

IsDeploymentMinimumReplicasUnavailable verifies if the deployment has the minimum replicas available

func IsObjectNew added in v1.35.0

func IsObjectNew(object ctrl.Object) bool

IsObjectNew verifies if the given object hasn't been created in the cluster

func LoadResourceFromYaml

func LoadResourceFromYaml(scheme *runtime.Scheme, data string) (ctrl.Object, error)

LoadResourceFromYaml returns a Kubernetes resource from its serialized YAML definition.

func LoadUnstructuredFromYaml

func LoadUnstructuredFromYaml(data string) (ctrl.Object, error)

LoadUnstructuredFromYaml returns an unstructured resource from its serialized YAML definition.

func MarkDeploymentToRollout added in v1.35.0

func MarkDeploymentToRollout(deployment *appsv1.Deployment) error

MarkDeploymentToRollout marks the given Deployment to restart now. The object must be updated. Code adapted from here: https://github.com/kubernetes/kubectl/blob/release-1.26/pkg/polymorphichelpers/objectrestarter.go#L44

func ReplaceResource

func ReplaceResource(ctx context.Context, c client.Client, res ctrl.Object) (bool, error)

ReplaceResource allows to completely replace a resource on Kubernetes, taking care of immutable fields and resource versions.

func RetrieveServiceURL added in v1.40.0

func RetrieveServiceURL(service *v1.Service) (*apis.URL, error)

RetrieveServiceURL function that based on the service name, namespace and eventually the nodeport, will provide the service URI

func SecurityDefaults added in v1.37.0

func SecurityDefaults() *corev1.SecurityContext

func ToTypedLocalReference added in v1.40.0

func ToTypedLocalReference(object ctrl.Object) *v1.TypedLocalObjectReference

ToTypedLocalReference ...

func VolumeAddVolumeProjectionConfigMap added in v1.40.0

func VolumeAddVolumeProjectionConfigMap(volumes []corev1.Volume, cmName, mountName string) []corev1.Volume

VolumeAddVolumeProjectionConfigMap adds a new ConfigMapProjection to the given Volume array. It looks for the given mount name in the Volume array. If finds it, adds a new projection for the given ConfigMap. If it doesn't find it, adds a new VolumeSource and the projection to it.

func VolumeConfigMap added in v1.40.0

func VolumeConfigMap(name string, cmName string, items ...corev1.KeyToPath) corev1.Volume

VolumeConfigMap creates a new Volume referencing the given ConfigMap name.

func VolumeMount added in v1.37.0

func VolumeMount(name string, readonly bool, mountPath string) corev1.VolumeMount

func VolumeMountAdd added in v1.40.0

func VolumeMountAdd(volumeMount []corev1.VolumeMount, name, mountPath string) []corev1.VolumeMount

VolumeMountAdd adds a new VolumeMount to the given collection. If there's already a VolumeMount with the same mount path, the function overrides the name.

func VolumeProjectionAddConfigMap added in v1.40.0

func VolumeProjectionAddConfigMap(volumeSource *corev1.ProjectedVolumeSource, cmName string, items ...corev1.KeyToPath)

VolumeProjectionAddConfigMap adds the given ConfigMap to the ProjectedVolumeSource sources. Overrides the items if already exists in the list.

Types

type Collection

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

A Collection is a container of Kubernetes resources.

func NewCollection

func NewCollection(objects ...ctrl.Object) *Collection

NewCollection creates a new empty collection.

func (*Collection) Add

func (c *Collection) Add(resource ctrl.Object)

Add adds a resource to the collection.

func (*Collection) AddAll

func (c *Collection) AddAll(resource []ctrl.Object)

AddAll adds all resources to the collection.

func (*Collection) AddFirst

func (c *Collection) AddFirst(resource ctrl.Object)

AddFirst adds a resource to the head of the collection.

func (*Collection) AsKubernetesList

func (c *Collection) AsKubernetesList() *corev1.List

AsKubernetesList returns all resources wrapped in a Kubernetes list.

func (*Collection) GetConfigMap

func (c *Collection) GetConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap

GetConfigMap returns a ConfigMap that matches the given function.

func (*Collection) GetContainer

func (c *Collection) GetContainer(filter func(container *corev1.Container) bool) *corev1.Container

GetContainer --.

func (*Collection) GetContainerByName

func (c *Collection) GetContainerByName(name string) *corev1.Container

GetContainerByName --.

func (*Collection) GetController

func (c *Collection) GetController(filter func(object ctrl.Object) bool) ctrl.Object

GetController returns the controller associated with the workflow (e.g. Deployment).

func (*Collection) GetCronJob

func (c *Collection) GetCronJob(filter func(job *batchv1.CronJob) bool) *batchv1.CronJob

GetCronJob returns a CronJob that matches the given function.

func (*Collection) GetDeployment

func (c *Collection) GetDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment

GetDeployment returns a Deployment that matches the given function.

func (*Collection) GetDeploymentForWorkflow

func (c *Collection) GetDeploymentForWorkflow(workflow *operatorapi.SonataFlow) *appsv1.Deployment

GetDeploymentForWorkflow returns a Deployment for the given workflow.

func (*Collection) GetPodMonitor

func (c *Collection) GetPodMonitor(filter func(*monitoringv1.PodMonitor) bool) *monitoringv1.PodMonitor

func (*Collection) GetRoute

func (c *Collection) GetRoute(filter func(*routev1.Route) bool) *routev1.Route

GetRoute returns a Route that matches the given function.

func (*Collection) GetService

func (c *Collection) GetService(filter func(*corev1.Service) bool) *corev1.Service

GetService returns a Service that matches the given function.

func (*Collection) GetServiceForWorkflow

func (c *Collection) GetServiceForWorkflow(workflow *operatorapi.SonataFlow) *corev1.Service

GetServiceForWorkflow returns a user Service for the given workflow.

func (*Collection) HasDeployment

func (c *Collection) HasDeployment(filter func(*appsv1.Deployment) bool) bool

HasDeployment returns true if a deployment matching the given condition is present.

func (*Collection) Items

func (c *Collection) Items() []ctrl.Object

Items returns all resources belonging to the collection.

func (*Collection) Remove

func (c *Collection) Remove(selector func(runtime.Object) bool) runtime.Object

Remove removes the given element from the collection and returns it.

func (*Collection) RemoveConfigMap

func (c *Collection) RemoveConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap

RemoveConfigMap removes and returns a ConfigMap that matches the given function.

func (*Collection) RemoveDeployment

func (c *Collection) RemoveDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment

RemoveDeployment removes and returns a Deployment that matches the given function.

func (*Collection) Size

func (c *Collection) Size() int

Size returns the number of resources belonging to the collection.

func (*Collection) Visit

func (c *Collection) Visit(visitor func(runtime.Object))

Visit executes the visitor function on all resources.

func (*Collection) VisitConfigMap

func (c *Collection) VisitConfigMap(visitor func(*corev1.ConfigMap))

VisitConfigMap executes the visitor function on all ConfigMap resources.

func (*Collection) VisitContainer

func (c *Collection) VisitContainer(visitor func(container *corev1.Container))

VisitContainer executes the visitor function on all Containers inside deployments or other resources.

func (*Collection) VisitCronJob

func (c *Collection) VisitCronJob(visitor func(*batchv1.CronJob))

VisitCronJob executes the visitor function on all CronJob resources.

func (*Collection) VisitCronJobE

func (c *Collection) VisitCronJobE(visitor func(*batchv1.CronJob) error) error

VisitCronJobE executes the visitor function on all CronJob resources.

func (*Collection) VisitDeployment

func (c *Collection) VisitDeployment(visitor func(*appsv1.Deployment))

VisitDeployment executes the visitor function on all Deployment resources.

func (*Collection) VisitDeploymentE

func (c *Collection) VisitDeploymentE(visitor func(*appsv1.Deployment) error) error

VisitDeploymentE executes the visitor function on all Deployment resources.

func (*Collection) VisitE

func (c *Collection) VisitE(visitor func(runtime.Object) error) error

VisitE executes the visitor function on all resources breaking if the visitor function returns an error.

func (*Collection) VisitMetaObject

func (c *Collection) VisitMetaObject(visitor func(metav1.Object))

VisitMetaObject executes the visitor function on all meta.Object resources.

func (*Collection) VisitPodMonitor

func (c *Collection) VisitPodMonitor(visitor func(*monitoringv1.PodMonitor))

func (*Collection) VisitPodSpec

func (c *Collection) VisitPodSpec(visitor func(container *corev1.PodSpec))

VisitPodSpec executes the visitor function on all PodSpec inside deployments or other resources.

func (*Collection) VisitPodTemplateMeta

func (c *Collection) VisitPodTemplateMeta(visitor func(meta *metav1.ObjectMeta))

VisitPodTemplateMeta executes the visitor function on all PodTemplate metadata inside deployments or other resources.

func (*Collection) VisitRoute

func (c *Collection) VisitRoute(visitor func(*routev1.Route))

VisitRoute executes the visitor function on all Route resources.

func (*Collection) VisitService

func (c *Collection) VisitService(visitor func(*corev1.Service))

VisitService executes the visitor function on all Service resources.

type DeploymentUnavailabilityReader added in v1.43.0

type DeploymentUnavailabilityReader interface {
	// ReasonMessage returns the reason message in string format fetched from the culprit resource. For example, a Container status.
	ReasonMessage() (string, error)
}

DeploymentUnavailabilityReader implementations find the reason behind a deployment failure

func DeploymentTroubleshooter added in v1.43.0

func DeploymentTroubleshooter(client client.Client, deployment *v1.Deployment, container string) DeploymentUnavailabilityReader

DeploymentTroubleshooter creates a new DeploymentUnavailabilityReader for finding out why a deployment failed

Jump to

Keyboard shortcuts

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