44 "fmt"
55 "os/exec"
66 "strings"
7- "time"
87
98 . "github.com/onsi/gomega"
109
@@ -26,19 +25,16 @@ func NewUmbrellaHelmHelper(releaseName, namespace, apiURL string) *UmbrellaHelmH
2625}
2726
2827func (h * UmbrellaHelmHelper ) InstallKentMode (apiKey string ) error {
28+ // preflight checks for Karpenter deployment + CRDs which don't exist on Kind.
29+ // castai-aws-vpc-cni runs a pre-install hook that patches the aws-node daemonset,
30+ // which also doesn't exist on Kind.
2931 cmd := exec .Command ("helm" , "upgrade" , "--install" , h .releaseName ,
3032 chartPath ,
3133 "--namespace" , h .namespace ,
3234 "--create-namespace" ,
3335 "--set" , "kent.enabled=true" ,
34- "--set" , "kent.castai-agent.enabled=true" ,
35- "--set" , "kent.castai-kentroller.enabled=true" ,
36- "--set" , "kent.castai-cluster-controller.enabled=true" ,
37- "--set" , "kent.castai-evictor.enabled=true" ,
38- "--set" , "kent.castai-live.enabled=false" ,
39- "--set" , "kent.castai-pod-mutator.enabled=false" ,
40- "--set" , "kent.castai-workload-autoscaler.enabled=false" ,
41- "--set" , "kent.metrics-server.enabled=false" ,
36+ "--set" , "kent.preflight.enabled=false" ,
37+ "--set" , "kent.castai-live.castai-aws-vpc-cni.enabled=false" ,
4238 "--set" , fmt .Sprintf ("global.castai.apiKey=%s" , apiKey ),
4339 "--set" , fmt .Sprintf ("global.castai.apiURL=%s" , h .apiURL ),
4440 "--timeout" , defaultHelmTimeout ,
@@ -50,19 +46,74 @@ func (h *UmbrellaHelmHelper) InstallKentMode(apiKey string) error {
5046 return nil
5147}
5248
49+ func (h * UmbrellaHelmHelper ) InstallAutoscalerReadonlyMode (apiKey , provider string ) error {
50+ // readonly tag activates: castai-agent, castai-spot-handler, castai-kvisor, gpu-metrics-exporter.
51+ cmd := exec .Command ("helm" , "upgrade" , "--install" , h .releaseName ,
52+ chartPath ,
53+ "--namespace" , h .namespace ,
54+ "--create-namespace" ,
55+ "--set" , "tags.readonly=true" ,
56+ "--set" , fmt .Sprintf ("global.castai.apiKey=%s" , apiKey ),
57+ "--set" , fmt .Sprintf ("global.castai.apiURL=%s" , h .apiURL ),
58+ "--set" , fmt .Sprintf ("global.castai.provider=%s" , provider ),
59+ "--timeout" , defaultHelmTimeout ,
60+ )
61+ _ , err := utils .Run (cmd )
62+ if err != nil {
63+ return fmt .Errorf ("helm install autoscaler readonly mode failed: %w" , err )
64+ }
65+ return nil
66+ }
67+
68+ func (h * UmbrellaHelmHelper ) UpgradeToFullMode () error {
69+ // Swap readonly tag for full. --reuse-values preserves apiKey/apiURL/provider.
70+ // readonly → full is not an additive path so both tags must be set explicitly.
71+ cmd := exec .Command ("helm" , "upgrade" , h .releaseName ,
72+ chartPath ,
73+ "--namespace" , h .namespace ,
74+ "--reuse-values" ,
75+ "--set" , "tags.readonly=false" ,
76+ "--set" , "tags.full=true" ,
77+ "--timeout" , defaultHelmTimeout ,
78+ )
79+ _ , err := utils .Run (cmd )
80+ if err != nil {
81+ return fmt .Errorf ("helm upgrade to full mode failed: %w" , err )
82+ }
83+ return nil
84+ }
85+
86+ func (h * UmbrellaHelmHelper ) InstallAutoscalerWorkloadMode (apiKey , provider string ) error {
87+ // workload-autoscaler tag activates: castai-agent, castai-spot-handler, castai-kvisor,
88+ // gpu-metrics-exporter, castai-cluster-controller, castai-evictor, castai-pod-mutator,
89+ // castai-workload-autoscaler, castai-workload-autoscaler-exporter.
90+ // NOT included: castai-pod-pinner, castai-live (those are node-autoscaler + full only).
91+ cmd := exec .Command ("helm" , "upgrade" , "--install" , h .releaseName ,
92+ chartPath ,
93+ "--namespace" , h .namespace ,
94+ "--create-namespace" ,
95+ "--set" , "tags.workload-autoscaler=true" ,
96+ "--set" , fmt .Sprintf ("global.castai.apiKey=%s" , apiKey ),
97+ "--set" , fmt .Sprintf ("global.castai.apiURL=%s" , h .apiURL ),
98+ "--set" , fmt .Sprintf ("global.castai.provider=%s" , provider ),
99+ "--timeout" , defaultHelmTimeout ,
100+ )
101+ _ , err := utils .Run (cmd )
102+ if err != nil {
103+ return fmt .Errorf ("helm install autoscaler workload mode failed: %w" , err )
104+ }
105+ return nil
106+ }
107+
53108func (h * UmbrellaHelmHelper ) InstallAutoscalerMode (apiKey , provider string ) error {
109+ // node-autoscaler tag activates: castai-agent, castai-spot-handler, castai-kvisor,
110+ // gpu-metrics-exporter, castai-cluster-controller, castai-evictor, castai-pod-mutator,
111+ // castai-pod-pinner, castai-live (see autoscaler/Chart.yaml tag definitions).
54112 cmd := exec .Command ("helm" , "upgrade" , "--install" , h .releaseName ,
55113 chartPath ,
56114 "--namespace" , h .namespace ,
57115 "--create-namespace" ,
58- "--set" , "autoscaler.enabled=true" ,
59- "--set" , "autoscaler.castai-agent.enabled=true" ,
60- "--set" , "autoscaler.castai-cluster-controller.enabled=true" ,
61- "--set" , "autoscaler.castai-evictor.enabled=true" ,
62- "--set" , "autoscaler.castai-live.enabled=false" ,
63- "--set" , "autoscaler.castai-pod-mutator.enabled=false" ,
64- "--set" , "autoscaler.castai-workload-autoscaler.enabled=false" ,
65- "--set" , "autoscaler.castai-kvisor.enabled=true" ,
116+ "--set" , "tags.node-autoscaler=true" ,
66117 "--set" , fmt .Sprintf ("global.castai.apiKey=%s" , apiKey ),
67118 "--set" , fmt .Sprintf ("global.castai.apiURL=%s" , h .apiURL ),
68119 "--set" , fmt .Sprintf ("global.castai.provider=%s" , provider ),
@@ -76,17 +127,14 @@ func (h *UmbrellaHelmHelper) InstallAutoscalerMode(apiKey, provider string) erro
76127}
77128
78129func (h * UmbrellaHelmHelper ) InstallAutoscalerAnywhereMode (apiKey , clusterName string ) error {
130+ // tags.autoscaler-anywhere includes the autoscaler-anywhere sub-chart.
131+ // Components within that sub-chart are enabled by default in its values.yaml;
132+ // ANYWHERE_CLUSTER_NAME is passed via additionalEnv so the agent can register.
79133 cmd := exec .Command ("helm" , "upgrade" , "--install" , h .releaseName ,
80134 chartPath ,
81135 "--namespace" , h .namespace ,
82136 "--create-namespace" ,
83- "--set" , "autoscaler-anywhere.enabled=true" ,
84- "--set" , "autoscaler-anywhere.castai-agent.enabled=true" ,
85- "--set" , "autoscaler-anywhere.castai-cluster-controller.enabled=true" ,
86- "--set" , "autoscaler-anywhere.castai-evictor.enabled=true" ,
87- "--set" , "autoscaler-anywhere.castai-pod-mutator.enabled=true" ,
88- "--set" , "autoscaler-anywhere.castai-workload-autoscaler.enabled=false" ,
89- "--set" , "autoscaler-anywhere.castai-workload-autoscaler-exporter.enabled=false" ,
137+ "--set" , "tags.autoscaler-anywhere=true" ,
90138 "--set" , fmt .Sprintf ("autoscaler-anywhere.castai-agent.additionalEnv.ANYWHERE_CLUSTER_NAME=%s" , clusterName ),
91139 "--set" , fmt .Sprintf ("global.castai.apiKey=%s" , apiKey ),
92140 "--set" , fmt .Sprintf ("global.castai.apiURL=%s" , h .apiURL ),
@@ -120,9 +168,13 @@ func (h *UmbrellaHelmHelper) InstallAutoscalerOpenshiftMode(apiKey string) error
120168}
121169
122170func (h * UmbrellaHelmHelper ) Uninstall () error {
171+ // --no-hooks skips pre/post-delete hooks (e.g. webhook teardown calls) that
172+ // block when pods are unhealthy. The namespace and Kind cluster are deleted
173+ // immediately after, so hook-managed resources are cleaned up anyway.
123174 cmd := exec .Command ("helm" , "uninstall" , h .releaseName ,
124175 "--namespace" , h .namespace ,
125176 "--ignore-not-found" ,
177+ "--no-hooks" ,
126178 "--timeout" , defaultHelmTimeout ,
127179 )
128180 _ , err := utils .Run (cmd )
@@ -236,12 +288,6 @@ func (n *NamespaceHelper) VerifyExists(g Gomega, namespace string) {
236288 g .Expect (err ).NotTo (HaveOccurred (), fmt .Sprintf ("Namespace %s should exist" , namespace ))
237289}
238290
239- func waitForDeployment (podHelper * PodHelper , name string , timeout time.Duration ) {
240- Eventually (func (g Gomega ) {
241- podHelper .VerifyDeploymentExists (g , name )
242- }, timeout , 5 * time .Second ).Should (Succeed ())
243- }
244-
245291// VerifyAtLeastOnePodReady checks that the named deployment has at least one
246292// available replica according to the deployment status — no label guessing needed.
247293func (p * PodHelper ) VerifyAtLeastOnePodReady (g Gomega , deploymentName string ) {
0 commit comments