Skip to content

Commit

Permalink
Merge pull request #7770 from mitch000001/external-cloud-controller-f…
Browse files Browse the repository at this point in the history
…eature-flag

Guard External cloud controller manager with its feature flag
  • Loading branch information
k8s-ci-robot authored Dec 26, 2019
2 parents e558059 + 92ffa79 commit dd608e8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/kops/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/kops/cmd/kops/util"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/v1alpha1"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/pkg/kopscodecs"
"k8s.io/kops/upup/pkg/fi/cloudup"
"k8s.io/kops/util/pkg/text"
Expand Down Expand Up @@ -147,6 +148,9 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {

switch v := o.(type) {
case *kopsapi.Cluster:
if v.Spec.ExternalCloudControllerManager != nil && !featureflag.EnableExternalCloudController.Enabled() {
klog.Warningf("Without setting the feature flag `+EnableExternalCloudController` the external cloud controller manager configuration will be discarded")
}
// Adding a PerformAssignments() call here as the user might be trying to use
// the new `-f` feature, with an old cluster definition.
err = cloudup.PerformAssignments(v)
Expand Down
4 changes: 4 additions & 0 deletions cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,10 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e
return fmt.Errorf("error populating configuration: %v", err)
}

if cluster.Spec.ExternalCloudControllerManager != nil && !featureflag.EnableExternalCloudController.Enabled() {
klog.Warningf("Without setting the feature flag `+EnableExternalCloudController` the external cloud controller manager configuration will be discarded")
}

strict := false
err = validation.DeepValidate(cluster, instanceGroups, strict)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/kops/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/kops/cmd/kops/util"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/commands"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/pkg/kopscodecs"
"k8s.io/kops/util/pkg/text"
"k8s.io/kops/util/pkg/vfs"
Expand Down Expand Up @@ -117,6 +118,9 @@ func RunReplace(f *util.Factory, cmd *cobra.Command, out io.Writer, c *replaceOp
switch v := o.(type) {
case *kopsapi.Cluster:
{
if v.Spec.ExternalCloudControllerManager != nil && !featureflag.EnableExternalCloudController.Enabled() {
klog.Warningf("Without setting the feature flag `+EnableExternalCloudController` the external cloud controller manager configuration will be discarded")
}
// Retrieve the current status of the cluster. This will eventually be part of the cluster object.
statusDiscovery := &commands.CloudDiscoveryStatusStore{}
status, err := statusDiscovery.FindClusterStatus(v)
Expand Down
1 change: 1 addition & 0 deletions pkg/model/components/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go_library(
"//pkg/apis/kops:go_default_library",
"//pkg/apis/kops/util:go_default_library",
"//pkg/assets:go_default_library",
"//pkg/featureflag:go_default_library",
"//pkg/k8sversion:go_default_library",
"//upup/pkg/fi:go_default_library",
"//upup/pkg/fi/cloudup/gce:go_default_library",
Expand Down
3 changes: 2 additions & 1 deletion pkg/model/components/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

v1 "k8s.io/api/core/v1"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/loader"

Expand Down Expand Up @@ -167,7 +168,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(o interface{}) error {
return fmt.Errorf("unknown cloudprovider %q", clusterSpec.CloudProvider)
}

if clusterSpec.ExternalCloudControllerManager != nil {
if featureflag.EnableExternalCloudController.Enabled() && clusterSpec.ExternalCloudControllerManager != nil {
c.CloudProvider = "external"
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/model/components/kubecontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/klog"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/util"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup/gce"
"k8s.io/kops/upup/pkg/fi/loader"
Expand Down Expand Up @@ -123,7 +124,7 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
return fmt.Errorf("unknown cloudprovider %q", clusterSpec.CloudProvider)
}

if clusterSpec.ExternalCloudControllerManager != nil {
if featureflag.EnableExternalCloudController.Enabled() && clusterSpec.ExternalCloudControllerManager != nil {
kcm.CloudProvider = "external"
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/model/components/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"k8s.io/klog"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/loader"
)
Expand Down Expand Up @@ -216,7 +217,7 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error {
clusterSpec.Kubelet.HostnameOverride = "@alicloud"
}

if clusterSpec.ExternalCloudControllerManager != nil {
if featureflag.EnableExternalCloudController.Enabled() && clusterSpec.ExternalCloudControllerManager != nil {
clusterSpec.Kubelet.CloudProvider = "external"
}

Expand Down

0 comments on commit dd608e8

Please sign in to comment.