Skip to content

Commit

Permalink
AWS and GCP always use external CCM
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Sep 4, 2023
1 parent daf3d08 commit 9ced296
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 57 deletions.
4 changes: 0 additions & 4 deletions pkg/apis/kops/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ func validateClusterSpec(spec *kops.ClusterSpec, c *kops.Cluster, fieldPath *fie
allErrs = append(allErrs, validateKubeAPIServer(spec.KubeAPIServer, c, fieldPath.Child("kubeAPIServer"), strict)...)
}

if spec.ExternalCloudControllerManager == nil && spec.IsIPv6Only() {
allErrs = append(allErrs, field.Required(fieldPath.Child("cloudControllerManager"), "IPv6 requires external Cloud Controller Manager"))
}

if spec.KubeProxy != nil {
allErrs = append(allErrs, validateKubeProxy(spec.KubeProxy, fieldPath.Child("kubeProxy"))...)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/nodeup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func buildKubeProxy(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) *k
}

func UsesInstanceIDForNodeName(cluster *kops.Cluster) bool {
return cluster.Spec.ExternalCloudControllerManager != nil && cluster.Spec.GetCloudProvider() == kops.CloudProviderAWS
return cluster.Spec.GetCloudProvider() == kops.CloudProviderAWS
}

func filterFileAssets(f []kops.FileAssetSpec, role kops.InstanceGroupRole) []kops.FileAssetSpec {
Expand Down
4 changes: 0 additions & 4 deletions pkg/model/components/awscloudcontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ func (b *AWSCloudControllerManagerOptionsBuilder) BuildOptions(o interface{}) er

eccm := clusterSpec.ExternalCloudControllerManager

if eccm == nil {
return nil
}

// No significant downside to always doing a leader election.
// Also, having multiple control plane nodes requires leader election.
eccm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)}
Expand Down
4 changes: 0 additions & 4 deletions pkg/model/components/gcpcloudcontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ func (b *GCPCloudControllerManagerOptionsBuilder) BuildOptions(options interface

ccmConfig := clusterSpec.ExternalCloudControllerManager

if ccmConfig == nil {
return nil
}

// No significant downside to always doing a leader election.
// Also, having multiple control plane nodes requires leader election.
ccmConfig.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)}
Expand Down
8 changes: 0 additions & 8 deletions pkg/model/components/kubecontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
kcm.ClusterName = b.ClusterName
kcm.CloudProvider = "external"

if clusterSpec.ExternalCloudControllerManager == nil {
if kcm.CloudProvider == "aws" || kcm.CloudProvider == "gce" {
kcm.EnableLeaderMigration = fi.PtrTo(true)
}
} else {
kcm.CloudProvider = "external"
}

if kcm.LogLevel == 0 {
kcm.LogLevel = 2
}
Expand Down
32 changes: 1 addition & 31 deletions pkg/model/iam/iam_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,12 @@ func (r *NodeRoleMaster) BuildAWSPolicy(b *PolicyBuilder) (*Policy, error) {
// Protokube needs dns-controller permissions in instance role even if UseServiceAccountExternalPermissions.
AddDNSControllerPermissions(b, p)

// If cluster does not use external CCM, the master IAM Role needs CCM permissions
if b.Cluster.Spec.ExternalCloudControllerManager == nil {
AddCCMPermissions(p, b.Cluster.Spec.Networking.Kubenet != nil)
AddLegacyCCMPermissions(p)
}

if !b.UseServiceAccountExternalPermisssions {
esc := b.Cluster.Spec.SnapshotController != nil &&
fi.ValueOf(b.Cluster.Spec.SnapshotController.Enabled)
AddAWSEBSCSIDriverPermissions(p, esc)

if b.Cluster.Spec.ExternalCloudControllerManager != nil {
AddCCMPermissions(p, b.Cluster.Spec.Networking.Kubenet != nil)
}
AddCCMPermissions(p, b.Cluster.Spec.Networking.Kubenet != nil)

if c := b.Cluster.Spec.CloudProvider.AWS.LoadBalancerController; c != nil && fi.ValueOf(b.Cluster.Spec.CloudProvider.AWS.LoadBalancerController.Enabled) {
AddAWSLoadbalancerControllerPermissions(p, c.EnableWAF, c.EnableWAFv2, c.EnableShield)
Expand Down Expand Up @@ -826,28 +818,6 @@ func addEtcdManagerPermissions(p *Policy) {
)
}

func AddLegacyCCMPermissions(p *Policy) {
p.unconditionalAction.Insert(
"ec2:CreateSecurityGroup",
"ec2:CreateTags",
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:AddTags",
"elasticloadbalancing:RegisterTargets",
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:DeleteListener",
"elasticloadbalancing:ModifyListener",
"ec2:DescribeVolumes",
"ec2:ModifyInstanceAttribute",
"ec2:ModifyVolume",
"ec2:AttachVolume",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteRoute",
"ec2:DeleteSecurityGroup",
"ec2:DeleteVolume",
"ec2:DetachVolume",
)
}

func AddCCMPermissions(p *Policy, cloudRoutes bool) {
p.unconditionalAction.Insert(
"autoscaling:DescribeAutoScalingGroups",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext)
}

if b.Cluster.Spec.GetCloudProvider() == kops.CloudProviderGCE {
if b.Cluster.Spec.ExternalCloudControllerManager != nil {
{
key := "gcp-cloud-controller.addons.k8s.io"
useBuiltin := !b.hasExternalAddon(key)

Expand Down Expand Up @@ -1141,7 +1141,7 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext)

if b.Cluster.Spec.GetCloudProvider() == kops.CloudProviderAWS {

if b.Cluster.Spec.ExternalCloudControllerManager != nil {
{
key := "aws-cloud-controller.addons.k8s.io"

{
Expand Down
4 changes: 1 addition & 3 deletions upup/pkg/fi/cloudup/template_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,7 @@ func (tf *TemplateFunctions) KopsControllerConfig() (string, error) {
Region: tf.Region,
}

if cluster.Spec.ExternalCloudControllerManager != nil {
config.Server.UseInstanceIDForNodeName = true
}
config.Server.UseInstanceIDForNodeName = true

case kops.CloudProviderGCE:
c := tf.cloud.(gce.GCECloud)
Expand Down

0 comments on commit 9ced296

Please sign in to comment.