Documentation ¶
Index ¶
- Constants
- Variables
- func ComponentResourceRemoval(ctx context.Context, c client.Client, obj interface{}, hcoName string, ...) error
- func ContainsString(s []string, word string) bool
- func DeepCopyLabels(src, tgt *metav1.ObjectMeta)
- func EnsureCreated(ctx context.Context, c client.Client, obj client.Object, logger logr.Logger) error
- func EnsureDeleted(ctx context.Context, c client.Client, obj client.Object, hcoName string, ...) error
- func GetCSVfromPod(pod *corev1.Pod, c client.Reader, logger logr.Logger) (*csvv1alpha1.ClusterServiceVersion, error)
- func GetHcoKvIoVersion() string
- func GetHcoPing() healthz.Checker
- func GetOperatorNamespace(logger logr.Logger) (string, error)
- func GetOperatorNamespaceFromEnv() (string, error)
- func GetPod(ctx context.Context, c client.Reader, logger logr.Logger, ci ClusterInfo) (*corev1.Pod, error)
- func GetRuntimeObject(ctx context.Context, c client.Client, obj client.Object, logger logr.Logger) error
- func GetWatchNamespace() (string, error)
- func IsReady() bool
- func IsRunModeLocal() bool
- func SetReady(ready bool)
- func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error)
- type AppComponent
- type ClusterInfo
- type ClusterInfoImp
- type EventEmitter
- type RunModeType
Constants ¶
const ( OperatorNamespaceEnv = "OPERATOR_NAMESPACE" OperatorWebhookModeEnv = "WEBHOOK_MODE" ContainerAppName = "APP" ContainerOperatorApp = "OPERATOR" ContainerWebhookApp = "WEBHOOK" HcoKvIoVersionName = "HCO_KV_IO_VERSION" KubevirtVersionEnvV = "KUBEVIRT_VERSION" CdiVersionEnvV = "CDI_VERSION" CnaoVersionEnvV = "NETWORK_ADDONS_VERSION" SspVersionEnvV = "SSP_VERSION" NmoVersionEnvV = "NMO_VERSION" HppoVersionEnvV = "HPPO_VERSION" VMImportEnvV = "VM_IMPORT_VERSION" HcoValidatingWebhook = "validate-hco.kubevirt.io" HcoMutatingWebhookNS = "mutate-ns-hco.kubevirt.io" AppLabel = "app" UndefinedNamespace = "" OpenshiftNamespace = "openshift" OperatorTestNamespace = "test-operators" OperatorHubNamespace = "operators" APIVersionAlpha = "v1alpha1" APIVersionBeta = "v1beta1" CurrentAPIVersion = APIVersionBeta APIVersionGroup = "hco.kubevirt.io" APIVersion = APIVersionGroup + "/" + APIVersionBeta // Recommended labels by Kubernetes. See // https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ AppLabelPrefix = "app.kubernetes.io" AppLabelVersion = AppLabelPrefix + "/version" AppLabelManagedBy = AppLabelPrefix + "/managed-by" AppLabelPartOf = AppLabelPrefix + "/part-of" AppLabelComponent = AppLabelPrefix + "/component" // Operator name for managed-by label OperatorName = "hco-operator" // Value for "part-of" label HyperConvergedCluster = "hyperconverged-cluster" // HyperConvergedName is the name of the HyperConverged resource that will be reconciled HyperConvergedName = "kubevirt-hyperconverged" MetricsHost = "0.0.0.0" MetricsPort int32 = 8383 OperatorMetricsPort int32 = 8686 HealthProbeHost = "0.0.0.0" HealthProbePort int32 = 6060 ReadinessEndpointName = "/readyz" LivenessEndpointName = "/livez" HCOWebhookPath = "/validate-hco-kubevirt-io-v1beta1-hyperconverged" HCONSWebhookPath = "/mutate-ns-hco-kubevirt-io" DefaulterWebhookPath = "/mutate-hco-kubevirt-io-v1beta1-hyperconverged" WebhookPort = 4343 )
HCO common constants
const ( LocalRunMode RunModeType = "local" ClusterRunMode RunModeType = "cluster" // WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE // which is the namespace where the watch activity happens. // this value is empty if the operator is running with clusterScope. WatchNamespaceEnvVar = "WATCH_NAMESPACE" // PodNameEnvVar is the constant for env variable POD_NAME // which is the name of the current pod. PodNameEnvVar = "POD_NAME" )
Variables ¶
var ErrNoNamespace = fmt.Errorf("namespace not found for current environment")
ErrNoNamespace indicates that a namespace could not be found for the current environment
var ErrRunLocal = fmt.Errorf("operator run mode forced to local")
ErrRunLocal indicates that the operator is set to run in local mode (this error is returned by functions that only work on operators running in cluster mode)
var ForceRunModeEnv = "OSDK_FORCE_RUN_MODE"
ForceRunModeEnv indicates if the operator should be forced to run in either local or cluster mode (currently only used for local mode)
Functions ¶
func ComponentResourceRemoval ¶ added in v1.2.0
func ComponentResourceRemoval(ctx context.Context, c client.Client, obj interface{}, hcoName string, logger logr.Logger, dryRun bool, wait bool) error
ComponentResourceRemoval removes the resource `obj` if it exists and belongs to the HCO with wait=true it will wait, (util ctx timeout, please set it!) for the resource to be effectively deleted
func ContainsString ¶ added in v1.3.0
func DeepCopyLabels ¶ added in v1.4.0
func DeepCopyLabels(src, tgt *metav1.ObjectMeta)
func EnsureCreated ¶ added in v1.2.0
func EnsureCreated(ctx context.Context, c client.Client, obj client.Object, logger logr.Logger) error
EnsureCreated creates the runtime object if it does not exist
func EnsureDeleted ¶ added in v1.2.0
func EnsureDeleted(ctx context.Context, c client.Client, obj client.Object, hcoName string, logger logr.Logger, dryRun bool, wait bool) error
EnsureDeleted calls ComponentResourceRemoval if the runtime object exists with wait=true it will wait, (util ctx timeout, please set it!) for the resource to be effectively deleted
func GetCSVfromPod ¶
func GetCSVfromPod(pod *corev1.Pod, c client.Reader, logger logr.Logger) (*csvv1alpha1.ClusterServiceVersion, error)
func GetHcoKvIoVersion ¶ added in v1.4.0
func GetHcoKvIoVersion() string
func GetHcoPing ¶ added in v1.3.0
func GetOperatorNamespace ¶ added in v1.3.0
GetOperatorNamespace returns the namespace the operator should be running in.
func GetRuntimeObject ¶ added in v1.2.0
func GetRuntimeObject(ctx context.Context, c client.Client, obj client.Object, logger logr.Logger) error
GetRuntimeObject will query the apiserver for the object
func GetWatchNamespace ¶ added in v1.3.0
GetWatchNamespace returns the namespace the operator should be watching for changes
func IsRunModeLocal ¶ added in v1.4.0
func IsRunModeLocal() bool
func ToUnstructured ¶ added in v1.4.0
func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error)
ToUnstructured convers an arbitrary object (which MUST obey the k8s object conventions) to an Unstructured
Types ¶
type AppComponent ¶ added in v1.4.0
type AppComponent string
const ( AppComponentCompute AppComponent = "compute" AppComponentStorage AppComponent = "storage" AppComponentImport AppComponent = "import" AppComponentNetwork AppComponent = "network" AppComponentMonitoring AppComponent = "monitoring" AppComponentSchedule AppComponent = "schedule" AppComponentDeployment AppComponent = "deployment" )
type ClusterInfo ¶ added in v1.1.0
type ClusterInfo interface { CheckRunningInOpenshift(creader client.Reader, ctx context.Context, logger logr.Logger, runningLocally bool) error IsOpenshift() bool IsRunningLocally() bool }
func GetClusterInfo ¶ added in v1.2.0
func GetClusterInfo() ClusterInfo
type ClusterInfoImp ¶ added in v1.1.0
type ClusterInfoImp struct {
// contains filtered or unexported fields
}
func (*ClusterInfoImp) CheckRunningInOpenshift ¶ added in v1.1.0
func (ClusterInfoImp) IsOpenshift ¶ added in v1.1.0
func (c ClusterInfoImp) IsOpenshift() bool
func (ClusterInfoImp) IsRunningLocally ¶ added in v1.2.0
func (c ClusterInfoImp) IsRunningLocally() bool
type EventEmitter ¶ added in v1.2.0
type EventEmitter interface { Init(ctx context.Context, mgr manager.Manager, ci ClusterInfo, logger logr.Logger) EmitEvent(object runtime.Object, eventType, reason, msg string) UpdateClient(ctx context.Context, clnt client.Reader, logger logr.Logger) }
func GetEventEmitter ¶ added in v1.2.0
func GetEventEmitter() EventEmitter
type RunModeType ¶ added in v1.3.0
type RunModeType string