diff --git a/pkg/oci/ccm.go b/pkg/oci/ccm.go index 84b5cfa5ba..833ead4019 100644 --- a/pkg/oci/ccm.go +++ b/pkg/oci/ccm.go @@ -87,7 +87,7 @@ func NewCloudProvider(config *Config) (cloudprovider.Interface, error) { config.CompartmentID = metadata.CompartmentOCID } - if config.VCNID == "" { + if !config.LoadBalancer.Disabled && config.VCNID == "" { glog.Infof("No vcn provided in cloud provider config. Falling back to looking up VCN via LB subnet.") subnet, err := c.Networking().GetSubnet(context.Background(), config.LoadBalancer.Subnet1) if err != nil { @@ -136,17 +136,19 @@ func (cp *CloudProvider) Initialize(clientBuilder controller.ControllerClientBui } cp.NodeLister = nodeInformer.Lister() - var serviceInformer informersv1.ServiceInformer - if cp.config.LoadBalancer.SecurityListManagementMode != ManagementModeNone { - serviceInformer = factory.Core().V1().Services() - go serviceInformer.Informer().Run(wait.NeverStop) - glog.Info("Waiting for service informer cache to sync") - if !cache.WaitForCacheSync(wait.NeverStop, serviceInformer.Informer().HasSynced) { - utilruntime.HandleError(fmt.Errorf("Timed out waiting for service informer to sync")) - } + if !cp.config.LoadBalancer.Disabled { + var serviceInformer informersv1.ServiceInformer + if cp.config.LoadBalancer.SecurityListManagementMode != ManagementModeNone { + serviceInformer = factory.Core().V1().Services() + go serviceInformer.Informer().Run(wait.NeverStop) + glog.Info("Waiting for service informer cache to sync") + if !cache.WaitForCacheSync(wait.NeverStop, serviceInformer.Informer().HasSynced) { + utilruntime.HandleError(fmt.Errorf("Timed out waiting for service informer to sync")) + } + } + cp.securityListManager = newSecurityListManager(cp.client, serviceInformer.Lister(), cp.config.LoadBalancer.SecurityLists, cp.config.LoadBalancer.SecurityListManagementMode) } - cp.securityListManager = newSecurityListManager(cp.client, serviceInformer.Lister(), cp.config.LoadBalancer.SecurityLists, cp.config.LoadBalancer.SecurityListManagementMode) } // ProviderName returns the cloud-provider ID. @@ -158,7 +160,7 @@ func (cp *CloudProvider) ProviderName() string { // is supported, false otherwise. func (cp *CloudProvider) LoadBalancer() (cloudprovider.LoadBalancer, bool) { glog.V(6).Info("Claiming to support Load Balancers") - return cp, true + return cp, !cp.config.LoadBalancer.Disabled } // Instances returns an instances interface. Also returns true if the interface diff --git a/pkg/oci/config.go b/pkg/oci/config.go index edc1290dd5..41e69517da 100644 --- a/pkg/oci/config.go +++ b/pkg/oci/config.go @@ -42,6 +42,9 @@ type AuthConfig struct { // LoadBalancerConfig holds the configuration options for OCI load balancers. type LoadBalancerConfig struct { + // Disabled disables the creation of a load balancer. + Disabled bool `yaml:"disabled"` + // DisableSecurityListManagement disables the automatic creation of ingress // rules for the node subnets and egress rules for the load balancers to the node subnets. // @@ -80,7 +83,7 @@ type Config struct { // Complete the config applying defaults / overrides. func (c *Config) Complete() { - if c.LoadBalancer.SecurityListManagementMode == "" { + if !c.LoadBalancer.Disabled && c.LoadBalancer.SecurityListManagementMode == "" { c.LoadBalancer.SecurityListManagementMode = ManagementModeAll // default if c.LoadBalancer.DisableSecurityListManagement { glog.Warningf("cloud-provider config: \"loadBalancer.disableSecurityListManagement\" is DEPRECIATED and will be removed in a later release. Please set \"loadBalancer.SecurityListManagementMode: %s\".", ManagementModeNone) diff --git a/pkg/oci/config_validate.go b/pkg/oci/config_validate.go index 9e4f3ac618..4903b444d4 100644 --- a/pkg/oci/config_validate.go +++ b/pkg/oci/config_validate.go @@ -83,6 +83,8 @@ func validateLoadBalancerConfig(c *Config, fldPath *field.Path) field.ErrorList func ValidateConfig(c *Config) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, validateAuthConfig(&c.Auth, field.NewPath("auth"))...) - allErrs = append(allErrs, validateLoadBalancerConfig(c, field.NewPath("loadBalancer"))...) + if !c.LoadBalancer.Disabled { + allErrs = append(allErrs, validateLoadBalancerConfig(c, field.NewPath("loadBalancer"))...) + } return allErrs }