Documentation ¶
Overview ¶
Copyright The Velero Contributors.
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.
Index ¶
- Constants
- Variables
- func DeletePVCIfAny(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvcName string, ...)
- func DeletePVIfAny(ctx context.Context, pvGetter corev1client.CoreV1Interface, pvName string, ...)
- func DeletePodIfAny(ctx context.Context, podGetter corev1client.CoreV1Interface, podName string, ...)
- func EnqueueRequestsFromMapUpdateFunc(fn MapUpdateFunc) handler.EventHandler
- func EnsureDeletePVC(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvc string, ...) error
- func EnsureDeletePod(ctx context.Context, podGetter corev1client.CoreV1Interface, pod string, ...) error
- func EnsureNamespaceExistsAndIsReady(namespace *corev1api.Namespace, client corev1client.NamespaceInterface, ...) (bool, bool, error)
- func GetPodPVCVolume(ctx context.Context, log logrus.FieldLogger, pod *corev1api.Pod, ...) (*corev1api.PersistentVolumeClaim, *corev1api.PersistentVolume, ...)
- func GetSecret(client kbclient.Client, namespace, name string) (*corev1api.Secret, error)
- func GetSecretKey(client kbclient.Client, namespace string, ...) ([]byte, error)
- func GetVolumeDirectory(ctx context.Context, log logrus.FieldLogger, pod *corev1api.Pod, ...) (string, error)
- func GetVolumeMode(ctx context.Context, log logrus.FieldLogger, pod *corev1api.Pod, ...) (uploader.PersistentVolumeMode, error)
- func IsCRDReady(crd *unstructured.Unstructured) (bool, error)
- func IsPVCBound(pvc *corev1api.PersistentVolumeClaim) bool
- func IsPodRunning(pod *corev1api.Pod) error
- func IsPodScheduled(pod *corev1api.Pod) error
- func IsV1Beta1CRDReady(crd *apiextv1beta1.CustomResourceDefinition) bool
- func IsV1CRDReady(crd *apiextv1.CustomResourceDefinition) bool
- func MakePodPVCAttachment(volumeName string, volumeMode *corev1api.PersistentVolumeMode) ([]corev1api.VolumeMount, []corev1api.VolumeDevice)
- func NamespaceAndName(objMeta metav1.Object) string
- func NewAllEventPredicate(f func(object client.Object) bool) predicate.Predicate
- func NewCreateEventPredicate(f func(client.Object) bool) predicate.Predicate
- func NewGenericEventPredicate(f func(object client.Object) bool) predicate.Predicate
- func NewUpdateEventPredicate(f func(client.Object, client.Object) bool) predicate.Predicate
- func ParseResourceRequirements(cpuRequest, memRequest, cpuLimit, memLimit string) (corev1.ResourceRequirements, error)
- func ParseSecurityContext(runAsUser string, runAsGroup string, allowPrivilegeEscalation string, ...) (corev1.SecurityContext, error)
- func PatchResource(original, updated client.Object, kbClient client.Client) error
- func RebindPVC(ctx context.Context, pvcGetter corev1client.CoreV1Interface, ...) (*corev1api.PersistentVolumeClaim, error)
- func ResetPVBinding(ctx context.Context, pvGetter corev1client.CoreV1Interface, ...) (*corev1api.PersistentVolume, error)
- func SetPVReclaimPolicy(ctx context.Context, pvGetter corev1client.CoreV1Interface, ...) (*corev1api.PersistentVolume, error)
- func SinglePathMatch(path string, fs filesystem.Interface, log logrus.FieldLogger) (string, error)
- func WaitPVBound(ctx context.Context, pvGetter corev1client.CoreV1Interface, pvName string, ...) (*corev1api.PersistentVolume, error)
- func WaitPVCBound(ctx context.Context, pvcGetter corev1client.CoreV1Interface, ...) (*corev1api.PersistentVolume, error)
- func WaitPVCConsumed(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvc string, ...) (string, *corev1api.PersistentVolumeClaim, error)
- type FalsePredicate
- type InternalLW
- type MapUpdateFunc
- type PeriodicalEnqueueSource
- type PeriodicalEnqueueSourceOption
- type SpecChangePredicate
Constants ¶
const ( KubeAnnBindCompleted = "pv.kubernetes.io/bind-completed" KubeAnnBoundByController = "pv.kubernetes.io/bound-by-controller" KubeAnnDynamicallyProvisioned = "pv.kubernetes.io/provisioned-by" KubeAnnMigratedTo = "pv.kubernetes.io/migrated-to" KubeAnnSelectedNode = "volume.kubernetes.io/selected-node" )
These annotations are taken from the Kubernetes persistent volume/persistent volume claim controller. They cannot be directly importing because they are part of the kubernetes/kubernetes package, and importing that package is unsupported. Their values are well-known and slow changing. They're duplicated here as constants to provide compile-time checking. Originals can be found in kubernetes/kubernetes/pkg/controller/volume/persistentvolume/util/util.go.
Variables ¶
var ErrorPodVolumeIsNotPVC = errors.New("pod volume is not a PVC")
Functions ¶
func DeletePVCIfAny ¶ added in v1.12.0
func DeletePVCIfAny(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvcName string, pvcNamespace string, log logrus.FieldLogger)
DeletePVCIfAny deletes a PVC by name if it exists, and log an error when the deletion fails
func DeletePVIfAny ¶ added in v1.12.0
func DeletePVIfAny(ctx context.Context, pvGetter corev1client.CoreV1Interface, pvName string, log logrus.FieldLogger)
DeletePVIfAny deletes a PV by name if it exists, and log an error when the deletion fails
func DeletePodIfAny ¶ added in v1.12.0
func DeletePodIfAny(ctx context.Context, podGetter corev1client.CoreV1Interface, podName string, podNamespace string, log logrus.FieldLogger)
DeletePodIfAny deletes a pod by name if it exists, and log an error when the deletion fails
func EnqueueRequestsFromMapUpdateFunc ¶ added in v1.11.0
func EnqueueRequestsFromMapUpdateFunc(fn MapUpdateFunc) handler.EventHandler
EnqueueRequestsFromMapUpdateFunc is for the same purpose with EnqueueRequestsFromMapFunc. Merely, it is more friendly to updating the mapped objects in the MapUpdateFunc, because on Update event, MapUpdateFunc is called for only once with the new object, so if MapUpdateFunc does some update to the mapped objects, the update is done for once
func EnsureDeletePVC ¶ added in v1.12.0
func EnsureDeletePVC(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvc string, namespace string, timeout time.Duration) error
EnsureDeletePVC asserts the existence of a PVC by name, deletes it and waits for its disappearance and returns errors on any failure
func EnsureDeletePod ¶ added in v1.12.0
func EnsureDeletePod(ctx context.Context, podGetter corev1client.CoreV1Interface, pod string, namespace string, timeout time.Duration) error
EnsureDeletePod asserts the existence of a pod by name, deletes it and waits for its disappearance and returns errors on any failure
func EnsureNamespaceExistsAndIsReady ¶ added in v0.11.0
func EnsureNamespaceExistsAndIsReady(namespace *corev1api.Namespace, client corev1client.NamespaceInterface, timeout time.Duration) (bool, bool, error)
EnsureNamespaceExistsAndIsReady attempts to create the provided Kubernetes namespace. It returns three values: a bool indicating whether or not the namespace is ready, a bool indicating whether or not the namespace was created and an error if the creation failed for a reason other than that the namespace already exists. Note that in the case where the namespace already exists and is not ready, this function will return (false, false, nil). If the namespace exists and is marked for deletion, this function will wait up to the timeout for it to fully delete.
func GetPodPVCVolume ¶ added in v1.12.1
func GetPodPVCVolume(ctx context.Context, log logrus.FieldLogger, pod *corev1api.Pod, volumeName string, cli client.Client) ( *corev1api.PersistentVolumeClaim, *corev1api.PersistentVolume, *corev1api.Volume, error)
GetPodPVCVolume gets the PVC, PV and volume for a pod volume name. Returns pod volume in case of ErrorPodVolumeIsNotPVC error
func GetSecretKey ¶ added in v1.6.0
func GetVolumeDirectory ¶ added in v0.9.0
func GetVolumeDirectory(ctx context.Context, log logrus.FieldLogger, pod *corev1api.Pod, volumeName string, cli client.Client) (string, error)
GetVolumeDirectory gets the name of the directory on the host, under /var/lib/kubelet/pods/<podUID>/volumes/, where the specified volume lives. For volumes with a CSIVolumeSource, append "/mount" to the directory name.
func GetVolumeMode ¶ added in v1.12.1
func GetVolumeMode(ctx context.Context, log logrus.FieldLogger, pod *corev1api.Pod, volumeName string, cli client.Client) ( uploader.PersistentVolumeMode, error)
GetVolumeMode gets the uploader.PersistentVolumeMode of the volume.
func IsCRDReady ¶ added in v1.3.0
func IsCRDReady(crd *unstructured.Unstructured) (bool, error)
IsCRDReady triggers IsV1Beta1CRDReady/IsV1CRDReady according to the version of the input param
func IsPVCBound ¶ added in v1.12.0
func IsPVCBound(pvc *corev1api.PersistentVolumeClaim) bool
IsPVCBound returns true if the specified PVC has been bound
func IsPodRunning ¶ added in v1.10.0
IsPodRunning does a well-rounded check to make sure the specified pod is running stably. If not, return the error found
func IsPodScheduled ¶ added in v1.11.0
IsPodScheduled does a well-rounded check to make sure the specified pod has been scheduled into a node and in a stable status. If not, return the error found
func IsV1Beta1CRDReady ¶ added in v1.6.3
func IsV1Beta1CRDReady(crd *apiextv1beta1.CustomResourceDefinition) bool
IsV1Beta1CRDReady checks a v1beta1 CRD to see if it's ready, with both the Established and NamesAccepted conditions.
func IsV1CRDReady ¶ added in v1.6.3
func IsV1CRDReady(crd *apiextv1.CustomResourceDefinition) bool
IsV1CRDReady checks a v1 CRD to see if it's ready, with both the Established and NamesAccepted conditions.
func MakePodPVCAttachment ¶ added in v1.12.1
func MakePodPVCAttachment(volumeName string, volumeMode *corev1api.PersistentVolumeMode) ([]corev1api.VolumeMount, []corev1api.VolumeDevice)
MakePodPVCAttachment returns the volume mounts and devices for a pod needed to attach a PVC
func NamespaceAndName ¶ added in v0.4.0
NamespaceAndName returns a string in the format <namespace>/<name>
func NewAllEventPredicate ¶ added in v1.10.0
NewAllEventPredicate creates a new Predicate that checks all the events with the provided func
func NewCreateEventPredicate ¶ added in v1.11.0
func NewGenericEventPredicate ¶ added in v1.10.0
NewGenericEventPredicate creates a new Predicate that checks the Generic event with the provided func
func NewUpdateEventPredicate ¶ added in v1.11.0
NewUpdateEventPredicate creates a new Predicate that checks the update events with the provided func and ignore others
func ParseResourceRequirements ¶ added in v1.0.1
func ParseResourceRequirements(cpuRequest, memRequest, cpuLimit, memLimit string) (corev1.ResourceRequirements, error)
ParseResourceRequirements takes a set of CPU and memory requests and limit string values and returns a ResourceRequirements struct to be used in a Container. An error is returned if we cannot parse the request/limit.
func ParseSecurityContext ¶ added in v1.5.0
func PatchResource ¶ added in v1.11.0
func RebindPVC ¶ added in v1.12.0
func RebindPVC(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvc *corev1api.PersistentVolumeClaim, pv string) (*corev1api.PersistentVolumeClaim, error)
RebindPVC rebinds a PVC by modifying its VolumeName to the specific PV
func ResetPVBinding ¶ added in v1.12.0
func ResetPVBinding(ctx context.Context, pvGetter corev1client.CoreV1Interface, pv *corev1api.PersistentVolume, labels map[string]string, pvc *corev1api.PersistentVolumeClaim) (*corev1api.PersistentVolume, error)
ResetPVBinding resets the binding info of a PV and adds the required labels so as to make it ready for binding
func SetPVReclaimPolicy ¶ added in v1.12.0
func SetPVReclaimPolicy(ctx context.Context, pvGetter corev1client.CoreV1Interface, pv *corev1api.PersistentVolume, policy corev1api.PersistentVolumeReclaimPolicy) (*corev1api.PersistentVolume, error)
SetPVReclaimPolicy sets the specified reclaim policy to a PV
func SinglePathMatch ¶ added in v1.9.1
func SinglePathMatch(path string, fs filesystem.Interface, log logrus.FieldLogger) (string, error)
SinglePathMatch checks whether pass-in volume path is valid. Check whether there is only one match by the path's pattern.
func WaitPVBound ¶ added in v1.12.0
func WaitPVBound(ctx context.Context, pvGetter corev1client.CoreV1Interface, pvName string, pvcName string, pvcNamespace string, timeout time.Duration) (*corev1api.PersistentVolume, error)
WaitPVBound wait for binding of a PV specified by name and returns the bound PV object
func WaitPVCBound ¶ added in v1.12.0
func WaitPVCBound(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvGetter corev1client.CoreV1Interface, pvc string, namespace string, timeout time.Duration) (*corev1api.PersistentVolume, error)
WaitPVCBound wait for binding of a PVC specified by name and returns the bound PV object
func WaitPVCConsumed ¶ added in v1.12.0
func WaitPVCConsumed(ctx context.Context, pvcGetter corev1client.CoreV1Interface, pvc string, namespace string, storageClient storagev1.StorageV1Interface, timeout time.Duration) (string, *corev1api.PersistentVolumeClaim, error)
WaitPVCConsumed waits for a PVC to be consumed by a pod so that the selected node is set by the pod scheduling; or does nothing if the consuming doesn't affect the PV provision. The latest PVC and the selected node will be returned.
Types ¶
type FalsePredicate ¶ added in v1.10.0
type FalsePredicate struct{}
FalsePredicate always returns false for all kinds of events
func (FalsePredicate) Create ¶ added in v1.10.0
func (f FalsePredicate) Create(event.CreateEvent) bool
Create always returns false
func (FalsePredicate) Delete ¶ added in v1.10.0
func (f FalsePredicate) Delete(event.DeleteEvent) bool
Delete always returns false
func (FalsePredicate) Generic ¶ added in v1.10.0
func (f FalsePredicate) Generic(event.GenericEvent) bool
Generic always returns false
func (FalsePredicate) Update ¶ added in v1.10.0
func (f FalsePredicate) Update(event.UpdateEvent) bool
Update always returns false
type InternalLW ¶ added in v1.12.0
type InternalLW struct { Client kbclient.WithWatch Namespace string ObjectList kbclient.ObjectList }
func (*InternalLW) List ¶ added in v1.12.0
func (lw *InternalLW) List(options metav1.ListOptions) (runtime.Object, error)
func (*InternalLW) Watch ¶ added in v1.12.0
func (lw *InternalLW) Watch(options metav1.ListOptions) (watch.Interface, error)
type PeriodicalEnqueueSource ¶ added in v1.9.0
PeriodicalEnqueueSource is an implementation of interface sigs.k8s.io/controller-runtime/pkg/source/Source It reads the specific resources from Kubernetes/cache and enqueues them into the queue to trigger the reconcile logic periodically
func NewPeriodicalEnqueueSource ¶ added in v1.9.0
func NewPeriodicalEnqueueSource( logger logrus.FieldLogger, client client.Client, objList client.ObjectList, period time.Duration, option PeriodicalEnqueueSourceOption) *PeriodicalEnqueueSource
func (*PeriodicalEnqueueSource) Start ¶ added in v1.9.0
func (p *PeriodicalEnqueueSource) Start(ctx context.Context, h handler.EventHandler, q workqueue.RateLimitingInterface, predicates ...predicate.Predicate) error
Start enqueue items periodically. The predicates only apply to the GenericEvent
func (*PeriodicalEnqueueSource) String ¶ added in v1.9.3
func (p *PeriodicalEnqueueSource) String() string
type PeriodicalEnqueueSourceOption ¶ added in v1.10.0
type PeriodicalEnqueueSourceOption struct {
OrderFunc func(objList client.ObjectList) client.ObjectList
}
type SpecChangePredicate ¶ added in v1.9.1
SpecChangePredicate implements a default update predicate function on Spec change As Velero doesn't enable subresource in CRDs, we cannot use the object's metadata.generation field to check the spec change More details about the generation field refer to https://github.com/kubernetes-sigs/controller-runtime/blob/v0.12.2/pkg/predicate/predicate.go#L156
func (SpecChangePredicate) Update ¶ added in v1.9.1
func (SpecChangePredicate) Update(e event.UpdateEvent) bool