Documentation ¶
Overview ¶
Package framework contains structures and functions to handle operator SDK and controllers specificness
Index ¶
- Constants
- Variables
- func AddIstioInjectSidecarAnnotation(objectMeta *metav1.ObjectMeta)
- func AddOwnerReference(owner resource.KubernetesResource, scheme *runtime.Scheme, ...) error
- func AddVolumeToDeployment(deployment *appsv1.Deployment, mount v1.VolumeMount, volume v1.Volume)
- func ConvertImageTagToImage(imageName string) api.Image
- func ConvertImageToImageTag(image api.Image) string
- func CreateBuildConfigComparator() ...
- func CreateConfigMapComparator() ...
- func CreateDeploymentComparator() ...
- func CreateDeploymentConfigComparator() ...
- func CreateEnvVar(key string, value string) corev1.EnvVar
- func CreateImageStreamComparator() ...
- func CreatePKCS12TrustStoreFromSecret(secret *v1.Secret, password string, keys ...string) ([]byte, error)
- func CreateRouteComparator() ...
- func CreateSecretEnvVar(variableName, secretName, secretKey string) corev1.EnvVar
- func CreateServiceComparator() ...
- func CreateServiceMonitorComparator() ...
- func CreateSharedImageStreamComparator() ...
- func DiffEnvVar(env1 []corev1.EnvVar, env2 []corev1.EnvVar) []corev1.EnvVar
- func DiscoverPortsAndProbesFromImage(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage)
- func EnvOverride(dst []corev1.EnvVar, src ...corev1.EnvVar) []corev1.EnvVar
- func ExtractPortsFromContainer(container *corev1.Container) []corev1.ServicePort
- func ExtractPrometheusConfigurationFromImage(dockerImage *dockerv10.DockerImage) (scrape bool, scheme string, path string, port *intstr.IntOrString, err error)
- func GetEnvVar(envName string, env []corev1.EnvVar) int
- func GetEnvVarFromContainer(key string, container *corev1.Container) string
- func GetLatestDeploymentCondition(conditions []v1.DeploymentCondition) *v1.DeploymentCondition
- func GetResource(resourceType reflect.Type, name string, ...) utilsres.KubernetesResource
- func GetSubscription(cli *client.Client, namespace, packageName, catalogSource string) (*olmapiv1alpha1.Subscription, error)
- func IsOwner(resource resource.KubernetesResource, owner resource.KubernetesResource) bool
- func IsPersistenceEnabled(dockerImage *dockerv10.DockerImage) (enabled bool)
- func IsSafeToRollOutDeploymentConfig(dc *v1.DeploymentConfig) bool
- func MergeImageMetadataWithDeploymentConfig(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage) bool
- func RemoveOwnerReference(owner resource.KubernetesResource, resources ...resource.KubernetesResource)
- func SetEnvVar(key, value string, container *corev1.Container)
- func SetEnvVarFromSecret(key, secretKey string, secret *corev1.Secret, container *corev1.Container)
- func SetOwner(owner resource.KubernetesResource, scheme *runtime.Scheme, ...) error
- func SplitImageTag(imageTag string) (domain, namespace, name, tag string)
- type Comparator
- type ComparatorBuilder
Constants ¶
const ( // DefaultExportedPort is the default protocol exposed by inner services specified in image metadata DefaultExportedPort = "http" // DefaultExposedPort TODO: found an agnostic API to fetch the ImageRaw from the docker image and read this value from there. DefaultExposedPort = 8080 // LabelKeyOrgKie is the label key for KIE metadata LabelKeyOrgKie = "org.kie" + labelNamespaceSep // LabelKeyOrgKiePersistence is the label key for Persistence metadata LabelKeyOrgKiePersistence = LabelKeyOrgKie + "persistence" // LabelKeyOrgKiePersistenceRequired is the label key to check if persistence is enabled or not LabelKeyOrgKiePersistenceRequired = LabelKeyOrgKiePersistence + labelNamespaceSep + "required" // LabelKeyPrometheus is the label key for Prometheus metadata LabelKeyPrometheus = "prometheus.io" // LabelPrometheusScrape is the label key for prometheus scrape configuration LabelPrometheusScrape = LabelKeyPrometheus + "/scrape" // LabelPrometheusPath is the label key for prometheus metrics path LabelPrometheusPath = LabelKeyPrometheus + "/path" // LabelPrometheusPort is the label key for prometheus metrics port LabelPrometheusPort = LabelKeyPrometheus + "/port" // LabelPrometheusScheme is the label key for Prometheus metrics endpoint scheme LabelPrometheusScheme = LabelKeyPrometheus + "/scheme" )
const (
// LabelAppKey is the default label key to bind resources together in "Application Group"
LabelAppKey = "app"
)
Variables ¶
var ( // ModeForCertificates unix file mode for certificates. ModeForCertificates = int32(0640) // ModeForPropertyFiles unix file mode for application property files. ModeForPropertyFiles = int32(0644) // ModeForProtoBufConfigMapVolume mode for Proto Buf config map volume ModeForProtoBufConfigMapVolume = int32(0644) )
var ( // DockerTagRegxCompiled is the compiled regex to verify docker tag names DockerTagRegxCompiled = *regexp.MustCompile(dockerTagRegx) )
Functions ¶
func AddIstioInjectSidecarAnnotation ¶
func AddIstioInjectSidecarAnnotation(objectMeta *metav1.ObjectMeta)
AddIstioInjectSidecarAnnotation adds the annotation to be read by the Istio operator to setup sidecars in the given Pod
func AddOwnerReference ¶
func AddOwnerReference(owner resource.KubernetesResource, scheme *runtime.Scheme, resources ...resource.KubernetesResource) error
AddOwnerReference adds given owner as a OwnerReference in the given resources
func AddVolumeToDeployment ¶
func AddVolumeToDeployment(deployment *appsv1.Deployment, mount v1.VolumeMount, volume v1.Volume)
AddVolumeToDeployment adds the Volume and VolumeMount to the given first container of v1.Deployment.
func ConvertImageTagToImage ¶
ConvertImageTagToImage converts a plain string into an Image structure. For example, see https://regex101.com/r/1YX9rh/1.
func ConvertImageToImageTag ¶
ConvertImageToImageTag converts an Image into a plain string (domain/namespace/name:tag).
func CreateBuildConfigComparator ¶
func CreateBuildConfigComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateBuildConfigComparator creates a new comparator for BuildConfig using Label, Trigger and SourceStrategy
func CreateConfigMapComparator ¶
func CreateConfigMapComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateConfigMapComparator creates a new comparator for ConfigMap using Label
func CreateDeploymentComparator ¶
func CreateDeploymentComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateDeploymentComparator creates a new comparator for Deployment sorting volumes
func CreateDeploymentConfigComparator ¶
func CreateDeploymentConfigComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateDeploymentConfigComparator creates a new comparator for DeploymentConfig using Trigger and RollingParams
func CreateEnvVar ¶
CreateEnvVar will create EnvVar value for provided key/value pair
func CreateImageStreamComparator ¶
func CreateImageStreamComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateImageStreamComparator creates a new ImageStream comparator
func CreatePKCS12TrustStoreFromSecret ¶
func CreatePKCS12TrustStoreFromSecret(secret *v1.Secret, password string, keys ...string) ([]byte, error)
CreatePKCS12TrustStoreFromSecret creates a PCKS12 with certificates inside a Kubernetes secret. The `keys` parameter must contain public certificates only.
func CreateRouteComparator ¶
func CreateRouteComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateRouteComparator creates a new comparator for Route using Label
func CreateSecretEnvVar ¶
CreateSecretEnvVar will create EnvVar value to hold SecretKey for given secret key/name
func CreateServiceComparator ¶
func CreateServiceComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateServiceComparator creates a new comparator for Service skipping ClusterIPs
func CreateServiceMonitorComparator ¶
func CreateServiceMonitorComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateServiceMonitorComparator creates a new comparator for ServiceMonitor using Label
func CreateSharedImageStreamComparator ¶
func CreateSharedImageStreamComparator() func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool
CreateSharedImageStreamComparator creates a new Shared ImageStream comparator that verifies if the OwnerReferences are equal between them Also incorporates the `CreateImageStreamComparator` logic
func DiffEnvVar ¶
DiffEnvVar returns elements in `env1` that are not in `env2`
func DiscoverPortsAndProbesFromImage ¶
func DiscoverPortsAndProbesFromImage(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage)
DiscoverPortsAndProbesFromImage set Ports and Probes based on labels set on the DockerImage of this DeploymentConfig
func EnvOverride ¶
EnvOverride replaces or appends the provided EnvVar to the collection
func ExtractPortsFromContainer ¶
func ExtractPortsFromContainer(container *corev1.Container) []corev1.ServicePort
ExtractPortsFromContainer converts ports defined in the given container to ServicePorts
func ExtractPrometheusConfigurationFromImage ¶
func ExtractPrometheusConfigurationFromImage(dockerImage *dockerv10.DockerImage) (scrape bool, scheme string, path string, port *intstr.IntOrString, err error)
ExtractPrometheusConfigurationFromImage retrieves prometheus configurations from the prometheus.io labels of the dockerImage
func GetEnvVarFromContainer ¶
GetEnvVarFromContainer gets the environment variable value from the container
func GetLatestDeploymentCondition ¶
func GetLatestDeploymentCondition(conditions []v1.DeploymentCondition) *v1.DeploymentCondition
GetLatestDeploymentCondition returns the latest condition of the array based on the LastUpdateTime field
func GetResource ¶
func GetResource(resourceType reflect.Type, name string, resources map[reflect.Type][]utilsres.KubernetesResource) utilsres.KubernetesResource
GetResource walks on KubernetesResource map and returns the object for the given name and type
func GetSubscription ¶
func GetSubscription(cli *client.Client, namespace, packageName, catalogSource string) (*olmapiv1alpha1.Subscription, error)
GetSubscription returns subscription or nil if no subscription is found.
func IsOwner ¶
func IsOwner(resource resource.KubernetesResource, owner resource.KubernetesResource) bool
IsOwner checks if the given owner is in the `ownerReferences` of the given resource
func IsPersistenceEnabled ¶
func IsPersistenceEnabled(dockerImage *dockerv10.DockerImage) (enabled bool)
IsPersistenceEnabled verifies if the image has labels indicating that persistence is enabled
func IsSafeToRollOutDeploymentConfig ¶
func IsSafeToRollOutDeploymentConfig(dc *v1.DeploymentConfig) bool
IsSafeToRollOutDeploymentConfig checks if the given `DeploymentConfig` has successfully rolled out to the latest version, thus it's safe to perform a new roll out
func MergeImageMetadataWithDeploymentConfig ¶
func MergeImageMetadataWithDeploymentConfig(dc *appsv1.DeploymentConfig, dockerImage *dockerv10.DockerImage) bool
MergeImageMetadataWithDeploymentConfig retrieves org.kie and prometheus.io labels from DockerImage and adds them to the DeploymentConfig returns true if any changes occurred in the deploymentConfig based on the dockerImage labels
func RemoveOwnerReference ¶
func RemoveOwnerReference(owner resource.KubernetesResource, resources ...resource.KubernetesResource)
RemoveOwnerReference remove given owner from OwnerReference in the given resources
func SetEnvVarFromSecret ¶
SetEnvVarFromSecret will set the Environment Variable from a Secret
func SetOwner ¶
func SetOwner(owner resource.KubernetesResource, scheme *runtime.Scheme, resources ...resource.KubernetesResource) error
SetOwner sets the given owner object into the given resources
func SplitImageTag ¶
SplitImageTag breaks into parts a given tag name, adds "latest" to the tag name if it's empty. For example, see https://regex101.com/r/1YX9rh/1.
Types ¶
type Comparator ¶
type Comparator struct { ResourceType reflect.Type CompFunc func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool }
Comparator is a simple struct to encapsulate the complex elements from Operator Utils
type ComparatorBuilder ¶
type ComparatorBuilder interface { // WithCustomComparator it's the custom comparator function that will get called by the Operator Utils WithCustomComparator(customComparator func(deployed resource.KubernetesResource, requested resource.KubernetesResource) (equal bool)) ComparatorBuilder // WithType defines the comparator resource type WithType(resourceType reflect.Type) ComparatorBuilder // UseDefaultComparator defines if the comparator will delegate the comparision to inner comparators from Operator Utils UseDefaultComparator() ComparatorBuilder // Build creates the Comparator in the form of Operator Utils interface Build() (reflect.Type, func(deployed resource.KubernetesResource, requested resource.KubernetesResource) bool) }
ComparatorBuilder creates Comparators to be used during reconciliation phases
func NewComparatorBuilder ¶
func NewComparatorBuilder() ComparatorBuilder
NewComparatorBuilder creates a new comparator builder for comparision usages