controller

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: Apache-2.0 Imports: 66 Imported by: 17

Documentation

Index

Constants

View Source
const (
	// TokenKeyDir is the path to the apiserver public key dir
	//nolint:gosec // This is a path, not the key itself
	TokenKeyDir = "/var/run/cdi/token/keys"

	// TokenPublicKeyPath is the path to the apiserver public key
	TokenPublicKeyPath = TokenKeyDir + "/id_rsa.pub"

	// TokenPrivateKeyPath is the path to the apiserver private key
	TokenPrivateKeyPath = TokenKeyDir + "/id_rsa"

	// CloneSucceededPVC provides a const to indicate a clone to the PVC succeeded
	CloneSucceededPVC = "CloneSucceeded"
)
View Source
const (
	// ErrDataSourceAlreadyManaged provides a const to indicate DataSource already managed error
	ErrDataSourceAlreadyManaged = "ErrDataSourceAlreadyManaged"
	// MessageDataSourceAlreadyManaged provides a const to form DataSource already managed error message
	MessageDataSourceAlreadyManaged = "DataSource %s is already managed by DataImportCron %s"
)
View Source
const (
	// AnnSourceDesiredDigest is the digest of the pending updated image
	AnnSourceDesiredDigest = cc.AnnAPIGroup + "/storage.import.sourceDesiredDigest"
	// AnnImageStreamDockerRef is the ImageStream Docker reference
	AnnImageStreamDockerRef = cc.AnnAPIGroup + "/storage.import.imageStreamDockerRef"
	// AnnNextCronTime is the next time stamp which satisfies the cron expression
	AnnNextCronTime = cc.AnnAPIGroup + "/storage.import.nextCronTime"
	// AnnLastCronTime is the cron last execution time stamp
	AnnLastCronTime = cc.AnnAPIGroup + "/storage.import.lastCronTime"
	// AnnLastUseTime is the PVC last use time stamp
	AnnLastUseTime = cc.AnnAPIGroup + "/storage.import.lastUseTime"
	// AnnStorageClass is the cron DV's storage class
	AnnStorageClass = cc.AnnAPIGroup + "/storage.import.storageClass"
)
View Source
const (
	// ErrImportFailedPVC provides a const to indicate an import to the PVC failed
	ErrImportFailedPVC = "ErrImportFailed"
	// ImportSucceededPVC provides a const to indicate an import to the PVC failed
	ImportSucceededPVC = "ImportSucceeded"

	// ImportTargetInUse is reason for event created when an import pvc is in use
	ImportTargetInUse = "ImportTargetInUse"
)
View Source
const (
	// AnnUploadClientName is the TLS name uploadserver will accept requests from
	AnnUploadClientName = "cdi.kubevirt.io/uploadClientName"

	// AnnUploadPod name of the upload pod
	AnnUploadPod = "cdi.kubevirt.io/storage.uploadPodName"

	// UploadSucceededPVC provides a const to indicate an import to the PVC failed
	UploadSucceededPVC = "UploadSucceeded"

	// UploadTargetInUse is reason for event created when an upload pvc is in use
	UploadTargetInUse = "UploadTargetInUse"
)
View Source
const (
	// CertVolName is the name of the volume containing certs
	CertVolName = "cdi-cert-vol"

	// SecretVolName is the name of the volume containing gcs key
	//nolint:gosec // This is not a real secret
	SecretVolName = "cdi-secret-vol"

	// AnnOwnerRef is used when owner is in a different namespace
	AnnOwnerRef = cc.AnnAPIGroup + "/storage.ownerRef"

	// PodRunningReason is const that defines the pod was started as a reason
	PodRunningReason = "Pod is running"

	// ScratchSpaceRequiredReason is a const that defines the pod exited due to a lack of scratch space
	ScratchSpaceRequiredReason = "Scratch space required"

	// ImagePullFailedReason is a const that defines the pod exited due to failure when pulling image
	ImagePullFailedReason = "ImagePullFailed"

	// ImportCompleteMessage is a const that defines the pod completeded the import successfully
	ImportCompleteMessage = "Import Complete"

	// ProxyCertVolName is the name of the volumecontaining certs
	ProxyCertVolName = "cdi-proxy-cert-vol"
	// ClusterWideProxyAPIGroup is the APIGroup for OpenShift Cluster Wide Proxy
	ClusterWideProxyAPIGroup = "config.openshift.io"
	// ClusterWideProxyAPIKind is the APIKind for OpenShift Cluster Wide Proxy
	ClusterWideProxyAPIKind = "Proxy"
	// ClusterWideProxyAPIVersion is the APIVersion for OpenShift Cluster Wide Proxy
	ClusterWideProxyAPIVersion = "v1"
	// ClusterWideProxyName is the OpenShift Cluster Wide Proxy object name. There is only one obj in the cluster.
	ClusterWideProxyName = "cluster"
	// ClusterWideProxyConfigMapName is the OpenShift Cluster Wide Proxy ConfigMap name for CA certificates.
	ClusterWideProxyConfigMapName = "user-ca-bundle"
	// ClusterWideProxyConfigMapNameSpace is the OpenShift Cluster Wide Proxy ConfigMap namespace for CA certificates.
	ClusterWideProxyConfigMapNameSpace = "openshift-config"
	// ClusterWideProxyConfigMapKey is the OpenShift Cluster Wide Proxy ConfigMap key name for CA certificates.
	ClusterWideProxyConfigMapKey = "ca-bundle.crt"
)
View Source
const (
	AnnConfigAuthority = "cdi.kubevirt.io/configAuthority"
)

AnnConfigAuthority is the annotation specifying a resource as the CDIConfig authority

Variables

View Source
var ErrNotManagedByCron = errors.New("DataSource is not managed by this DataImportCron")

Functions

func DecodePublicKey added in v1.9.4

func DecodePublicKey(keyBytes []byte) (*rsa.PublicKey, error)

DecodePublicKey turns a bunch of bytes into a public key

func FindDataImportCronConditionByType added in v1.42.0

func FindDataImportCronConditionByType(cron *cdiv1.DataImportCron, conditionType cdiv1.DataImportCronConditionType) *cdiv1.DataImportCronCondition

FindDataImportCronConditionByType finds DataImportCronCondition by condition type

func FindDataSourceConditionByType added in v1.42.0

func FindDataSourceConditionByType(ds *cdiv1.DataSource, conditionType cdiv1.DataSourceConditionType) *cdiv1.DataSourceCondition

FindDataSourceConditionByType finds DataSourceCondition by condition type

func GetCronJobName added in v1.41.1

func GetCronJobName(cron *cdiv1.DataImportCron) string

GetCronJobName get CronJob name based on cron name and UID

func GetFilesystemOverhead added in v1.24.0

func GetFilesystemOverhead(ctx context.Context, client client.Client, pvc *corev1.PersistentVolumeClaim) (cdiv1.Percent, error)

GetFilesystemOverhead determines the filesystem overhead defined in CDIConfig for this PVC's volumeMode and storageClass.

func GetImportProxyConfig added in v1.31.0

func GetImportProxyConfig(config *cdiv1.CDIConfig, field string) (string, error)

GetImportProxyConfig attempts to import proxy URLs if configured in the CDIConfig.

func GetImportProxyConfigMapName added in v1.56.0

func GetImportProxyConfigMapName(pvcName string) string

GetImportProxyConfigMapName returns the import proxy ConfigMap name

func GetInitialJobName added in v1.43.1

func GetInitialJobName(cron *cdiv1.DataImportCron) string

GetInitialJobName get initial job name based on cron name and UID

func GetScratchPvcStorageClass added in v1.7.0

func GetScratchPvcStorageClass(client client.Client, pvc *corev1.PersistentVolumeClaim) string

GetScratchPvcStorageClass tries to determine which storage class to use for use with a scratch persistent volume claim. The order of preference is the following: 1. Defined value in CDI Config field scratchSpaceStorageClass. 2. If 1 is not available, use the storage class name of the original pvc that will own the scratch pvc. 3. If none of those are available, return blank.

func GetUploadServerURL added in v1.10.1

func GetUploadServerURL(namespace, pvc, uploadPath string) string

GetUploadServerURL returns the url the proxy should post to for a particular pvc

func InitPollerPodSpec added in v1.57.0

func InitPollerPodSpec(c client.Client, cron *cdiv1.DataImportCron, podSpec *corev1.PodSpec, image string, pullPolicy corev1.PullPolicy, log logr.Logger) error

InitPollerPodSpec inits poller PodSpec

func IsInsecureTLS added in v1.41.1

func IsInsecureTLS(ep string, cdiConfig *cdiv1.CDIConfig, log logr.Logger) (bool, error)

IsInsecureTLS checks if TLS security is disabled for the given endpoint

func MakeCloneSourcePodSpec

func MakeCloneSourcePodSpec(sourceVolumeMode corev1.PersistentVolumeMode, image, pullPolicy, ownerRefAnno string, imagePullSecrets []corev1.LocalObjectReference,
	serverCACert []byte, targetPvc, sourcePvc *corev1.PersistentVolumeClaim, resourceRequirements *corev1.ResourceRequirements,
	workloadNodePlacement *sdkapi.NodePlacement) *corev1.Pod

MakeCloneSourcePodSpec creates and returns the clone source pod spec based on the target pvc.

func MakeEmptyStorageProfileSpec added in v1.33.0

func MakeEmptyStorageProfileSpec(name string) *cdiv1.StorageProfile

MakeEmptyStorageProfileSpec creates StorageProfile manifest

func MakePVCOwnerReference added in v1.5.1

func MakePVCOwnerReference(pvc *corev1.PersistentVolumeClaim) metav1.OwnerReference

MakePVCOwnerReference makes owner reference from a PVC

func MakePodOwnerReference added in v1.5.1

func MakePodOwnerReference(pod *corev1.Pod) metav1.OwnerReference

MakePodOwnerReference makes owner reference from a Pod

func NewCloneController

func NewCloneController(mgr manager.Manager,
	log logr.Logger,
	image, pullPolicy,
	verbose string,
	clientCertGenerator generator.CertGenerator,
	serverCAFetcher fetcher.CertBundleFetcher,
	apiServerKey *rsa.PublicKey,
	installerLabels map[string]string) (controller.Controller, error)

NewCloneController creates a new instance of the config controller.

func NewConfigController added in v1.6.0

func NewConfigController(mgr manager.Manager, log logr.Logger, uploadProxyServiceName, configName string, installerLabels map[string]string) (controller.Controller, error)

NewConfigController creates a new instance of the config controller.

func NewDataImportCronController added in v1.41.1

func NewDataImportCronController(mgr manager.Manager, log logr.Logger, importerImage, pullPolicy string, installerLabels map[string]string) (controller.Controller, error)

NewDataImportCronController creates a new instance of the DataImportCron controller

func NewDataSourceController added in v1.43.0

func NewDataSourceController(mgr manager.Manager, log logr.Logger, installerLabels map[string]string) (controller.Controller, error)

NewDataSourceController creates a new instance of the DataSource controller

func NewImportController

func NewImportController(mgr manager.Manager, log logr.Logger, importerImage, pullPolicy, verbose string, installerLabels map[string]string) (controller.Controller, error)

NewImportController creates a new instance of the import controller.

func NewStorageProfileController added in v1.33.0

func NewStorageProfileController(mgr manager.Manager, log logr.Logger, installerLabels map[string]string) (controller.Controller, error)

NewStorageProfileController creates a new instance of the StorageProfile controller.

func NewUploadController

func NewUploadController(mgr manager.Manager, log logr.Logger, uploadImage, pullPolicy, verbose string, serverCertGenerator generator.CertGenerator, clientCAFetcher fetcher.CertBundleFetcher, installerLabels map[string]string) (controller.Controller, error)

NewUploadController creates a new instance of the upload controller.

func ParseCloneRequestAnnotation added in v1.11.0

func ParseCloneRequestAnnotation(pvc *corev1.PersistentVolumeClaim) (exists bool, namespace, name string)

ParseCloneRequestAnnotation parses the clone request annotation

func UploadPossibleForPVC

func UploadPossibleForPVC(pvc *corev1.PersistentVolumeClaim) error

UploadPossibleForPVC is called by the api server to see whether to return an upload token

func ValidateCanCloneSourceAndTargetContentType added in v1.30.0

func ValidateCanCloneSourceAndTargetContentType(sourcePvc, targetPvc *corev1.PersistentVolumeClaim) (cdiv1.DataVolumeContentType, error)

ValidateCanCloneSourceAndTargetContentType validates the pvcs passed has the same content type.

func ValidateCanCloneSourceAndTargetSpec added in v1.9.0

func ValidateCanCloneSourceAndTargetSpec(ctx context.Context, c client.Client, sourcePvc, targetPvc *corev1.PersistentVolumeClaim, contentType cdiv1.DataVolumeContentType) error

ValidateCanCloneSourceAndTargetSpec validates the specs passed in are compatible for cloning.

Types

type CDIConfigReconciler added in v1.12.0

type CDIConfigReconciler struct {
	// contains filtered or unexported fields
}

CDIConfigReconciler members

func (*CDIConfigReconciler) Init added in v1.12.0

func (r *CDIConfigReconciler) Init() error

Init initializes a CDIConfig object.

func (*CDIConfigReconciler) Reconcile added in v1.12.0

Reconcile the reconcile loop for the CDIConfig object.

type CloneReconciler added in v1.14.0

type CloneReconciler struct {
	// contains filtered or unexported fields
}

CloneReconciler members

func (*CloneReconciler) CreateCloneSourcePod added in v1.14.0

func (r *CloneReconciler) CreateCloneSourcePod(image, pullPolicy string, pvc *corev1.PersistentVolumeClaim, log logr.Logger) (*corev1.Pod, error)

CreateCloneSourcePod creates our cloning src pod which will be used for out of band cloning to read the contents of the src PVC

func (*CloneReconciler) Reconcile added in v1.14.0

Reconcile the reconcile loop for host assisted clone pvc.

type CryptoEnvVars added in v1.52.0

type CryptoEnvVars struct {
	Ciphers       string
	MinTLSVersion string
}

CryptoEnvVars holds the TLS crypto-related configurables for the upload server

type DataImportCronReconciler added in v1.41.1

type DataImportCronReconciler struct {
	// contains filtered or unexported fields
}

DataImportCronReconciler members

func (*DataImportCronReconciler) Reconcile added in v1.41.1

Reconcile loop for DataImportCronReconciler

type DataSourceReconciler added in v1.43.0

type DataSourceReconciler struct {
	// contains filtered or unexported fields
}

DataSourceReconciler members

func (*DataSourceReconciler) Reconcile added in v1.43.0

Reconcile loop for DataSourceReconciler

type ImportReconciler added in v1.12.0

type ImportReconciler struct {
	// contains filtered or unexported fields
}

ImportReconciler members

func (*ImportReconciler) Reconcile added in v1.12.0

Reconcile the reconcile loop for the CDIConfig object.

type StorageProfileReconciler added in v1.33.0

type StorageProfileReconciler struct {
	// contains filtered or unexported fields
}

StorageProfileReconciler members

func (*StorageProfileReconciler) Reconcile added in v1.33.0

Reconcile the reconcile.Reconciler implementation for the StorageProfileReconciler object.

type UploadPodArgs added in v1.11.0

type UploadPodArgs struct {
	Name                            string
	PVC                             *corev1.PersistentVolumeClaim
	ScratchPVCName                  string
	ClientName                      string
	FilesystemOverhead              string
	ServerCert, ServerKey, ClientCA []byte
	Preallocation                   string
	CryptoEnvVars                   CryptoEnvVars
	Deadline                        *time.Time
}

UploadPodArgs are the parameters required to create an upload pod

type UploadReconciler added in v1.14.0

type UploadReconciler struct {
	// contains filtered or unexported fields
}

UploadReconciler members

func (*UploadReconciler) Reconcile added in v1.14.0

Reconcile the reconcile loop for the CDIConfig object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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