Documentation ¶
Index ¶
- func AddEnvIfNotPresent(container *v1.Container, envVar v1.EnvVar) bool
- func AddOrReplaceContainer(containerName string, container v1.Container, podSpec *v1.PodSpec)
- func AddOrReplaceEnvVar(container *corev1.Container, envs ...corev1.EnvVar)
- func AddOrReplaceVolume(podSpec *corev1.PodSpec, volumes ...corev1.Volume)
- func AddOrReplaceVolumeMount(container *corev1.Container, mounts ...corev1.VolumeMount)
- func AnnotateDeploymentConfigChecksum(workflow *operatorapi.SonataFlow, deployment *appsv1.Deployment, ...) error
- func CreateOrReplaceEnv(container *v1.Container, name, value string)
- func GetAnnotationAsBool(object client.Object, key string) bool
- func GetContainerByName(name string, podSpec *v1.PodSpec) (*v1.Container, int)
- func GetContainerPortByName(name string, container *v1.Container) (*v1.ContainerPort, int)
- func GetDeploymentUnavailabilityMessage(deployment *appsv1.Deployment) string
- func GetImagePullPolicy(imageTag string) corev1.PullPolicy
- func GetImageTag(imageTag string) string
- func GetServicePortByName(name string, service *v1.Service) (*v1.ServicePort, int)
- func IsDeploymentAvailable(deployment *appsv1.Deployment) bool
- func IsDeploymentFailed(deployment *appsv1.Deployment) bool
- func IsDeploymentMinimumReplicasUnavailable(deployment *appsv1.Deployment) bool
- func IsObjectNew(object ctrl.Object) bool
- func LoadResourceFromYaml(scheme *runtime.Scheme, data string) (ctrl.Object, error)
- func LoadUnstructuredFromYaml(data string) (ctrl.Object, error)
- func MarkDeploymentToRollout(deployment *appsv1.Deployment) error
- func MustSafeDNS1035(prefix, s string) string
- func ReplaceResource(ctx context.Context, c client.Client, res ctrl.Object) (bool, error)
- func RetrieveServiceURL(service *v1.Service) (*apis.URL, error)
- func SafeDNS1035(prefix, s string) (string, error)
- func SecurityDefaults() *corev1.SecurityContext
- func SetAnnotation(object client.Object, key, value string)
- func ToTypedLocalReference(object ctrl.Object) *v1.TypedLocalObjectReference
- func VolumeAddVolumeProjectionConfigMap(volumes []corev1.Volume, cmName, mountName string) []corev1.Volume
- func VolumeConfigMap(name string, cmName string, items ...corev1.KeyToPath) corev1.Volume
- func VolumeMount(name string, readonly bool, mountPath string) corev1.VolumeMount
- func VolumeMountAdd(volumeMount []corev1.VolumeMount, name, mountPath string) []corev1.VolumeMount
- func VolumeProjectionAddConfigMap(volumeSource *corev1.ProjectedVolumeSource, cmName string, ...)
- type Collection
- func (c *Collection) Add(resource ctrl.Object)
- func (c *Collection) AddAll(resource []ctrl.Object)
- func (c *Collection) AddFirst(resource ctrl.Object)
- func (c *Collection) AsKubernetesList() *corev1.List
- func (c *Collection) GetConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap
- func (c *Collection) GetContainer(filter func(container *corev1.Container) bool) *corev1.Container
- func (c *Collection) GetContainerByName(name string) *corev1.Container
- func (c *Collection) GetController(filter func(object ctrl.Object) bool) ctrl.Object
- func (c *Collection) GetCronJob(filter func(job *batchv1.CronJob) bool) *batchv1.CronJob
- func (c *Collection) GetDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment
- func (c *Collection) GetDeploymentForWorkflow(workflow *operatorapi.SonataFlow) *appsv1.Deployment
- func (c *Collection) GetPodMonitor(filter func(*monitoringv1.PodMonitor) bool) *monitoringv1.PodMonitor
- func (c *Collection) GetRoute(filter func(*routev1.Route) bool) *routev1.Route
- func (c *Collection) GetService(filter func(*corev1.Service) bool) *corev1.Service
- func (c *Collection) GetServiceForWorkflow(workflow *operatorapi.SonataFlow) *corev1.Service
- func (c *Collection) HasDeployment(filter func(*appsv1.Deployment) bool) bool
- func (c *Collection) Items() []ctrl.Object
- func (c *Collection) Remove(selector func(runtime.Object) bool) runtime.Object
- func (c *Collection) RemoveConfigMap(filter func(*corev1.ConfigMap) bool) *corev1.ConfigMap
- func (c *Collection) RemoveDeployment(filter func(*appsv1.Deployment) bool) *appsv1.Deployment
- func (c *Collection) Size() int
- func (c *Collection) Visit(visitor func(runtime.Object))
- func (c *Collection) VisitConfigMap(visitor func(*corev1.ConfigMap))
- func (c *Collection) VisitContainer(visitor func(container *corev1.Container))
- func (c *Collection) VisitCronJob(visitor func(*batchv1.CronJob))
- func (c *Collection) VisitCronJobE(visitor func(*batchv1.CronJob) error) error
- func (c *Collection) VisitDeployment(visitor func(*appsv1.Deployment))
- func (c *Collection) VisitDeploymentE(visitor func(*appsv1.Deployment) error) error
- func (c *Collection) VisitE(visitor func(runtime.Object) error) error
- func (c *Collection) VisitMetaObject(visitor func(metav1.Object))
- func (c *Collection) VisitPodMonitor(visitor func(*monitoringv1.PodMonitor))
- func (c *Collection) VisitPodSpec(visitor func(container *corev1.PodSpec))
- func (c *Collection) VisitPodTemplateMeta(visitor func(meta *metav1.ObjectMeta))
- func (c *Collection) VisitRoute(visitor func(*routev1.Route))
- func (c *Collection) VisitService(visitor func(*corev1.Service))
- type DeploymentUnavailabilityReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEnvIfNotPresent ¶
AddEnvIfNotPresent Adds and env variable to a container if not already present. Returns true if the variable didn't exist and was added, false in any other case.
func AddOrReplaceContainer ¶
AddOrReplaceContainer replace the existing container or add if it doesn't exist in the .spec.containers attribute
func AddOrReplaceEnvVar ¶
AddOrReplaceEnvVar adds or removes the given env variables to the PodSpec. If there's already an env variable with the same name, it's replaced.
func AddOrReplaceVolume ¶
AddOrReplaceVolume adds or removes the given volumes to the PodSpec. If there's already a volume with the same name, it's replaced.
func AddOrReplaceVolumeMount ¶
func AddOrReplaceVolumeMount(container *corev1.Container, mounts ...corev1.VolumeMount)
AddOrReplaceVolumeMount same as AddOrReplaceVolume, but with VolumeMounts in a specific container
func AnnotateDeploymentConfigChecksum ¶
func AnnotateDeploymentConfigChecksum(workflow *operatorapi.SonataFlow, deployment *appsv1.Deployment, userPropsCM *v1.ConfigMap, managedPropsCM *v1.ConfigMap) error
AnnotateDeploymentConfigChecksum adds the checksum/config annotation to the template annotations of the Deployment to set the current configuration. If the checksum has changed from the previous value, the restartedAt annotation is also added and a new rollout is started. Code adapted from here: https://github.com/kubernetes/kubectl/blob/release-1.26/pkg/polymorphichelpers/objectrestarter.go#L44
func CreateOrReplaceEnv ¶
func GetAnnotationAsBool ¶
GetAnnotationAsBool returns the boolean value from the given annotation. If the annotation is not present or is there an error in the ParseBool conversion, returns false.
func GetContainerByName ¶
GetContainerByName returns a pointer to the Container within the given Deployment. If none found, returns nil. It also returns the position where the container was found, -1 if none
func GetContainerPortByName ¶
GetContainerPortByName returns a pointer to the ContainerPort within the given Container. If none found, returns nil. It also returns the position where the container port was found, -1 if none.
func GetDeploymentUnavailabilityMessage ¶
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 GetImagePullPolicy ¶
func GetImagePullPolicy(imageTag string) corev1.PullPolicy
GetImagePullPolicy gets the default corev1.PullPolicy depending on the image tag specified. It follows the conventions of docker client and OpenShift. If no tag specified, it assumes latest. Returns PullAlways if latest tag, empty otherwise to let the cluster figure it out. See: https://kubernetes.io/docs/concepts/containers/images/#updating-images
func GetImageTag ¶
GetImageTag gets the tag after `:` in an image tag or empty if not found.
func GetServicePortByName ¶
GetServicePortByName returns a pointer to the ServicePort within the given Service. If none found, returns nil. It also returns the position where the service port por was found, -1 if none.
func IsDeploymentAvailable ¶
func IsDeploymentAvailable(deployment *appsv1.Deployment) bool
IsDeploymentAvailable verifies if the Deployment conditions match the Available status
func IsDeploymentFailed ¶
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 ¶
func IsDeploymentMinimumReplicasUnavailable(deployment *appsv1.Deployment) bool
IsDeploymentMinimumReplicasUnavailable verifies if the deployment has the minimum replicas available
func IsObjectNew ¶
IsObjectNew verifies if the given object hasn't been created in the cluster
func LoadResourceFromYaml ¶
LoadResourceFromYaml returns a Kubernetes resource from its serialized YAML definition.
func LoadUnstructuredFromYaml ¶
LoadUnstructuredFromYaml returns an unstructured resource from its serialized YAML definition.
func MarkDeploymentToRollout ¶
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 MustSafeDNS1035 ¶
MustSafeDNS1035 see SafeDNS1035. Use this function only if you control the prefix.
func ReplaceResource ¶
ReplaceResource allows to completely replace a resource on Kubernetes, taking care of immutable fields and resource versions.
func RetrieveServiceURL ¶
RetrieveServiceURL function that based on the service name, namespace and eventually the nodeport, will provide the service URI
func SafeDNS1035 ¶
SafeDNS1035 generates a safe encoded string based on "s" with the given prefix. Ideally used with internal generated names.
See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names
func SecurityDefaults ¶
func SecurityDefaults() *corev1.SecurityContext
func SetAnnotation ¶
SetAnnotation Safely set the annotation to the object
func ToTypedLocalReference ¶
func ToTypedLocalReference(object ctrl.Object) *v1.TypedLocalObjectReference
ToTypedLocalReference ...
func VolumeAddVolumeProjectionConfigMap ¶
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 ¶
VolumeConfigMap creates a new Volume referencing the given ConfigMap name.
func VolumeMount ¶
func VolumeMount(name string, readonly bool, mountPath string) corev1.VolumeMount
func VolumeMountAdd ¶
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 ¶
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 ¶
GetConfigMap returns a ConfigMap that matches the given function.
func (*Collection) GetContainer ¶
GetContainer --.
func (*Collection) GetContainerByName ¶
func (c *Collection) GetContainerByName(name string) *corev1.Container
GetContainerByName --.
func (*Collection) GetController ¶
GetController returns the controller associated with the workflow (e.g. Deployment).
func (*Collection) GetCronJob ¶
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) GetService ¶
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) RemoveConfigMap ¶
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 ¶
DeploymentUnavailabilityReader implementations find the reason behind a deployment failure
func DeploymentTroubleshooter ¶
func DeploymentTroubleshooter(client client.Client, deployment *v1.Deployment, container string) DeploymentUnavailabilityReader
DeploymentTroubleshooter creates a new DeploymentUnavailabilityReader for finding out why a deployment failed