Documentation ¶
Index ¶
- Constants
- Variables
- func AddDeploymentLabels(d *appsv1.Deployment, labels map[string]string) bool
- func AddInstallerLabel(u *unstructured.Unstructured, name string, ns string)
- func AddInstallerLabels(l map[string]string, name string, ns string) map[string]string
- func AddPodLabels(d *appsv1.Deployment, labels map[string]string) bool
- func AnnotationsMatch(old, new map[string]string) bool
- func AppendProxyVariables(existing []corev1.EnvVar, added []corev1.EnvVar) []corev1.EnvVar
- func CertManagerNS(m *operatorsv1.MultiClusterHub) string
- func Contains(s []string, e string) bool
- func ContainsMap(all map[string]string, expected map[string]string) bool
- func ContainsPullSecret(pullSecrets []corev1.LocalObjectReference, ps corev1.LocalObjectReference) bool
- func CoreToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)
- func DeduplicateComponents(m *operatorsv1.MultiClusterHub) bool
- func DefaultReplicaCount(mch *operatorsv1.MultiClusterHub) int
- func DistributePods(key string, value string) *corev1.Affinity
- func FormatSSLCiphers(ciphers []string) string
- func GetContainerArgs(dep *appsv1.Deployment) []string
- func GetContainerEnvVars(dep *appsv1.Deployment) []corev1.EnvVar
- func GetContainerRequestResources(dep *appsv1.Deployment) corev1.ResourceList
- func GetContainerVolumeMounts(dep *appsv1.Deployment) []corev1.VolumeMount
- func GetContainerVolumes(dep *appsv1.Deployment) []corev1.Volume
- func GetCustomResources(m *operatorsv1.MultiClusterHub) []types.NamespacedName
- func GetCustomResourcesForStatus(m *operatorsv1.MultiClusterHub) []types.NamespacedName
- func GetDeployments(m *operatorsv1.MultiClusterHub) []types.NamespacedName
- func GetDeploymentsForStatus(m *operatorsv1.MultiClusterHub, ocpConsole, isSTSEnabled bool) []types.NamespacedName
- func GetDisableClusterImageSets(m *operatorsv1.MultiClusterHub) string
- func GetHubSize(instance *operatorsv1.MultiClusterHub) operatorsv1.HubSize
- func GetImageOverridesConfigmapName(instance *operatorsv1.MultiClusterHub) string
- func GetImagePullPolicy(m *operatorsv1.MultiClusterHub) corev1.PullPolicy
- func GetImageRepository(instance *operatorsv1.MultiClusterHub) string
- func GetMCEAnnotationOverrides(instance *operatorsv1.MultiClusterHub) string
- func GetMCEComponents(mch *operatorsv1.MultiClusterHub) []mcev1.ComponentConfig
- func GetOADPAnnotationOverrides(instance *operatorsv1.MultiClusterHub) string
- func GetTemplateOverridesConfigmapName(instance *operatorsv1.MultiClusterHub) string
- func GetTestImages() []string
- func GetTolerations(m *operatorsv1.MultiClusterHub) []corev1.Toleration
- func HasAnnotation(instance *operatorsv1.MultiClusterHub, annotationKey string) bool
- func IsAnnotationTrue(instance *operatorsv1.MultiClusterHub, annotationKey string) bool
- func IsCommunityMode() bool
- func IsPaused(instance *operatorsv1.MultiClusterHub) bool
- func IsUnitTest() bool
- func MchIsValid(m *operatorsv1.MultiClusterHub) bool
- func OperatorNamespace() (string, error)
- func OverrideImageRepository(imageOverrides map[string]string, imageRepo string) map[string]string
- func ProxyEnvVarsAreSet() bool
- func RemoveString(s []string, r string) []string
- func SetDefaultComponents(m *operatorsv1.MultiClusterHub) (bool, error)
- func ShouldIgnoreOCPVersion(instance *operatorsv1.MultiClusterHub) bool
- func TrackedNamespaces(m *operatorsv1.MultiClusterHub) []string
- func UpdateMCEOverrides(mce *mcev1.MultiClusterEngine, mch *operatorsv1.MultiClusterHub)
- type Condition
- type OperatorCondition
Constants ¶
const ( // ShortRefreshInterval is ideal for frequently changing or moderately critical state requiring timely updates. ShortRefreshInterval = 5 * time.Minute // ErrorRefreshInterval is used for handling critical errors that require immediate attention. ErrorRefreshInterval = 30 * time.Second /* WarningRefreshInterval is suitable for addressing warnings or non-critical issues that should still be addressed relatively promptly. */ WarningRefreshInterval = 1 * time.Minute /* DefaultRefreshInterval serves as a fallback for any other conditions not explicitly covered by the above intervals. */ DefaultRefreshInterval = 20 * time.Minute )
const ( UpgradeableInitReason = "Initializing" UpgradeableInitMessage = "The mch operator is starting up" UpgradeableUpgradingReason = "AlreadyPerformingUpgrade" UpgradeableUpgradingMessage = "upgrading the mch operator to version " UpgradeableAllowReason = "Upgradeable" UpgradeableAllowMessage = "" )
const ( // WebhookServiceName is the name of the webhook service. WebhookServiceName = "multiclusterhub-operator-webhook" // CertManagerNamespace is the namespace where CertManager is deployed. CertManagerNamespace = "cert-manager" // DefaultRepository is the default repository for images. DefaultRepository = "quay.io/stolostron" // UnitTestEnvVar is the environment variable for unit testing. UnitTestEnvVar = "UNIT_TEST" // MCHOperatorName is the name of the Multicluster Hub operator deployment. MCHOperatorName = "multiclusterhub-operator" // SubscriptionOperatorName is the name of the operator deployment managing application subscriptions. SubscriptionOperatorName = "multicluster-operators-standalone-subscription" // MCESubscriptionName is the name of the Multicluster Engine subscription. MCESubscriptionName = "multicluster-engine" // MCESubscriptionNamespace is the namespace for the Multicluster Engine subscription. MCESubscriptionNamespace = "multicluster-engine" // ClusterSubscriptionNamespace is the namespace for the open-cluster-management-backup subscription. ClusterSubscriptionNamespace = "open-cluster-management-backup" // MCEManagedByLabel is the label used to mark resources managed by Multicluster Hub. MCEManagedByLabel = "multiclusterhubs.operator.open-cluster-management.io/managed-by" // OpenShiftClusterMonitoringLabel is the label for OpenShift cluster monitoring. OpenShiftClusterMonitoringLabel = "openshift.io/cluster-monitoring" // AppsubChartLocation is the location of the App Subscription chart. AppsubChartLocation = "/charts/toggle/multicloud-operators-subscription" // CLCChartLocation is the location of the Cluster Lifecycle chart. CLCChartLocation = "/charts/toggle/cluster-lifecycle" // ClusterBackupChartLocation is the location of the Cluster Backup chart. ClusterBackupChartLocation = "/charts/toggle/cluster-backup" // ClusterPermissionChartLocation is the location of the Cluster Permission chart. ClusterPermissionChartLocation = "/charts/toggle/cluster-permission" // ConsoleChartLocation is the location of the Console chart. ConsoleChartLocation = "/charts/toggle/console" // GRCChartLocation is the location of the GRC chart. GRCChartLocation = "/charts/toggle/grc" // InsightsChartLocation is the location of the Insights chart. InsightsChartLocation = "/charts/toggle/insights" // MCOChartLocation is the location of the Multicluster Observability Operator chart. MCOChartLocation = "/charts/toggle/multicluster-observability-operator" // SearchV2ChartLocation is the location of the Search V2 Operator chart. SearchV2ChartLocation = "/charts/toggle/search-v2-operator" // SiteConfigChartLocation is the location of the SiteConfig Operator chart. SiteConfigChartLocation = "/charts/toggle/siteconfig-operator" // SubmarinerAddonChartLocation is the location of the Submariner Addon chart. SubmarinerAddonChartLocation = "/charts/toggle/submariner-addon" // VolsyncChartLocation is the location of the Volsync Controller chart. VolsyncChartLocation = "/charts/toggle/volsync-controller" )
const ( /* MCHOperatorMetricsServiceName is the name of the service used to expose the metrics endpoint for the multiclusterhub-operator. */ MCHOperatorMetricsServiceName = "multiclusterhub-operator-metrics" /* MCHOperatorMetricsServiceMonitorName is the name of the service monitor used to expose the metrics for the multiclusterhub-operator. */ MCHOperatorMetricsServiceMonitorName = "multiclusterhub-operator-metrics" )
Variables ¶
var ( /* AnnotationConfiguration is an annotation used in a resource's metadata to identify the configuration last used to create it. */ AnnotationConfiguration = "installer.open-cluster-management.io/last-applied-configuration" /* AnnotationIgnoreOCPVersion is an annotation used to indicate the operator should not check the OpenShift Container Platform (OCP) version before proceeding when set. */ AnnotationIgnoreOCPVersion = "installer.open-cluster-management.io/ignore-ocp-version" DeprecatedAnnotationIgnoreOCPVersion = "ignoreOCPVersion" /* AnnotationImageOverridesCM is an annotation used in multiclusterhub to specify a custom ConfigMap containing image overrides. */ AnnotationImageOverridesCM = "installer.open-cluster-management.io/image-overrides-configmap" DeprecatedAnnotationImageOverridesCM = "mch-imageOverridesCM" /* AnnotationImageRepo is an annotation used in multiclusterhub to specify a custom image repository to use. */ AnnotationImageRepo = "installer.open-cluster-management.io/image-repository" DeprecatedAnnotationImageRepo = "mch-imageRepository" /* AnnotationKubeconfig is an annotation used to specify the secret name residing in target containing the kubeconfig to access the remote cluster. */ AnnotationKubeconfig = "installer.open-cluster-management.io/kubeconfig" DeprecatedAnnotationKubeconfig = "mch-kubeconfig" /* AnnotationMCHPause is an annotation used in multiclusterhub to identify if the multiclusterhub is paused or not. */ AnnotationMCHPause = "installer.open-cluster-management.io/pause" DeprecatedAnnotationMCHPause = "mch-pause" /* AnnotationMCESubscriptionSpec is an annotation used in multiclusterhub to identify the subscription spec last used to create the multiclustengine. */ AnnotationMCESubscriptionSpec = "installer.open-cluster-management.io/mce-subscription-spec" /* AnnotationOADPSubscriptionSpec is an annotation used to override the OADP subscription used in cluster-backup. */ AnnotationOADPSubscriptionSpec = "installer.open-cluster-management.io/oadp-subscription-spec" /* AnnotationReleaseVersion is an annotation used to indicate the release version that should be applied to all resources managed by the MCH operator. */ AnnotationReleaseVersion = "installer.open-cluster-management.io/release-version" /* AnnotationTemplateOverridesCM is an annotation used in multiclusterhub to specify a custom ConfigMap containing resource template overrides. */ AnnotationTemplateOverridesCM = "installer.open-cluster-management.io/template-override-configmap" /* AnnotationHubSize is an annotation used in multiclusterhub to specify a hub size that can be used by other components */ AnnotationHubSize = "installer.open-cluster-management.io/hub-size" )
var DefaultSSLCiphers = []string{
"ECDHE-ECDSA-AES256-GCM-SHA384",
"ECDHE-RSA-AES256-GCM-SHA384",
"ECDHE-ECDSA-AES128-GCM-SHA256",
"ECDHE-RSA-AES128-GCM-SHA256",
}
DefaultSSLCiphers defines the default cipher configuration used by management ingress
var GetFactory = func(cl client.Client) conditions.Factory { if operatorConditionFactory == nil { operatorConditionFactory = conditions.InClusterFactory{Client: cl} } return operatorConditionFactory }
Functions ¶
func AddDeploymentLabels ¶
func AddDeploymentLabels(d *appsv1.Deployment, labels map[string]string) bool
AddDeploymentLabels ...
func AddInstallerLabel ¶
func AddInstallerLabel(u *unstructured.Unstructured, name string, ns string)
AddInstallerLabel adds Installer Labels ...
func AddInstallerLabels ¶
AddInstallerLabel adds Installer Labels ...
func AddPodLabels ¶
func AddPodLabels(d *appsv1.Deployment, labels map[string]string) bool
AddPodLabels ...
func AnnotationsMatch ¶
AnnotationsMatch checks if all specified annotations in the 'old' map match the corresponding ones in the 'new' map. It returns true if all annotations match, otherwise false.
func AppendProxyVariables ¶
func CertManagerNS ¶
func CertManagerNS(m *operatorsv1.MultiClusterHub) string
CertManagerNS returns the namespace to deploy cert manager objects
func ContainsMap ¶
ContainsMap returns whether the expected map entries are included in the map
func ContainsPullSecret ¶
func ContainsPullSecret(pullSecrets []corev1.LocalObjectReference, ps corev1.LocalObjectReference) bool
ContainsPullSecret returns whether a list of pullSecrets contains a given pull secret
func CoreToUnstructured ¶
func CoreToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error)
CoreToUnstructured converts a Core Kube resource to unstructured
func DeduplicateComponents ¶
func DeduplicateComponents(m *operatorsv1.MultiClusterHub) bool
DeduplicateComponents removes duplicate componentconfigs by name, keeping the config of the last componentconfig in the list. Returns true if changes are made.
func DefaultReplicaCount ¶
func DefaultReplicaCount(mch *operatorsv1.MultiClusterHub) int
DefaultReplicaCount returns an integer corresponding to the default number of replicas for HA or non-HA modes
func DistributePods ¶
DistributePods returns a anti-affinity rule that specifies a preference for pod replicas with the matching key-value label to run across different nodes and zones
func FormatSSLCiphers ¶
FormatSSLCiphers converts an array of ciphers into a string consumed by the management ingress chart
func GetContainerArgs ¶
func GetContainerArgs(dep *appsv1.Deployment) []string
GetContainerArgs return arguments forfirst container in deployment
func GetContainerEnvVars ¶
func GetContainerEnvVars(dep *appsv1.Deployment) []corev1.EnvVar
GetContainerEnvVars returns environment variables for first container in deployment
func GetContainerRequestResources ¶
func GetContainerRequestResources(dep *appsv1.Deployment) corev1.ResourceList
GetContainerRequestResources returns Request Requirements for first container in deployment
func GetContainerVolumeMounts ¶
func GetContainerVolumeMounts(dep *appsv1.Deployment) []corev1.VolumeMount
GetContainerVolumeMounts returns volume mount for first container in deployment
func GetContainerVolumes ¶
func GetContainerVolumes(dep *appsv1.Deployment) []corev1.Volume
GetDeploymentVolumes returns volumes in deployment
func GetCustomResources ¶
func GetCustomResources(m *operatorsv1.MultiClusterHub) []types.NamespacedName
func GetCustomResourcesForStatus ¶
func GetCustomResourcesForStatus(m *operatorsv1.MultiClusterHub) []types.NamespacedName
func GetDeployments ¶
func GetDeployments(m *operatorsv1.MultiClusterHub) []types.NamespacedName
func GetDeploymentsForStatus ¶
func GetDeploymentsForStatus(m *operatorsv1.MultiClusterHub, ocpConsole, isSTSEnabled bool) []types.NamespacedName
func GetDisableClusterImageSets ¶
func GetDisableClusterImageSets(m *operatorsv1.MultiClusterHub) string
GetDisableClusterImageSets returns true or false for whether auto update for clusterImageSets should be disabled
func GetHubSize ¶
func GetHubSize(instance *operatorsv1.MultiClusterHub) operatorsv1.HubSize
GetHubSize gets the current hubsize, returning "Small" as default if the annotation is not found.
func GetImageOverridesConfigmapName ¶
func GetImageOverridesConfigmapName(instance *operatorsv1.MultiClusterHub) string
GetImageOverridesConfigmapName returns the image overrides ConfigMap annotation value, using the primary annotation key and falling back to the deprecated key if not set.
func GetImagePullPolicy ¶
func GetImagePullPolicy(m *operatorsv1.MultiClusterHub) corev1.PullPolicy
GetImagePullPolicy returns either pull policy from CR overrides or default of Always
func GetImageRepository ¶
func GetImageRepository(instance *operatorsv1.MultiClusterHub) string
GetImageRepository returns the image repository annotation value, using the primary annotation key and falling back to the deprecated key if not set.
func GetMCEAnnotationOverrides ¶
func GetMCEAnnotationOverrides(instance *operatorsv1.MultiClusterHub) string
GetMCEAnnotationOverrides returns the MulticlusterEngine subscription spec annotation value, or an empty string if not set.
func GetMCEComponents ¶
func GetMCEComponents(mch *operatorsv1.MultiClusterHub) []mcev1.ComponentConfig
getMCEComponents returns mce components that are present in mch
func GetOADPAnnotationOverrides ¶
func GetOADPAnnotationOverrides(instance *operatorsv1.MultiClusterHub) string
GetOADPAnnotationOverrides returns the OADP subscription spec annotation value, or an empty string if not set.
func GetTemplateOverridesConfigmapName ¶
func GetTemplateOverridesConfigmapName(instance *operatorsv1.MultiClusterHub) string
GetTemplateOverridesConfigmapName returns the template overrides ConfigMap annotation value, or an empty string if not set.
func GetTestImages ¶
func GetTestImages() []string
func GetTolerations ¶
func GetTolerations(m *operatorsv1.MultiClusterHub) []corev1.Toleration
func HasAnnotation ¶
func HasAnnotation(instance *operatorsv1.MultiClusterHub, annotationKey string) bool
HasAnnotation checks if a specific annotation key exists in the instance's annotations.
func IsAnnotationTrue ¶
func IsAnnotationTrue(instance *operatorsv1.MultiClusterHub, annotationKey string) bool
IsAnnotationTrue checks if a specific annotation key in the given instance is set to "true".
func IsCommunityMode ¶
func IsCommunityMode() bool
IsCommunityMode returns true if operator is running in community mode
func IsPaused ¶
func IsPaused(instance *operatorsv1.MultiClusterHub) bool
IsPaused checks if the MultiClusterHub instance is labeled as paused. It returns true if the instance is paused, otherwise false.
func IsUnitTest ¶
func IsUnitTest() bool
func MchIsValid ¶
func MchIsValid(m *operatorsv1.MultiClusterHub) bool
MchIsValid Checks if the optional default parameters need to be set
func OperatorNamespace ¶
OperatorNamespace returns the namespace where the MultiClusterHub operator is registered or deployed.
func OverrideImageRepository ¶
OverrideImageRepository modifies image references in a map to use a specified image repository.
func ProxyEnvVarsAreSet ¶
func ProxyEnvVarsAreSet() bool
ProxyEnvVarIsSet ... OLM handles these environment variables as a unit; if at least one of them is set, all three are considered overridden and the cluster-wide defaults are not used for the deployments of the subscribed Operator. https://docs.openshift.com/container-platform/4.6/operators/admin/olm-configuring-proxy-support.html GetProxyEnvVars
func RemoveString ¶
func SetDefaultComponents ¶
func SetDefaultComponents(m *operatorsv1.MultiClusterHub) (bool, error)
SetDefaultComponents returns true if changes are made
func ShouldIgnoreOCPVersion ¶
func ShouldIgnoreOCPVersion(instance *operatorsv1.MultiClusterHub) bool
ShouldIgnoreOCPVersion checks if the instance is annotated to skip the minimum OCP version requirement.
func TrackedNamespaces ¶
func TrackedNamespaces(m *operatorsv1.MultiClusterHub) []string
TrackedNamespaces returns the list of namespaces we deploy components to and should track
func UpdateMCEOverrides ¶
func UpdateMCEOverrides(mce *mcev1.MultiClusterEngine, mch *operatorsv1.MultiClusterHub)
UpdateMCEOverrides adds MCE componenets that are present in mch
Types ¶
type Condition ¶
type Condition interface {
Set(ctx context.Context, status metav1.ConditionStatus, reason, message string) error
}
Condition - We just need the Set method in our code.
type OperatorCondition ¶
type OperatorCondition struct {
// contains filtered or unexported fields
}
OperatorCondition wraps operator-lib's Condition to make it not crash, when running locally or in Kubernetes without OLM.
func NewOperatorCondition ¶
func NewOperatorCondition(cl client.Client, condType string) (*OperatorCondition, error)
func (*OperatorCondition) Set ¶
func (oc *OperatorCondition) Set(ctx context.Context, status metav1.ConditionStatus, reason, message string) error