Commit d963cb2f authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Disable cloud-node and cloud-node-lifecycle if CCM is disabled

If CCM and ServiceLB are both disabled, don't run the cloud-controller-manager at all; this should provide the same CLI flag behavior as previous releases, and not create problems when users disable the CCM but still want ServiceLB. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 0b96ca92
...@@ -362,7 +362,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont ...@@ -362,7 +362,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
serverConfig.ControlConfig.DisableServiceLB = true serverConfig.ControlConfig.DisableServiceLB = true
} }
if serverConfig.ControlConfig.DisableCCM { if serverConfig.ControlConfig.DisableCCM && serverConfig.ControlConfig.DisableServiceLB {
serverConfig.ControlConfig.Skips["ccm"] = true serverConfig.ControlConfig.Skips["ccm"] = true
serverConfig.ControlConfig.Disables["ccm"] = true serverConfig.ControlConfig.Disables["ccm"] = true
} }
......
...@@ -2,6 +2,7 @@ package cloudprovider ...@@ -2,6 +2,7 @@ package cloudprovider
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
...@@ -29,6 +30,7 @@ type Config struct { ...@@ -29,6 +30,7 @@ type Config struct {
LBEnabled bool `json:"lbEnabled"` LBEnabled bool `json:"lbEnabled"`
LBImage string `json:"lbImage"` LBImage string `json:"lbImage"`
LBNamespace string `json:"lbNamespace"` LBNamespace string `json:"lbNamespace"`
NodeEnabled bool `json:"nodeEnabled"`
Rootless bool `json:"rootless"` Rootless bool `json:"rootless"`
} }
...@@ -55,6 +57,7 @@ func init() { ...@@ -55,6 +57,7 @@ func init() {
LBEnabled: true, LBEnabled: true,
LBImage: DefaultLBImage, LBImage: DefaultLBImage,
LBNamespace: DefaultLBNS, LBNamespace: DefaultLBNS,
NodeEnabled: true,
}, },
} }
...@@ -66,6 +69,10 @@ func init() { ...@@ -66,6 +69,10 @@ func init() {
} }
} }
if !k.LBEnabled && !k.NodeEnabled {
return nil, fmt.Errorf("all cloud-provider functionality disabled by config")
}
return &k, err return &k, err
}) })
} }
...@@ -114,7 +121,7 @@ func (k *k3s) Instances() (cloudprovider.Instances, bool) { ...@@ -114,7 +121,7 @@ func (k *k3s) Instances() (cloudprovider.Instances, bool) {
} }
func (k *k3s) InstancesV2() (cloudprovider.InstancesV2, bool) { func (k *k3s) InstancesV2() (cloudprovider.InstancesV2, bool) {
return k, true return k, k.NodeEnabled
} }
func (k *k3s) LoadBalancer() (cloudprovider.LoadBalancer, bool) { func (k *k3s) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
......
...@@ -777,6 +777,7 @@ func genCloudConfig(controlConfig *config.Control) error { ...@@ -777,6 +777,7 @@ func genCloudConfig(controlConfig *config.Control) error {
LBNamespace: controlConfig.ServiceLBNamespace, LBNamespace: controlConfig.ServiceLBNamespace,
LBImage: cloudprovider.DefaultLBImage, LBImage: cloudprovider.DefaultLBImage,
Rootless: controlConfig.Rootless, Rootless: controlConfig.Rootless,
NodeEnabled: !controlConfig.DisableCCM,
} }
if controlConfig.SystemDefaultRegistry != "" { if controlConfig.SystemDefaultRegistry != "" {
cloudConfig.LBImage = controlConfig.SystemDefaultRegistry + "/" + cloudConfig.LBImage cloudConfig.LBImage = controlConfig.SystemDefaultRegistry + "/" + cloudConfig.LBImage
......
...@@ -81,7 +81,7 @@ func Server(ctx context.Context, cfg *config.Control) error { ...@@ -81,7 +81,7 @@ func Server(ctx context.Context, cfg *config.Control) error {
} }
} }
if !cfg.DisableCCM { if !cfg.DisableCCM || !cfg.DisableServiceLB {
if err := cloudControllerManager(ctx, cfg); err != nil { if err := cloudControllerManager(ctx, cfg); err != nil {
return err return err
} }
...@@ -301,10 +301,12 @@ func cloudControllerManager(ctx context.Context, cfg *config.Control) error { ...@@ -301,10 +301,12 @@ func cloudControllerManager(ctx context.Context, cfg *config.Control) error {
argsMap := map[string]string{ argsMap := map[string]string{
"profiling": "false", "profiling": "false",
"allocate-node-cidrs": "true", "allocate-node-cidrs": "true",
"leader-elect-resource-name": version.Program + "-cloud-controller-manager",
"cloud-provider": version.Program, "cloud-provider": version.Program,
"cloud-config": runtime.CloudControllerConfig, "cloud-config": runtime.CloudControllerConfig,
"cluster-cidr": util.JoinIPNets(cfg.ClusterIPRanges), "cluster-cidr": util.JoinIPNets(cfg.ClusterIPRanges),
"configure-cloud-routes": "false", "configure-cloud-routes": "false",
"controllers": "*,-route",
"kubeconfig": runtime.KubeConfigCloudController, "kubeconfig": runtime.KubeConfigCloudController,
"authorization-kubeconfig": runtime.KubeConfigCloudController, "authorization-kubeconfig": runtime.KubeConfigCloudController,
"authentication-kubeconfig": runtime.KubeConfigCloudController, "authentication-kubeconfig": runtime.KubeConfigCloudController,
...@@ -314,6 +316,12 @@ func cloudControllerManager(ctx context.Context, cfg *config.Control) error { ...@@ -314,6 +316,12 @@ func cloudControllerManager(ctx context.Context, cfg *config.Control) error {
if cfg.NoLeaderElect { if cfg.NoLeaderElect {
argsMap["leader-elect"] = "false" argsMap["leader-elect"] = "false"
} }
if cfg.DisableCCM {
argsMap["controllers"] = argsMap["controllers"] + ",-cloud-node,-cloud-node-lifecycle"
}
if cfg.DisableServiceLB {
argsMap["controllers"] = argsMap["controllers"] + ",-service"
}
args := config.GetArgs(argsMap, cfg.ExtraCloudControllerArgs) args := config.GetArgs(argsMap, cfg.ExtraCloudControllerArgs)
logrus.Infof("Running cloud-controller-manager %s", config.ArgString(args)) logrus.Infof("Running cloud-controller-manager %s", config.ArgString(args))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment