util

package
v0.59.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 23 Imported by: 6

Documentation

Overview

* This file is part of the KubeVirt project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2019 Red Hat, Inc. *

Index

Constants

View Source
const (
	KubeVirtFinalizer string = "foregroundDeleteKubeVirt"

	ConditionReasonDeploymentFailedExisting = "ExistingDeployment"
	ConditionReasonDeploymentFailedError    = "DeploymentFailed"
	ConditionReasonDeletionFailedError      = "DeletionFailed"
	ConditionReasonDeploymentCreated        = "AllResourcesCreated"
	ConditionReasonDeploymentReady          = "AllComponentsReady"
	ConditionReasonDeploying                = "DeploymentInProgress"
	ConditionReasonUpdating                 = "UpdateInProgress"
	ConditionReasonDeleting                 = "DeletionInProgress"
)
View Source
const (
	// Name of env var containing the operator's image name
	OperatorImageEnvName          = "OPERATOR_IMAGE"
	VirtApiShasumEnvName          = "VIRT_API_SHASUM"
	VirtControllerShasumEnvName   = "VIRT_CONTROLLER_SHASUM"
	VirtHandlerShasumEnvName      = "VIRT_HANDLER_SHASUM"
	VirtLauncherShasumEnvName     = "VIRT_LAUNCHER_SHASUM"
	VirtExportProxyShasumEnvName  = "VIRT_EXPORTPROXY_SHASUM"
	VirtExportServerShasumEnvName = "VIRT_EXPORTSERVER_SHASUM"
	GsEnvShasumName               = "GS_SHASUM"
	KubeVirtVersionEnvName        = "KUBEVIRT_VERSION"
	// Deprecated, use TargetDeploymentConfig instead
	TargetInstallNamespace = "TARGET_INSTALL_NAMESPACE"
	// Deprecated, use TargetDeploymentConfig instead
	TargetImagePullPolicy = "TARGET_IMAGE_PULL_POLICY"
	// JSON containing all relevant deployment properties, replaces TargetInstallNamespace and TargetImagePullPolicy
	TargetDeploymentConfig = "TARGET_DEPLOYMENT_CONFIG"

	// these names need to match field names from KubeVirt Spec if they are set from there
	AdditionalPropertiesNamePullPolicy = "ImagePullPolicy"

	// lookup key in AdditionalProperties
	AdditionalPropertiesMonitorNamespace = "MonitorNamespace"

	// lookup key in AdditionalProperties
	AdditionalPropertiesServiceMonitorNamespace = "ServiceMonitorNamespace"

	// lookup key in AdditionalProperties
	AdditionalPropertiesMonitorServiceAccount = "MonitorAccount"

	// lookup key in AdditionalProperties
	AdditionalPropertiesWorkloadUpdatesEnabled = "WorkloadUpdatesEnabled"

	// lookup key in AdditionalProperties
	AdditionalPropertiesMigrationNetwork = "MigrationNetwork"

	// account to use if one is not explicitly named
	DefaultMonitorAccount = "prometheus-k8s"

	// lookup keys in AdditionalProperties
	ImagePrefixKey      = "imagePrefix"
	ProductNameKey      = "productName"
	ProductComponentKey = "productComponent"
	ProductVersionKey   = "productVersion"

	// #nosec 101, the variable is not holding any credential
	// Prefix for env vars that will be passed along
	PassthroughEnvPrefix = "KV_IO_EXTRA_ENV_"
)

Variables

View Source
var DefaultMonitorNamespaces = []string{
	"openshift-monitoring",
	"monitoring",
}

DefaultMonitorNamespaces holds a set of well known prometheus-operator namespaces. Ordering in the list matters. First entries have precedence.

Functions

func AddFinalizer

func AddFinalizer(kv *virtv1.KubeVirt)

func DaemonSetIsUpToDate added in v0.49.0

func DaemonSetIsUpToDate(kv *v1.KubeVirt, daemonSet *appsv1.DaemonSet) bool

func DaemonsetIsReady added in v0.16.0

func DaemonsetIsReady(kv *v1.KubeVirt, daemonset *appsv1.DaemonSet, stores Stores) bool

func DeploymentIsReady added in v0.16.0

func DeploymentIsReady(kv *v1.KubeVirt, deployment *appsv1.Deployment, stores Stores) bool

func GetPassthroughEnv added in v0.30.0

func GetPassthroughEnv() map[string]string

func IsManagedByOperator added in v0.20.0

func IsManagedByOperator(labels map[string]string) bool

func IsPrometheusRuleEnabled added in v0.26.0

func IsPrometheusRuleEnabled(clientset kubecli.KubevirtClient) (bool, error)

IsPrometheusRuleEnabled returns true if prometheusrules cr is defined and false otherwise.

func IsSCCStoreEmpty added in v0.20.0

func IsSCCStoreEmpty(store cache.Store) bool

func IsServiceMonitorEnabled added in v0.20.6

func IsServiceMonitorEnabled(clientset kubecli.KubevirtClient) (bool, error)

func IsStoreEmpty

func IsStoreEmpty(store cache.Store) bool

func IsValidLabel added in v0.39.0

func IsValidLabel(label string) bool

func NewEnvVarMap added in v0.30.0

func NewEnvVarMap(envMap map[string]string) *[]k8sv1.EnvVar

func PodIsCrashLooping added in v0.49.0

func PodIsCrashLooping(pod *k8sv1.Pod) bool

func PodIsReady added in v0.49.0

func PodIsReady(pod *k8sv1.Pod) bool

func PodIsUpToDate added in v0.49.0

func PodIsUpToDate(pod *k8sv1.Pod, kv *v1.KubeVirt) bool

func SetConditionTimestamps added in v0.20.0

func SetConditionTimestamps(kvOrig *virtv1.KubeVirt, kvUpdated *virtv1.KubeVirt)

func SetOperatorVersion added in v0.16.0

func SetOperatorVersion(kv *virtv1.KubeVirt)

func UpdateConditionsAvailable added in v0.20.0

func UpdateConditionsAvailable(kv *virtv1.KubeVirt)

func UpdateConditionsCreated added in v0.20.0

func UpdateConditionsCreated(kv *virtv1.KubeVirt)

func UpdateConditionsDeleting added in v0.20.0

func UpdateConditionsDeleting(kv *virtv1.KubeVirt)

func UpdateConditionsDeletionFailed added in v0.20.0

func UpdateConditionsDeletionFailed(kv *virtv1.KubeVirt, err error)

func UpdateConditionsDeploying added in v0.20.0

func UpdateConditionsDeploying(kv *virtv1.KubeVirt)

func UpdateConditionsFailedError added in v0.20.0

func UpdateConditionsFailedError(kv *virtv1.KubeVirt, err error)

func UpdateConditionsFailedExists added in v0.20.0

func UpdateConditionsFailedExists(kv *virtv1.KubeVirt)

func UpdateConditionsUpdating added in v0.20.0

func UpdateConditionsUpdating(kv *virtv1.KubeVirt)

func VerifyEnv added in v0.20.0

func VerifyEnv() error

Types

type Expectations

func (*Expectations) DeleteExpectations

func (e *Expectations) DeleteExpectations(key string)

func (*Expectations) ResetExpectations

func (e *Expectations) ResetExpectations(key string)

func (*Expectations) SatisfiedExpectations

func (e *Expectations) SatisfiedExpectations(key string) bool

type KubeVirtDeploymentConfig

type KubeVirtDeploymentConfig struct {
	ID          string `json:"id,omitempty" optional:"true"`
	Namespace   string `json:"namespace,omitempty" optional:"true"`
	Registry    string `json:"registry,omitempty" optional:"true"`
	ImagePrefix string `json:"imagePrefix,omitempty" optional:"true"`

	// the KubeVirt version
	// matches the image tag, if tags are used, either by the manifest, or by the KubeVirt CR
	// used on the KubeVirt CR status and on annotations, and for determining up-/downgrade path, even when using shasums for the images
	KubeVirtVersion string `json:"kubeVirtVersion,omitempty" optional:"true"`

	// the shasums of every image we use
	VirtOperatorSha     string `json:"virtOperatorSha,omitempty" optional:"true"`
	VirtApiSha          string `json:"virtApiSha,omitempty" optional:"true"`
	VirtControllerSha   string `json:"virtControllerSha,omitempty" optional:"true"`
	VirtHandlerSha      string `json:"virtHandlerSha,omitempty" optional:"true"`
	VirtLauncherSha     string `json:"virtLauncherSha,omitempty" optional:"true"`
	VirtExportProxySha  string `json:"virtExportProxySha,omitempty" optional:"true"`
	VirtExportServerSha string `json:"virtExportServerSha,omitempty" optional:"true"`
	GsSha               string `json:"gsSha,omitempty" optional:"true"`

	// everything else, which can e.g. come from KubeVirt CR spec
	AdditionalProperties map[string]string `json:"additionalProperties,omitempty" optional:"true"`

	// environment variables from virt-operator to pass along
	PassthroughEnvVars map[string]string `json:"passthroughEnvVars,omitempty" optional:"true"`
}

func GetConfigFromEnv added in v0.20.0

func GetConfigFromEnv() (*KubeVirtDeploymentConfig, error)

func GetTargetConfigFromKV added in v0.20.0

func GetTargetConfigFromKV(kv *v1.KubeVirt) *KubeVirtDeploymentConfig

func (*KubeVirtDeploymentConfig) GetApiVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetApiVersion() string

func (*KubeVirtDeploymentConfig) GetControllerVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetControllerVersion() string

func (*KubeVirtDeploymentConfig) GetDeploymentID added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetDeploymentID() string

func (*KubeVirtDeploymentConfig) GetExportProxyVersion added in v0.55.0

func (c *KubeVirtDeploymentConfig) GetExportProxyVersion() string

func (*KubeVirtDeploymentConfig) GetExportServerVersion added in v0.55.0

func (c *KubeVirtDeploymentConfig) GetExportServerVersion() string

func (*KubeVirtDeploymentConfig) GetExtraEnv added in v0.30.0

func (c *KubeVirtDeploymentConfig) GetExtraEnv() map[string]string

func (*KubeVirtDeploymentConfig) GetHandlerVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetHandlerVersion() string

func (*KubeVirtDeploymentConfig) GetImagePrefix added in v0.20.8

func (c *KubeVirtDeploymentConfig) GetImagePrefix() string

func (*KubeVirtDeploymentConfig) GetImagePullPolicy added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetImagePullPolicy() k8sv1.PullPolicy

func (*KubeVirtDeploymentConfig) GetImageRegistry added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetImageRegistry() string

func (*KubeVirtDeploymentConfig) GetJson added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetJson() (string, error)

func (*KubeVirtDeploymentConfig) GetKubeVirtVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetKubeVirtVersion() string

func (*KubeVirtDeploymentConfig) GetLauncherVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetLauncherVersion() string

func (*KubeVirtDeploymentConfig) GetMigrationNetwork added in v0.49.0

func (c *KubeVirtDeploymentConfig) GetMigrationNetwork() *string

func (*KubeVirtDeploymentConfig) GetMonitorServiceAccountName added in v0.53.0

func (c *KubeVirtDeploymentConfig) GetMonitorServiceAccountName() string

func (*KubeVirtDeploymentConfig) GetNamespace added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetNamespace() string

func (*KubeVirtDeploymentConfig) GetOperatorVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetOperatorVersion() string

func (*KubeVirtDeploymentConfig) GetPotentialMonitorNamespaces added in v0.53.0

func (c *KubeVirtDeploymentConfig) GetPotentialMonitorNamespaces() []string

if the monitoring namespace field is defiend in kubevirtCR than return it otherwise we return common monitoring namespaces.

func (*KubeVirtDeploymentConfig) GetProductComponent added in v0.48.0

func (c *KubeVirtDeploymentConfig) GetProductComponent() string

func (*KubeVirtDeploymentConfig) GetProductName added in v0.33.0

func (c *KubeVirtDeploymentConfig) GetProductName() string

func (*KubeVirtDeploymentConfig) GetProductVersion added in v0.33.0

func (c *KubeVirtDeploymentConfig) GetProductVersion() string

func (*KubeVirtDeploymentConfig) GetServiceMonitorNamespace added in v0.53.0

func (c *KubeVirtDeploymentConfig) GetServiceMonitorNamespace() string

func (*KubeVirtDeploymentConfig) GetVerbosity added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetVerbosity() string

func (*KubeVirtDeploymentConfig) SetObservedDeploymentConfig added in v0.20.0

func (c *KubeVirtDeploymentConfig) SetObservedDeploymentConfig(kv *v1.KubeVirt) error

func (*KubeVirtDeploymentConfig) SetTargetDeploymentConfig added in v0.20.0

func (c *KubeVirtDeploymentConfig) SetTargetDeploymentConfig(kv *v1.KubeVirt) error

func (*KubeVirtDeploymentConfig) UseShasums added in v0.20.0

func (c *KubeVirtDeploymentConfig) UseShasums() bool

func (*KubeVirtDeploymentConfig) WorkloadUpdatesEnabled added in v0.39.0

func (c *KubeVirtDeploymentConfig) WorkloadUpdatesEnabled() bool

type Stores

type Stores struct {
	ServiceAccountCache           cache.Store
	ClusterRoleCache              cache.Store
	ClusterRoleBindingCache       cache.Store
	RoleCache                     cache.Store
	RoleBindingCache              cache.Store
	CrdCache                      cache.Store
	ServiceCache                  cache.Store
	DeploymentCache               cache.Store
	DaemonSetCache                cache.Store
	ValidationWebhookCache        cache.Store
	MutatingWebhookCache          cache.Store
	APIServiceCache               cache.Store
	SCCCache                      cache.Store
	RouteCache                    cache.Store
	InstallStrategyConfigMapCache cache.Store
	InstallStrategyJobCache       cache.Store
	InfrastructurePodCache        cache.Store
	PodDisruptionBudgetCache      cache.Store
	ServiceMonitorCache           cache.Store
	NamespaceCache                cache.Store
	PrometheusRuleCache           cache.Store
	SecretCache                   cache.Store
	ConfigMapCache                cache.Store
	IsOnOpenshift                 bool
	ServiceMonitorEnabled         bool
	PrometheusRulesEnabled        bool
}

func (*Stores) AllEmpty

func (s *Stores) AllEmpty() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL