Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set flags on AWS CCM mimicking KCM #11566

Merged
merged 1 commit into from
May 23, 2021
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
1 change: 1 addition & 0 deletions pkg/model/components/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions pkg/model/components/awscloudcontrollermanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2021 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package components

import (
"fmt"

"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/loader"
)

// KubeControllerManagerOptionsBuilder adds options for the kubernetes controller manager to the model.
type AWSCloudControllerManagerOptionsBuilder struct {
*OptionsContext
}

var _ loader.OptionsBuilder = &AWSCloudControllerManagerOptionsBuilder{}

// BuildOptions generates the configurations used for the AWS cloud controller manager manifest
func (b *AWSCloudControllerManagerOptionsBuilder) BuildOptions(o interface{}) error {

clusterSpec := o.(*kops.ClusterSpec)

eccm := clusterSpec.ExternalCloudControllerManager

if eccm == nil || kops.CloudProviderID(eccm.CloudProvider) != kops.CloudProviderAWS {
return nil
}

eccm.ClusterName = b.ClusterName

eccm.ClusterCIDR = clusterSpec.NonMasqueradeCIDR

eccm.AllocateNodeCIDRs = fi.Bool(true)
eccm.ConfigureCloudRoutes = fi.Bool(false)

// TODO: we want to consolidate this with the logic from KCM
networking := clusterSpec.Networking
if networking == nil {
eccm.ConfigureCloudRoutes = fi.Bool(true)
} else if networking.Kubenet != nil {
eccm.ConfigureCloudRoutes = fi.Bool(true)
} else if networking.GCE != nil {
eccm.ConfigureCloudRoutes = fi.Bool(false)
eccm.CIDRAllocatorType = fi.String("CloudAllocator")

if eccm.ClusterCIDR == "" {
eccm.ClusterCIDR = clusterSpec.PodCIDR
}
} else if networking.External != nil {
eccm.ConfigureCloudRoutes = fi.Bool(false)
} else if UsesCNI(networking) {
eccm.ConfigureCloudRoutes = fi.Bool(false)
} else if networking.Kopeio != nil {
// Kopeio is based on kubenet / external
eccm.ConfigureCloudRoutes = fi.Bool(false)
} else {
return fmt.Errorf("no networking mode set")
}

eccm.Master = "https://127.0.0.1"

return nil
}
1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/populate_cluster_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func (c *populateClusterSpec) run(clientset simple.Clientset) error {
codeModels = append(codeModels, &components.ClusterAutoscalerOptionsBuilder{OptionsContext: optionsContext})
codeModels = append(codeModels, &components.NodeTerminationHandlerOptionsBuilder{OptionsContext: optionsContext})
codeModels = append(codeModels, &components.AWSEBSCSIDriverOptionsBuilder{OptionsContext: optionsContext})
codeModels = append(codeModels, &components.AWSCloudControllerManagerOptionsBuilder{OptionsContext: optionsContext})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ spec:
spec:
containers:
- args:
- --master=https://127.0.0.1
- --v=2
- --cloud-provider=aws
- --cluster-name=minimal.example.com
- --cluster-cidr=100.64.0.0/10
- --allocate-node-cidrs=true
- --configure-cloud-routes=false
- --use-service-account-credentials=true
image: gcr.io/k8s-staging-provider-aws/cloud-controller-manager:latest
name: aws-cloud-controller-manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:
- id: k8s-1.18
kubernetesVersion: '>=1.18.0'
manifest: aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml
manifestHash: c0a92fc15661776506a8861a5600315b930a599b
manifestHash: d1234040768f371ebb4a4e27cac699e215afb173
name: aws-cloud-controller.addons.k8s.io
selector:
k8s-addon: aws-cloud-controller.addons.k8s.io
Expand Down