Skip to content

Commit 98ac43d

Browse files
committed
feat: Install CDI when creating cluster
1 parent 71989e4 commit 98ac43d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

main.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
VirtinkVersion = "v0.13.0"
2727
VirtinkProviderVersion = "v0.6.0"
2828
IPAddressManagerVersion = "v1.2.1"
29+
CDIVersion = "v1.55.2"
2930
)
3031

3132
var version string
@@ -101,6 +102,25 @@ func main() {
101102
}
102103
}
103104

105+
cdiCRDOutput, err := getCommandOutput(exec.Command("kubectl", "get", "crd", "datavolumes.cdi.kubevirt.io", "--ignore-not-found"))
106+
if err != nil {
107+
return fmt.Errorf("get CDI CRDs: %s", err)
108+
}
109+
if len(cdiCRDOutput) == 0 {
110+
fmt.Println("Installing CDI")
111+
if err := runCommand(exec.Command("kubectl", "apply", "-f", fmt.Sprintf("https://github.com/kubevirt/containerized-data-importer/releases/download/%s/cdi-operator.yaml", CDIVersion))); err != nil {
112+
return fmt.Errorf("install CDI operator: %s", err)
113+
}
114+
if err := runCommand(exec.Command("kubectl", "apply", "-f", fmt.Sprintf("https://github.com/kubevirt/containerized-data-importer/releases/download/%s/cdi-cr.yaml", CDIVersion))); err != nil {
115+
return fmt.Errorf("install CDI: %s", err)
116+
}
117+
118+
fmt.Println("Waiting for CDI to be available...")
119+
if err := runCommand(exec.Command("kubectl", "wait", "cdi", "cdi", "--for", "condition=Available", "--timeout", "-1s")); err != nil {
120+
return fmt.Errorf("wait for CDI to be available: %s", err)
121+
}
122+
}
123+
104124
ipAddressManagerCRDOutput, err := getCommandOutput(exec.Command("kubectl", "get", "crd", "ippools.ipam.metal3.io", "--ignore-not-found"))
105125
if err != nil {
106126
return fmt.Errorf("get ip-address-manager CRDs: %s", err)

0 commit comments

Comments
 (0)