util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Default port that api listens on.
	DefaultPort = 8443
	// Default address api listens on.
	DefaultHost  = "0.0.0.0"
	DefaultAaqNs = "aaq"
)
View Source
const (
	// AAQLabel is the labe applied to all non operator resources
	AAQLabel = "aaq.kubevirt.io"
	// AAQPriorityClass is the priority class for all AAQ pods.
	AAQPriorityClass = "kubevirt-cluster-critical"
	// AppKubernetesManagedByLabel is the Kubernetes recommended managed-by label
	AppKubernetesManagedByLabel = "app.kubernetes.io/managed-by"
	// AppKubernetesComponentLabel is the Kubernetes recommended component label
	AppKubernetesComponentLabel = "app.kubernetes.io/component"
	// PrometheusLabelKey provides the label to indicate prometheus metrics are available in the pods.
	PrometheusLabelKey = "prometheus.aaq.kubevirt.io"
	// PrometheusLabelValue provides the label value which shouldn't be empty to avoid a prometheus WIP issue.
	PrometheusLabelValue = "true"
	// AppKubernetesPartOfLabel is the Kubernetes recommended part-of label
	AppKubernetesPartOfLabel = "app.kubernetes.io/part-of"
	// AppKubernetesVersionLabel is the Kubernetes recommended version label
	AppKubernetesVersionLabel = "app.kubernetes.io/version"
	// ControllerPodName is the label applied to aaq-controller resources
	ControllerPodName = "aaq-controller"
	// AaqServerPodName is the name of the server pods
	AaqServerPodName = "aaq-server"
	// ControllerServiceAccountName is the name of the AAQ controller service account
	ControllerServiceAccountName = ControllerPodName

	// InstallerPartOfLabel provides a constant to capture our env variable "INSTALLER_PART_OF_LABEL"
	InstallerPartOfLabel = "INSTALLER_PART_OF_LABEL"
	// InstallerVersionLabel provides a constant to capture our env variable "INSTALLER_VERSION_LABEL"
	InstallerVersionLabel = "INSTALLER_VERSION_LABEL"
	// IsOnOpenshift provides a constant to capture our env variable "IS_ON_OPENSHIFT"
	IsOnOpenshift = "IS_ON_OPENSHIFT"
	// EnableClusterQuota provides a constant to capture our env variable "ENABLE_CLUSTER_QUOTA"
	EnableClusterQuota = "ENABLE_CLUSTER_QUOTA"
	// VMICalculatorConfiguration provides a constant to capture our env variable "VMI_CALCULATOR_CONFIGURATION" //todo: should delete once sidecar container for custom evaluation is in
	VMICalculatorConfiguration = "VMI_CALCULATOR_CONFIGURATION"
	// TlsLabel provides a constant to capture our env variable "TLS"
	TlsLabel = "TLS"
	// ConfigMapName is the name of the aaq configmap that own aaq resources
	ConfigMapName                                                       = "aaq-config"
	OperatorServiceAccountName                                          = "aaq-operator"
	AAQGate                                                             = "ApplicationAwareQuotaGate"
	ControllerResourceName                                              = ControllerPodName
	SecretResourceName                                                  = "aaq-server-cert"
	AaqServerResourceName                                               = "aaq-server"
	ControllerClusterRoleName                                           = ControllerPodName
	DefaultLauncherConfig                 aaqv1alpha1.VmiCalcConfigName = aaqv1alpha1.VmiPodUsage
	LauncherConfig                                                      = "launcherConfig"
	SocketsSharedDirectory                                              = "/var/run/aaq-sockets"
	SidecarEvaluatorsNumberFlag                                         = "evaluators-sidecars"
	DefaultSidecarsEvaluatorsStartTimeout                               = 2 * time.Minute
)

Variables

View Source
var ResourceBuilder = utils.NewResourceBuilder(commonLabels, operatorLabels)

ResourceBuilder helps in creating k8s resources

Functions

func CipherSuiteIds

func CipherSuiteIds(names []string) []uint16

func CipherSuiteNameMap

func CipherSuiteNameMap() map[string]uint16

func CreateContainer

func CreateContainer(name, image, verbosity, pullPolicy string) corev1.Container

CreateContainer creates container

func CreateDeployment

func CreateDeployment(name, matchKey, matchValue, serviceAccountName string, imagePullSecrets []corev1.LocalObjectReference, replicas int32, infraNodePlacement *sdkapi.NodePlacement) *appsv1.Deployment

CreateDeployment creates deployment

func CreateOperatorDeployment

func CreateOperatorDeployment(name, namespace, matchKey, matchValue, serviceAccount string, imagePullSecrets []corev1.LocalObjectReference, numReplicas int32) *appsv1.Deployment

CreateOperatorDeployment creates operator deployment

func FilterNonScheduableResources

func FilterNonScheduableResources(resourceList corev1.ResourceList) corev1.ResourceList

func GetActiveAAQ

func GetActiveAAQ(c client.Client) (*aaqv1alpha1.AAQ, error)

GetActiveAAQ returns the active AAQ CR

func GetDeployment

func GetDeployment(c client.Client, deploymentName string, deploymentNS string) (*appsv1.Deployment, error)

func GetNamespace

func GetNamespace() string

GetNamespace returns the namespace the pod is executing in

func GetRecommendedInstallerLabelsFromCr

func GetRecommendedInstallerLabelsFromCr(cr *aaqv1alpha1.AAQ) map[string]string

GetRecommendedInstallerLabelsFromCr returns the recommended labels to set on AAQ resources

func IgnoreRqErr added in v1.1.5

func IgnoreRqErr(err string) string

func MergeLabels

func MergeLabels(src, dest map[string]string) map[string]string

MergeLabels adds source labels to destination (does not change existing ones)

func OnOpenshift

func OnOpenshift() bool

func PrintVersion

func PrintVersion()

func SetRecommendedLabels

func SetRecommendedLabels(obj metav1.Object, installerLabels map[string]string, controllerName string)

SetRecommendedLabels sets the recommended labels on AAQ resources (does not get rid of existing ones)

func SetupTLS

func SetupTLS(certManager certificate.Manager) *tls.Config

func TLSVersion

func TLSVersion(version v1.TLSProtocolVersion) uint16

TLSVersion converts from human-readable TLS version (for example "1.1") to the values accepted by tls.Config (for example 0x301).

func ToExternalPodOrError

func ToExternalPodOrError(obj k8sruntime.Object) (*corev1.Pod, error)

todo: ask kubernetes to make this funcs global and remove all this code:

func VerifyPodsWithOutSchedulingGates

func VerifyPodsWithOutSchedulingGates(aaqCli client2.AAQClient, podInformer cache.SharedIndexInformer, namespace string, podNames []string) (bool, error)

VerifyPodsWithOutSchedulingGates checks that all pods in the specified namespace with the specified names do not have scheduling gates.

Types

type BucketingWorkQueue

type BucketingWorkQueue interface {
	AddWithData(key interface{}, data ...interface{})
	AddWithDataRateLimited(key interface{}, data ...interface{})
	GetWithData() (key interface{}, data []interface{}, quit bool)
	Done(key interface{})
	Forget(key interface{})

	ShutDown()
}

BucketingWorkQueue gives a way to add items related to a single entry in a work queue this allows you work on a set of related work in a single UOW-style way

func NewBucketingWorkQueue

func NewBucketingWorkQueue(name string) BucketingWorkQueue

Directories

Path Synopsis
net
generated
Package aaq_sidecar_evaluate is a generated protocol buffer package.
Package aaq_sidecar_evaluate is a generated protocol buffer package.
grpc
* 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.
* 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.

Jump to

Keyboard shortcuts

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