Skip to content

Commit

Permalink
KubeVirt Default Image (#563)
Browse files Browse the repository at this point in the history
* KubeVirt Plugin

* Add kubevirt to defaultPlugins used in e2e

* add kubevirt to alm-examples

* switched to konveyor

* set ENV

* remove redundant entry. Already added plugin to settings.json
  • Loading branch information
kaovilai authored Feb 2, 2022
1 parent fbab17b commit bbf19c5
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const DefaultPluginGCP DefaultPlugin = "gcp"
const DefaultPluginMicrosoftAzure DefaultPlugin = "azure"
const DefaultPluginCSI DefaultPlugin = "csi"
const DefaultPluginOpenShift DefaultPlugin = "openshift"
const DefaultPluginKubeVirt DefaultPlugin = "kubevirt"

type CustomPlugin struct {
Name string `json:"name"`
Expand All @@ -54,6 +55,7 @@ const GCPPluginImageKey UnsupportedImageKey = "gcpPluginImageFqin"
const CSIPluginImageKey UnsupportedImageKey = "csiPluginImageFqin"
const ResticRestoreImageKey UnsupportedImageKey = "resticRestoreImageFqin"
const RegistryImageKey UnsupportedImageKey = "registryImageFqin"
const KubeVirtPluginImageKey UnsupportedImageKey = "kubevirtPluginImageFqin"

type VeleroConfig struct {
// FeatureFlags defines the list of features to enable for Velero instance
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion bundle/manifests/oadp-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ metadata:
"velero": {
"defaultPlugins": [
"openshift",
"aws"
"aws",
"kubevirt"
]
}
},
Expand Down Expand Up @@ -479,6 +480,8 @@ spec:
value: velero-plugin-for-gcp
- name: VELERO_AZURE_PLUGIN_REPO
value: velero-plugin-for-microsoft-azure
- name: VELERO_KUBEVIRT_PLUGIN_REPO
value: kubevirt-velero-plugin
- name: VELERO_CSI_PLUGIN_REPO
value: velero-plugin-for-csi
- name: VELERO_TAG
Expand All @@ -493,6 +496,8 @@ spec:
value: latest
- name: VELERO_CSI_PLUGIN_TAG
value: latest
- name: VELERO_KUBEVIRT_PLUGIN_TAG
value: 0.2.0
image: quay.io/konveyor/oadp-operator:latest
imagePullPolicy: Always
livenessProbe:
Expand Down Expand Up @@ -615,4 +620,6 @@ spec:
name: csi_plugin
- image: quay.io/konveyor/registry:latest
name: registry
- image: quay.io/konveyor/kubevirt-velero-plugin:v0.2.0
name: kubevirt_plugin
version: 99.0.0
4 changes: 4 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ spec:
value: velero-plugin-for-gcp
- name: VELERO_AZURE_PLUGIN_REPO
value: velero-plugin-for-microsoft-azure
- name: VELERO_KUBEVIRT_PLUGIN_REPO
value: kubevirt-velero-plugin
- name: VELERO_CSI_PLUGIN_REPO
value: velero-plugin-for-csi
- name: VELERO_TAG
Expand All @@ -73,6 +75,8 @@ spec:
value: latest
- name: VELERO_CSI_PLUGIN_TAG
value: latest
- name: VELERO_KUBEVIRT_PLUGIN_TAG
value: 0.2.0
args:
- --leader-elect
image: controller:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,6 @@ spec:
name: csi_plugin
- image: quay.io/konveyor/registry:latest
name: registry
- image: quay.io/konveyor/kubevirt-velero-plugin:v0.2.0
name: kubevirt_plugin
version: 99.0.0
1 change: 1 addition & 0 deletions config/samples/oadp_v1alpha1_dpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spec:
defaultPlugins:
- openshift
- aws
- kubevirt
restic:
enable: true
backupLocations:
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
GCPPluginImage = "quay.io/konveyor/velero-plugin-for-gcp:konveyor-1.3.0"
CSIPluginImage = "quay.io/konveyor/velero-plugin-for-csi:konveyor-0.2.0"
RegistryImage = "quay.io/konveyor/registry:oadp-0.3.0"
KubeVirtPluginImage = "quay.io/konveyor/kubevirt-velero-plugin:v0.2.0"
)

// Plugin names
Expand All @@ -26,6 +27,7 @@ const (
VeleroPluginForGCP = "velero-plugin-for-gcp"
VeleroPluginForCSI = "velero-plugin-for-csi"
VeleroPluginForOpenshift = "openshift-velero-plugin"
KubeVirtPlugin = "kubevirt-velero-plugin"
)

// Environment Vars keys
Expand Down
13 changes: 13 additions & 0 deletions pkg/credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ func getAzurePluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
return fmt.Sprintf("%v/%v/%v:%v", os.Getenv("REGISTRY"), os.Getenv("PROJECT"), os.Getenv("VELERO_AZURE_PLUGIN_REPO"), os.Getenv("VELERO_AZURE_PLUGIN_TAG"))
}

func getKubeVirtPluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.KubeVirtPluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.KubeVirtPluginImageKey]
}
if os.Getenv("VELERO_KUBEVIRT_PLUGIN_REPO") == "" {
return common.KubeVirtPluginImage
}
return fmt.Sprintf("%v/%v/%v:%v", os.Getenv("REGISTRY"), os.Getenv("PROJECT"), os.Getenv("VELERO_KUBEVIRT_PLUGIN_REPO"), os.Getenv("VELERO_KUBEVIRT_PLUGIN_TAG"))
}

func getPluginImage(pluginName string, dpa *oadpv1alpha1.DataProtectionApplication) string {
switch pluginName {

Expand All @@ -131,6 +141,9 @@ func getPluginImage(pluginName string, dpa *oadpv1alpha1.DataProtectionApplicati

case common.VeleroPluginForAzure:
return getAzurePluginImage(dpa)

case common.KubeVirtPlugin:
return getKubeVirtPluginImage(dpa)
}
return ""
}
Expand Down
47 changes: 47 additions & 0 deletions pkg/credentials/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,53 @@ func TestCredentials_getPluginImage(t *testing.T) {
"VELERO_CSI_PLUGIN_TAG": "latest",
},
},
// KubeVirt tests
{
name: "given default Velero CR without env var set, image should be built from default",
dpa: &oadpv1alpha1.DataProtectionApplication{
ObjectMeta: metav1.ObjectMeta{
Name: "test-Velero-CR",
Namespace: "test-ns",
},
Spec: oadpv1alpha1.DataProtectionApplicationSpec{
Configuration: &oadpv1alpha1.ApplicationConfig{
Velero: &oadpv1alpha1.VeleroConfig{
DefaultPlugins: []oadpv1alpha1.DefaultPlugin{
oadpv1alpha1.DefaultPluginKubeVirt,
},
},
},
},
},
pluginName: common.KubeVirtPlugin,
wantImage: "quay.io/konveyor/kubevirt-velero-plugin:v0.2.0",
},
{
name: "given default Velero CR with env var set, image should be built via env vars",
dpa: &oadpv1alpha1.DataProtectionApplication{
ObjectMeta: metav1.ObjectMeta{
Name: "test-Velero-CR",
Namespace: "test-ns",
},
Spec: oadpv1alpha1.DataProtectionApplicationSpec{
Configuration: &oadpv1alpha1.ApplicationConfig{
Velero: &oadpv1alpha1.VeleroConfig{
DefaultPlugins: []oadpv1alpha1.DefaultPlugin{
oadpv1alpha1.DefaultPluginKubeVirt,
},
},
},
},
},
pluginName: common.KubeVirtPlugin,
wantImage: "quay.io/kubevirt/kubevirt-velero-plugin:latest",
setEnvVars: map[string]string{
"REGISTRY": "quay.io",
"PROJECT": "kubevirt",
"VELERO_KUBEVIRT_PLUGIN_REPO": "kubevirt-velero-plugin",
"VELERO_KUBEVIRT_PLUGIN_TAG": "latest",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,3 @@ func isCredentialsSecretDeleted(namespace string, credSecretRef string) wait.Con
return false, err
}
}

2 changes: 1 addition & 1 deletion tests/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = BeforeSuite(func() {
if errString != "" {
Expect(errors.New(errString)).NotTo(HaveOccurred())
}

credData, err := readFile(cloud)
Expect(err).NotTo(HaveOccurred())
err = createCredentialsSecret(credData, namespace, getSecretRef(credSecretRef))
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/templates/default_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"configuration":{
"velero":{
"defaultPlugins": [
"openshift", "aws"
"openshift",
"aws",
"kubevirt"
]
}
},
Expand Down

0 comments on commit bbf19c5

Please sign in to comment.