@@ -20,10 +20,26 @@ import (
2020 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/lifecycle/cni"
2121 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/lifecycle/config"
2222 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options"
23+ capiutils "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/utils"
2324)
2425
26+ type helmAddonConfig struct {
27+ defaultValuesTemplateConfigMapName string
28+ }
29+
30+ func (c * helmAddonConfig ) AddFlags (prefix string , flags * pflag.FlagSet ) {
31+ flags .StringVar (
32+ & c .defaultValuesTemplateConfigMapName ,
33+ prefix + ".default-values-template-configmap-name" ,
34+ "default-multus-values-template" ,
35+ "default values ConfigMap name" ,
36+ )
37+ }
38+
2539type MultusConfig struct {
2640 * options.GlobalOptions
41+
42+ helmAddonConfig helmAddonConfig
2743}
2844
2945func NewMultusConfig (globalOptions * options.GlobalOptions ) * MultusConfig {
@@ -33,7 +49,7 @@ func NewMultusConfig(globalOptions *options.GlobalOptions) *MultusConfig {
3349}
3450
3551func (m * MultusConfig ) AddFlags (prefix string , flags * pflag.FlagSet ) {
36- // No flags needed for Multus - it's auto-deployed
52+ m . helmAddonConfig . AddFlags ( prefix + ".helm-addon" , flags )
3753}
3854
3955type MultusHandler struct {
@@ -99,16 +115,15 @@ func (m *MultusHandler) apply(
99115 )
100116
101117 // Check if Multus is supported for this cloud provider
102- isSupported , providerName := isCloudProviderSupported (cluster )
103-
104- if ! isSupported {
118+ provider := capiutils .GetProvider (cluster )
119+ if provider != "eks" && provider != "nutanix" {
105120 log .V (5 ).Info (
106121 "Multus is not supported for this cloud provider. Skipping Multus deployment." ,
107122 )
108123 return
109124 }
110125
111- log .Info (fmt .Sprintf ("Cluster is %s. Checking CNI configuration for Multus deployment." , providerName ))
126+ log .Info (fmt .Sprintf ("Cluster is %s. Checking CNI configuration for Multus deployment." , provider ))
112127
113128 // Read CNI configuration to detect which CNI is deployed
114129 varMap := variables .ClusterVariablesToVariablesMap (cluster .Spec .Topology .Variables )
@@ -128,15 +143,15 @@ func (m *MultusHandler) apply(
128143 return
129144 }
130145
131- // Get readiness socket path for the CNI provider
132- readinessSocketPath , err := cni .ReadinessSocketPath (cniVar .Provider )
146+ // Get socket path for the CNI provider
147+ socketPath , err := cni .SocketPath (cniVar .Provider )
133148 if err != nil {
134149 log .V (5 ).
135150 Info (fmt .Sprintf ("Multus does not support CNI provider: %s. Skipping Multus deployment." , cniVar .Provider ))
136151 return
137152 }
138153
139- log .Info (fmt .Sprintf ("Auto-deploying Multus for %s cluster with %s CNI" , providerName , cniVar .Provider ))
154+ log .Info (fmt .Sprintf ("Auto-deploying Multus for %s cluster with %s CNI" , provider , cniVar .Provider ))
140155
141156 // Get helm chart configuration
142157 helmChart , err := m .helmChartInfoGetter .For (ctx , log , config .Multus )
@@ -156,9 +171,9 @@ func (m *MultusHandler) apply(
156171
157172 // Create and apply helm addon strategy
158173 targetNamespace := m .config .DefaultsNamespace ()
159- strategy := newHelmAddonStrategy (m .client , helmChart )
174+ strategy := newHelmAddonStrategy (m .client , helmChart , m . config . helmAddonConfig )
160175
161- if err := strategy .apply (ctx , cluster , readinessSocketPath , targetNamespace , log ); err != nil {
176+ if err := strategy .apply (ctx , cluster , socketPath , targetNamespace , log ); err != nil {
162177 log .Error (err , "failed to deploy Multus" )
163178 resp .SetStatus (runtimehooksv1 .ResponseStatusFailure )
164179 resp .SetMessage (fmt .Sprintf ("failed to deploy Multus: %v" , err ))
0 commit comments