Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions pkg/oci/ccm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pkg/oci/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion pkg/oci/config_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}