Documentation ¶
Overview ¶
Package cluster contains utility functions used to operate on cluster resources.
This includes getting cluster domain, operator namespace and CSV, defining different GVK being used in the project, config metadata on reousrces, managing reousrces like rolebinding, secret and configmap.
Index ¶
- func ApplyMetaOptions(obj metav1.Object, opts ...MetaOptions) error
- func CreateNamespace(ctx context.Context, cli client.Client, namespace string, ...) (*corev1.Namespace, error)
- func CreateOrUpdateConfigMap(ctx context.Context, c client.Client, desiredCfgMap *corev1.ConfigMap, ...) error
- func CreateSecret(ctx context.Context, cli client.Client, name, namespace string, ...) error
- func CreateWithRetry(ctx context.Context, cli client.Client, obj client.Object, timeoutMin int) error
- func DeleteExistingSubscription(cli client.Client, operatorNs string, subsName string) error
- func GetClusterServiceVersion(ctx context.Context, c client.Client, watchNameSpace string) (*ofapi.ClusterServiceVersion, error)
- func GetDomain(c client.Client) (string, error)
- func GetOperatorNamespace() (string, error)
- func GetSubscription(cli client.Client, namespace string, name string) (*v1alpha1.Subscription, error)
- func OperatorExists(cli client.Client, operatorPrefix string) (bool, error)
- func SubscriptionExists(cli client.Client, name string) (bool, error)
- func UpdatePodSecurityRolebinding(ctx context.Context, cli client.Client, namespace string, ...) error
- func WaitForDeploymentAvailable(ctx context.Context, c client.Client, componentName string, namespace string, ...) error
- type MetaOptions
- type Platform
- type Release
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyMetaOptions ¶ added in v2.10.0
func ApplyMetaOptions(obj metav1.Object, opts ...MetaOptions) error
func CreateNamespace ¶
func CreateNamespace(ctx context.Context, cli client.Client, namespace string, metaOptions ...MetaOptions) (*corev1.Namespace, error)
CreateNamespace creates a namespace and apply metadata. If a namespace already exists, the operation has no effect on it.
func CreateOrUpdateConfigMap ¶ added in v2.10.1
func CreateOrUpdateConfigMap(ctx context.Context, c client.Client, desiredCfgMap *corev1.ConfigMap, metaOptions ...MetaOptions) error
CreateOrUpdateConfigMap creates a new configmap or updates an existing one. If the configmap already exists, it will be updated with the merged Data and MetaOptions, if any. ConfigMap.ObjectMeta.Name and ConfigMap.ObjectMeta.Namespace are both required, it returns an error otherwise.
func CreateSecret ¶
func CreateSecret(ctx context.Context, cli client.Client, name, namespace string, metaOptions ...MetaOptions) error
CreateSecret creates secrets required by dashboard component in downstream.
func CreateWithRetry ¶ added in v2.12.0
func DeleteExistingSubscription ¶ added in v2.13.0
DeleteExistingSubscription deletes given Subscription if it exists Do not error if the Subscription does not exist.
func GetClusterServiceVersion ¶ added in v2.10.0
func GetClusterServiceVersion(ctx context.Context, c client.Client, watchNameSpace string) (*ofapi.ClusterServiceVersion, error)
GetClusterServiceVersion retries the clusterserviceversions available in the operator namespace.
func GetOperatorNamespace ¶ added in v2.10.0
func GetSubscription ¶ added in v2.13.0
func GetSubscription(cli client.Client, namespace string, name string) (*v1alpha1.Subscription, error)
GetSubscription checks if a Subscription for the operator exists in the given namespace. if exists, return object; otherwise, return error.
func OperatorExists ¶ added in v2.13.0
OperatorExists checks if an Operator with 'operatorPrefix' is installed. Return true if found it, false if not. if we need to check exact version of the operator installed, can append vX.Y.Z later.
func SubscriptionExists ¶ added in v2.13.0
func UpdatePodSecurityRolebinding ¶
func UpdatePodSecurityRolebinding(ctx context.Context, cli client.Client, namespace string, serviceAccountsList ...string) error
UpdatePodSecurityRolebinding update default rolebinding which is created in applications namespace by manifests being used by different components and SRE monitoring.
func WaitForDeploymentAvailable ¶ added in v2.12.0
func WaitForDeploymentAvailable(ctx context.Context, c client.Client, componentName string, namespace string, interval int, timeout int) error
WaitForDeploymentAvailable to check if component deployment from 'namespace' is ready within 'timeout' before apply prometheus rules for the component.
Types ¶
type MetaOptions ¶ added in v2.7.0
MetaOptions allows to add additional settings for the object being created through a chain of functions which are applied on metav1.Object before actual resource creation.
func OwnedBy ¶ added in v2.11.0
func OwnedBy(owner metav1.Object, scheme *runtime.Scheme) MetaOptions
func WithLabels ¶ added in v2.7.0
func WithLabels(labels ...string) MetaOptions
func WithOwnerReference ¶ added in v2.10.0
func WithOwnerReference(ownerReferences ...metav1.OwnerReference) MetaOptions
type Platform ¶ added in v2.12.0
type Platform string
const ( // ManagedRhods defines expected addon catalogsource. ManagedRhods Platform = "addon-managed-odh-catalog" // SelfManagedRhods defines display name in csv. SelfManagedRhods Platform = "Red Hat OpenShift AI" // OpenDataHub defines display name in csv. OpenDataHub Platform = "Open Data Hub Operator" // Unknown indicates that operator is not deployed using OLM. Unknown Platform = "" )
type Release ¶ added in v2.13.0
type Release struct { Name Platform `json:"name,omitempty"` Version version.OperatorVersion `json:"version,omitempty"` }
Release includes information on operator version and platform +kubebuilder:object:generate=true
func (*Release) DeepCopy ¶ added in v2.13.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Release.
func (*Release) DeepCopyInto ¶ added in v2.13.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.