containerized-data-importer/manifests/templates/sample-populator.yaml.in
alromeros 2e9a9257f9
Add support for volume populators (#2482)
* Add support for volume populators in CDI

This commit enables the use of volume populators in CDI, so datavolume-owned PVCs can be populated using custom logic.

Volume populators are CRDs used to populate volumes externally, independently of CDI. These CRDs can now be specified using the new DataSourceRef API field in the DataVolume spec.

When a DataVolume is created with a populated DataSourceRef field, the datavolume-controller creates the corresponding PVC accordingly but skips all the population-related steps. Once the PVC is bound, the DV phase changes to succeeded.

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Modify CDI test infrastructure to support testing of external populators

This commit introduces several changes to CDI ci to support the testing of DataVolumes with external populators:
* A sample volume populator is now deployed in the test infrastructure, in a similar way as bad-webserver or test-proxy. This populator will be used in functional tests from now on.
* A new test file with external population tests has been introduced in the tests directory

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Update dependencies to include lib-volume-populator library

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Add functional tests for proper coverage of external population of DataVolumes

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Minor fixes on external-population logic for DataVolumes:
* Added comments for exported structs
* Removed non-inclusive language
* Improved error messages in webhooks
* Fixed logic on datavolume-controller

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Improve DataVolume external-population logic when using the old 'DataSource' API

This commit introduces several changes into the datavolume external-population controller to improve its behavior when using the DataSource field.

It also introduces minor fixes on the generic populator logic.

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Add unit tests for external-population controller and DV admission

Signed-off-by: Alvaro Romero <alromero@redhat.com>

Signed-off-by: Alvaro Romero <alromero@redhat.com>
2023-01-17 21:56:15 +01:00

140 lines
4.0 KiB
YAML

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
api-approved.kubernetes.io: unapproved
creationTimestamp: null
name: samplepopulators.cdi.sample.populator
spec:
group: cdi.sample.populator
names:
kind: SamplePopulator
listKind: SamplePopulatorList
plural: samplepopulators
singular: samplepopulator
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: SamplePopulator is a specification for a SamplePopulator resource
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
spec:
description: CDIPopulatorSpec is the spec for a SamplePopulator resource
properties:
fileContents:
type: string
fileName:
type: string
required:
- fileContents
- fileName
type: object
required:
- spec
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: cdi-sample-account
namespace: {{ .Namespace }}
labels:
cdi.kubevirt.io/testing: ""
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cdi-sample-role
labels:
cdi.kubevirt.io/testing: ""
rules:
- apiGroups: [""]
resources: [persistentvolumes]
verbs: [get, list, watch, patch]
- apiGroups: [""]
resources: [persistentvolumeclaims]
verbs: [get, list, watch, patch, create, delete]
- apiGroups: [""]
resources: [pods]
verbs: [get, list, watch, create, delete]
- apiGroups: [storage.k8s.io]
resources: [storageclasses]
verbs: [get, list, watch]
- apiGroups: [cdi.sample.populator]
resources: [samplepopulators]
verbs: [get, list, watch]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cdi-sample-binding
labels:
cdi.kubevirt.io/testing: ""
subjects:
- kind: ServiceAccount
name: cdi-sample-account
namespace: {{ .Namespace }}
roleRef:
kind: ClusterRole
name: cdi-sample-role
apiGroup: rbac.authorization.k8s.io
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: cdi-sample-populator
namespace: {{ .Namespace }}
labels:
cdi.kubevirt.io/testing: ""
spec:
selector:
matchLabels:
app: cdi-sample-populator
template:
metadata:
labels:
app: cdi-sample-populator
cdi.kubevirt.io/testing: ""
spec:
serviceAccount: cdi-sample-account
containers:
- name: cdi-sample-populator
image: {{ .DockerRepo }}/cdi-func-test-sample-populator:{{ .DockerTag }}
imagePullPolicy: Always
command: ["/app/tools/cdi-func-test-sample-populator/cdi-func-test-sample-populator-image.binary"]
args:
- --mode=controller
- --image-name={{ .DockerRepo }}/cdi-func-test-sample-populator:{{ .DockerTag }}
- --http-endpoint=:8080
- --namespace={{ .Namespace }}
ports:
- containerPort: 8080
name: http-endpoint
protocol: TCP
env:
- name: CDI_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace