Documentation
¶
Index ¶
- Constants
- func CreateCloneSourcePod(args CloneSourcePodArgs) (*v1.Pod, error)
- func CreateScratchPersistentVolumeClaim(client kubernetes.Interface, pvc *v1.PersistentVolumeClaim, pod *v1.Pod, ...) (*v1.PersistentVolumeClaim, error)
- func CreateUploadPod(args UploadPodArgs) (*v1.Pod, error)
- func CreateUploadService(client kubernetes.Interface, name string, pvc *v1.PersistentVolumeClaim) (*v1.Service, error)
- func DecodePublicKey(keyBytes []byte) (*rsa.PublicKey, error)
- func GetDefaultPodResourceRequirements(cdiclient clientset.Interface) (*v1.ResourceRequirements, error)
- func GetScratchPvcStorageClass(client kubernetes.Interface, cdiclient clientset.Interface, ...) string
- func GetUploadResourceName(name string) string
- func GetUploadServerURL(namespace, pvc, path string) string
- func IgnoreIsNoMatchError(err error) error
- func IgnoreNotFound(err error) error
- func IsCsiCrdsDeployed(c extclientset.Interface) bool
- func IsOpenshift(client kubernetes.Interface) bool
- func MakeCloneSourcePodSpec(image, pullPolicy, sourcePvcName, ownerRefAnno string, ...) *v1.Pod
- func MakeEmptyCDIConfigSpec(name string) *cdiv1.CDIConfig
- func MakePVCOwnerReference(pvc *v1.PersistentVolumeClaim) metav1.OwnerReference
- func MakePodOwnerReference(pod *v1.Pod) metav1.OwnerReference
- func MakeUploadServiceSpec(name string, pvc *v1.PersistentVolumeClaim) *v1.Service
- func NewConfigController(mgr manager.Manager, cdiClient *cdiclientset.Clientset, ...) (controller.Controller, error)
- func NewImportController(mgr manager.Manager, cdiClient *cdiclientset.Clientset, ...) (controller.Controller, error)
- func ParseCloneRequestAnnotation(pvc *v1.PersistentVolumeClaim) (exists bool, namespace, name string)
- func UploadPossibleForPVC(pvc *v1.PersistentVolumeClaim) error
- func ValidateCanCloneSourceAndTargetSpec(sourceSpec, targetSpec *v1.PersistentVolumeClaimSpec) error
- type CDIConfigReconciler
- type CloneController
- type CloneSourcePodArgs
- type Controller
- type DataVolumeController
- type DataVolumeEvent
- type ImportReconciler
- type SmartCloneController
- type UploadController
- type UploadPodArgs
Constants ¶
const ( //AnnCloneRequest sets our expected annotation for a CloneRequest AnnCloneRequest = "k8s.io/CloneRequest" //AnnCloneOf is used to indicate that cloning was complete AnnCloneOf = "k8s.io/CloneOf" // AnnCloneToken is the annotation containing the clone token AnnCloneToken = "cdi.kubevirt.io/storage.clone.token" //CloneUniqueID is used as a special label to be used when we search for the pod CloneUniqueID = "cdi.kubevirt.io/storage.clone.cloneUniqeId" // ErrIncompatiblePVC provides a const to indicate a clone is not possible due to an incompatible PVC ErrIncompatiblePVC = "ErrIncompatiblePVC" // APIServerPublicKeyDir is the path to the apiserver public key dir APIServerPublicKeyDir = "/var/run/cdi/apiserver/key" // APIServerPublicKeyPath is the path to the apiserver public key APIServerPublicKeyPath = APIServerPublicKeyDir + "/id_rsa.pub" )
const ( // AnnAPIGroup is the APIGroup for CDI AnnAPIGroup = "cdi.kubevirt.io" // AnnCreatedBy is a pod annotation indicating if the pod was created by the PVC AnnCreatedBy = AnnAPIGroup + "/storage.createdByController" // AnnPodPhase is a PVC annotation indicating the related pod progress (phase) AnnPodPhase = AnnAPIGroup + "/storage.pod.phase" // AnnPodReady tells whether the pod is ready AnnPodReady = AnnAPIGroup + "/storage.pod.ready" // AnnOwnerRef is used when owner is in a different namespace AnnOwnerRef = AnnAPIGroup + "/storage.ownerRef" )
const ( // SuccessSynced provides a const to represent a Synced status SuccessSynced = "Synced" // ErrResourceExists provides a const to indicate a resource exists error ErrResourceExists = "ErrResourceExists" // ErrResourceDoesntExist provides a const to indicate a resource doesn't exist error ErrResourceDoesntExist = "ErrResourceDoesntExist" // ErrClaimLost provides a const to indicate a claim is lost ErrClaimLost = "ErrClaimLost" // DataVolumeFailed provides a const to represent DataVolume failed status DataVolumeFailed = "DataVolumeFailed" // ImportScheduled provides a const to indicate import is scheduled ImportScheduled = "ImportScheduled" // ImportInProgress provides a const to indicate an import is in progress ImportInProgress = "ImportInProgress" // ImportFailed provides a const to indicate import has failed ImportFailed = "ImportFailed" // ImportSucceeded provides a const to indicate import has succeeded ImportSucceeded = "ImportSucceeded" // CloneScheduled provides a const to indicate clone is scheduled CloneScheduled = "CloneScheduled" // CloneInProgress provides a const to indicate clone is in progress CloneInProgress = "CloneInProgress" // SnapshotForSmartCloneInProgress provides a const to indicate snapshot creation for smart-clone is in progress SnapshotForSmartCloneInProgress = "SnapshotForSmartCloneInProgress" // SnapshotForSmartCloneCreated provides a const to indicate snapshot creation for smart-clone has been completed SnapshotForSmartCloneCreated = "SnapshotForSmartCloneCreated" // SmartClonePVCInProgress provides a const to indicate snapshot creation for smart-clone is in progress SmartClonePVCInProgress = "SmartClonePVCInProgress" // CloneFailed provides a const to indicate clone has failed CloneFailed = "CloneFailed" // CloneSucceeded provides a const to indicate clone has succeeded CloneSucceeded = "CloneSucceeded" // UploadScheduled provides a const to indicate upload is scheduled UploadScheduled = "UploadScheduled" // UploadReady provides a const to indicate upload is in progress UploadReady = "UploadReady" // UploadFailed provides a const to indicate upload has failed UploadFailed = "UploadFailed" // UploadSucceeded provides a const to indicate upload has succeeded UploadSucceeded = "UploadSucceeded" // MessageResourceExists provides a const to form a resource exists error message MessageResourceExists = "Resource %q already exists and is not managed by DataVolume" // MessageResourceDoesntExist provides a const to form a resource doesn't exist error message MessageResourceDoesntExist = "Resource managed by %q doesn't exist" // MessageResourceSynced provides a const to standardize a Resource Synced message MessageResourceSynced = "DataVolume synced successfully" // MessageErrClaimLost provides a const to form claim lost message MessageErrClaimLost = "PVC %s lost" // MessageImportScheduled provides a const to form import is scheduled message MessageImportScheduled = "Import into %s scheduled" // MessageImportInProgress provides a const to form import is in progress message MessageImportInProgress = "Import into %s in progress" // MessageImportFailed provides a const to form import has failed message MessageImportFailed = "Failed to import into PVC %s" // MessageImportSucceeded provides a const to form import has succeeded message MessageImportSucceeded = "Successfully imported into PVC %s" // MessageCloneScheduled provides a const to form clone is scheduled message MessageCloneScheduled = "Cloning from %s/%s into %s/%s scheduled" // MessageCloneInProgress provides a const to form clone is in progress message MessageCloneInProgress = "Cloning from %s/%s into %s/%s in progress" // MessageCloneFailed provides a const to form clone has failed message MessageCloneFailed = "Cloning from %s/%s into %s/%s failed" // MessageCloneSucceeded provides a const to form clone has succeeded message MessageCloneSucceeded = "Successfully cloned from %s/%s into %s/%s" // MessageSmartCloneInProgress provides a const to form snapshot for smart-clone is in progress message MessageSmartCloneInProgress = "Creating snapshot for smart-clone is in progress (for pvc %s/%s)" // MessageSmartClonePVCInProgress provides a const to form snapshot for smart-clone is in progress message MessageSmartClonePVCInProgress = "Creating PVC for smart-clone is in progress (for pvc %s/%s)" // MessageUploadScheduled provides a const to form upload is scheduled message MessageUploadScheduled = "Upload into %s scheduled" // MessageUploadReady provides a const to form upload is ready message MessageUploadReady = "Upload into %s ready" // MessageUploadFailed provides a const to form upload has failed message MessageUploadFailed = "Upload into %s failed" // MessageUploadSucceeded provides a const to form upload has succeeded message MessageUploadSucceeded = "Successfully uploaded into %s" )
const ( // AnnSource provide a const for our PVC import source annotation AnnSource = AnnAPIGroup + "/storage.import.source" // AnnEndpoint provides a const for our PVC endpoint annotation AnnEndpoint = AnnAPIGroup + "/storage.import.endpoint" // AnnSecret provides a const for our PVC secretName annotation AnnSecret = AnnAPIGroup + "/storage.import.secretName" // AnnCertConfigMap is the name of a configmap containing tls certs AnnCertConfigMap = AnnAPIGroup + "/storage.import.certConfigMap" // AnnContentType provides a const for the PVC content-type AnnContentType = AnnAPIGroup + "/storage.contentType" // AnnImportPod provides a const for our PVC importPodName annotation AnnImportPod = AnnAPIGroup + "/storage.import.importPodName" // AnnRequiresScratch provides a const for our PVC requires scratch annotation AnnRequiresScratch = AnnAPIGroup + "/storage.import.requiresScratch" //LabelImportPvc is a pod label used to find the import pod that was created by the relevant PVC LabelImportPvc = AnnAPIGroup + "/storage.import.importPvcName" //AnnDefaultStorageClass is the annotation indicating that a storage class is the default one. AnnDefaultStorageClass = "storageclass.kubernetes.io/is-default-class" // 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" )
const ( // AnnUploadRequest marks that a PVC should be made available for upload AnnUploadRequest = "cdi.kubevirt.io/storage.upload.target" // AnnUploadClientName is the TLS name uploadserver will accept requests from AnnUploadClientName = "cdi.kubevirt.io/uploadClientName" )
const ( // DataVolName provides a const to use for creating volumes in pod specs DataVolName = "cdi-data-vol" // CertVolName is the name of the volumecontaining certs CertVolName = "cdi-cert-vol" // ScratchVolName provides a const to use for creating scratch pvc volumes in pod specs ScratchVolName = "cdi-scratch-vol" // ImagePathName provides a const to use for creating volumes in pod specs ImagePathName = "image-path" // SourceHTTP is the source type HTTP, if unspecified or invalid, it defaults to SourceHTTP SourceHTTP = "http" // SourceS3 is the source type S3 SourceS3 = "s3" // SourceGlance is the source type of glance SourceGlance = "glance" // SourceNone means there is no source. SourceNone = "none" // SourceRegistry is the source type of Registry SourceRegistry = "registry" )
const (
//AnnSmartCloneRequest sets our expected annotation for a CloneRequest
AnnSmartCloneRequest = "k8s.io/SmartCloneRequest"
)
Variables ¶
This section is empty.
Functions ¶
func CreateCloneSourcePod ¶
func CreateCloneSourcePod(args CloneSourcePodArgs) (*v1.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 CreateScratchPersistentVolumeClaim ¶ added in v1.7.0
func CreateScratchPersistentVolumeClaim(client kubernetes.Interface, pvc *v1.PersistentVolumeClaim, pod *v1.Pod, name, storageClassName string) (*v1.PersistentVolumeClaim, error)
CreateScratchPersistentVolumeClaim creates and returns a pointer to a scratch PVC which is created based on the passed-in pvc and storage class name.
func CreateUploadPod ¶
func CreateUploadPod(args UploadPodArgs) (*v1.Pod, error)
CreateUploadPod creates upload service pod manifest and sends to server
func CreateUploadService ¶
func CreateUploadService(client kubernetes.Interface, name string, pvc *v1.PersistentVolumeClaim) (*v1.Service, error)
CreateUploadService creates upload service service manifest and sends to server
func DecodePublicKey ¶ added in v1.9.4
DecodePublicKey turns a bunch of bytes into a public key
func GetDefaultPodResourceRequirements ¶ added in v1.12.0
func GetDefaultPodResourceRequirements(cdiclient clientset.Interface) (*v1.ResourceRequirements, error)
GetDefaultPodResourceRequirements gets default pod resource requirements from cdi config status
func GetScratchPvcStorageClass ¶ added in v1.7.0
func GetScratchPvcStorageClass(client kubernetes.Interface, cdiclient clientset.Interface, pvc *v1.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 map. 2. If 1 is not available use the 'default' storage class. 3. If 2 is not available use the storage class name of the original pvc that will own the scratch pvc. 4. If none of those are available, return blank.
func GetUploadResourceName ¶
GetUploadResourceName returns the name given to upload resources
func GetUploadServerURL ¶ added in v1.10.1
GetUploadServerURL returns the url the proxy should post to for a particular pvc
func IgnoreIsNoMatchError ¶ added in v1.12.0
IgnoreIsNoMatchError returns nil if the error is a IsNoMatchError. We will want to ignore this error for optional CRDs, if it is not found, just ignore it.
func IgnoreNotFound ¶ added in v1.12.0
IgnoreNotFound returns nil if the error is a NotFound error. We generally want to ignore (not requeue) NotFound errors, since we'll get a reconciliation request once the object exists, and requeuing in the meantime won't help.
func IsCsiCrdsDeployed ¶ added in v1.10.0
func IsCsiCrdsDeployed(c extclientset.Interface) bool
IsCsiCrdsDeployed checks whether the CSI snapshotter CRD are deployed
func IsOpenshift ¶ added in v1.6.0
func IsOpenshift(client kubernetes.Interface) bool
IsOpenshift checks if we are on OpenShift platform
func MakeCloneSourcePodSpec ¶
func MakeCloneSourcePodSpec(image, pullPolicy, sourcePvcName, ownerRefAnno string, clientKey, clientCert, serverCACert []byte, pvc *v1.PersistentVolumeClaim, resourceRequirements *v1.ResourceRequirements) *v1.Pod
MakeCloneSourcePodSpec creates and returns the clone source pod spec based on the target pvc.
func MakeEmptyCDIConfigSpec ¶ added in v1.7.0
MakeEmptyCDIConfigSpec creates cdi config manifest
func MakePVCOwnerReference ¶ added in v1.5.1
func MakePVCOwnerReference(pvc *v1.PersistentVolumeClaim) metav1.OwnerReference
MakePVCOwnerReference makes owner reference from a PVC
func MakePodOwnerReference ¶ added in v1.5.1
func MakePodOwnerReference(pod *v1.Pod) metav1.OwnerReference
MakePodOwnerReference makes owner reference from a Pod
func MakeUploadServiceSpec ¶
func MakeUploadServiceSpec(name string, pvc *v1.PersistentVolumeClaim) *v1.Service
MakeUploadServiceSpec creates upload service service manifest
func NewConfigController ¶ added in v1.6.0
func NewConfigController(mgr manager.Manager, cdiClient *cdiclientset.Clientset, k8sClient kubernetes.Interface, log logr.Logger, uploadProxyServiceName, configName string) (controller.Controller, error)
NewConfigController creates a new instance of the config controller.
func NewImportController ¶
func NewImportController(mgr manager.Manager, cdiClient *cdiclientset.Clientset, k8sClient kubernetes.Interface, log logr.Logger, importerImage, pullPolicy, verbose string) (controller.Controller, error)
NewImportController creates a new instance of the import controller.
func ParseCloneRequestAnnotation ¶ added in v1.11.0
func ParseCloneRequestAnnotation(pvc *v1.PersistentVolumeClaim) (exists bool, namespace, name string)
ParseCloneRequestAnnotation parses the clone request annotation
func UploadPossibleForPVC ¶
func UploadPossibleForPVC(pvc *v1.PersistentVolumeClaim) error
UploadPossibleForPVC is called by the api server to see whether to return an upload token
func ValidateCanCloneSourceAndTargetSpec ¶ added in v1.9.0
func ValidateCanCloneSourceAndTargetSpec(sourceSpec, targetSpec *v1.PersistentVolumeClaimSpec) error
ValidateCanCloneSourceAndTargetSpec validates the specs passed in are compatible for cloning.
Types ¶
type CDIConfigReconciler ¶ added in v1.12.0
type CDIConfigReconciler struct { Client client.Client CdiClient cdiclientset.Interface K8sClient kubernetes.Interface Scheme *runtime.Scheme Log logr.Logger UploadProxyServiceName string ConfigName string CDINamespace string }
CDIConfigReconciler members
func (*CDIConfigReconciler) Init ¶ added in v1.12.0
func (r *CDIConfigReconciler) Init() error
Init initializes a CDIConfig object.
type CloneController ¶
type CloneController struct { Controller // contains filtered or unexported fields }
CloneController represents the CDI Clone Controller
func NewCloneController ¶
func NewCloneController(client kubernetes.Interface, cdiClientSet clientset.Interface, pvcInformer coreinformers.PersistentVolumeClaimInformer, podInformer coreinformers.PodInformer, image string, pullPolicy string, verbose string, clientCertGenerator generator.CertGenerator, serverCAFetcher fetcher.CertBundleFetcher, apiServerKey *rsa.PublicKey) *CloneController
NewCloneController sets up a Clone Controller, and returns a pointer to to the newly created Controller
func (*CloneController) ProcessNextPvcItem ¶
func (cc *CloneController) ProcessNextPvcItem() bool
ProcessNextPvcItem ...
func (*CloneController) Run ¶
func (cc *CloneController) Run(threadiness int, stopCh <-chan struct{}) error
Run is being called from cdi-controller (cmd)
type CloneSourcePodArgs ¶ added in v1.13.0
type CloneSourcePodArgs struct { Client kubernetes.Interface CDIClient clientset.Interface Image, PullPolicy string ServerCACert, ClientCert, ClientKey []byte PVC *v1.PersistentVolumeClaim }
CloneSourcePodArgs are the required args to create a clone source pod
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is a struct that contains common information and functionality used by all CDI controllers.
func NewController ¶
func NewController(client kubernetes.Interface, pvcInformer coreinformers.PersistentVolumeClaimInformer, podInformer coreinformers.PodInformer, image string, pullPolicy string, verbose string) *Controller
NewController is called when we instantiate any CDI controller.
type DataVolumeController ¶
type DataVolumeController struct {
// contains filtered or unexported fields
}
DataVolumeController represents the CDI Data Volume Controller
func NewDataVolumeController ¶
func NewDataVolumeController( kubeclientset kubernetes.Interface, cdiClientSet clientset.Interface, csiClientSet csiclientset.Interface, extClientSet extclientset.Interface, pvcInformer coreinformers.PersistentVolumeClaimInformer, dataVolumeInformer informers.DataVolumeInformer) *DataVolumeController
NewDataVolumeController sets up a Data Volume Controller, and return a pointer to the newly created Controller
func (*DataVolumeController) Run ¶
func (c *DataVolumeController) Run(threadiness int, stopCh <-chan struct{}) error
Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers to finish processing their current work items.
type DataVolumeEvent ¶ added in v1.3.0
type DataVolumeEvent struct {
// contains filtered or unexported fields
}
DataVolumeEvent reoresents event
type ImportReconciler ¶ added in v1.12.0
type ImportReconciler struct { Client client.Client CdiClient cdiclientset.Interface K8sClient kubernetes.Interface Scheme *runtime.Scheme Log logr.Logger Image string Verbose string PullPolicy string // contains filtered or unexported fields }
ImportReconciler members
type SmartCloneController ¶ added in v1.10.0
type SmartCloneController struct {
// contains filtered or unexported fields
}
SmartCloneController represents the CDI SmartClone Controller
func NewSmartCloneController ¶ added in v1.10.0
func NewSmartCloneController(client kubernetes.Interface, cdiClientSet clientset.Interface, csiClientSet csiclientset.Interface, pvcInformer coreinformers.PersistentVolumeClaimInformer, snapshotInformer snapshotsinformers.VolumeSnapshotInformer, dataVolumeInformer informers.DataVolumeInformer) *SmartCloneController
NewSmartCloneController sets up a Smart Clone Controller, and returns a pointer to to the newly created Controller
func (*SmartCloneController) ProcessNextItem ¶ added in v1.10.0
func (c *SmartCloneController) ProcessNextItem() bool
ProcessNextItem ...
func (*SmartCloneController) Run ¶ added in v1.10.0
func (c *SmartCloneController) Run(threadiness int, stopCh <-chan struct{}) error
Run is being called from cdi-controller (cmd)
type UploadController ¶
type UploadController struct {
// contains filtered or unexported fields
}
UploadController members
func NewUploadController ¶
func NewUploadController(client kubernetes.Interface, cdiClientSet clientset.Interface, pvcInformer coreinformers.PersistentVolumeClaimInformer, podInformer coreinformers.PodInformer, serviceInformer coreinformers.ServiceInformer, uploadServiceImage string, uploadProxyServiceName string, pullPolicy string, verbose string, serverCertGenerator generator.CertGenerator, clientCAFetcher fetcher.CertBundleFetcher) *UploadController
NewUploadController returns a new UploadController
func (*UploadController) Init ¶ added in v1.7.0
func (c *UploadController) Init() error
Init does synchronous initialization before being considered "ready"
func (*UploadController) Run ¶
func (c *UploadController) Run(threadiness int, stopCh <-chan struct{}) error
Run sets up UploadController state and executes main event loop
type UploadPodArgs ¶ added in v1.11.0
type UploadPodArgs struct { Client kubernetes.Interface CdiClient clientset.Interface Image string Verbose string PullPolicy string Name string PVC *v1.PersistentVolumeClaim ScratchPVCName string ClientName string ServerCert, ServerKey, ClientCA []byte }
UploadPodArgs are the parameters required to create an upload pod