Skip to content

Commit

Permalink
Remove code for disabling AWS EBS CSI driver
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Sep 4, 2023
1 parent 30becc0 commit 6379a60
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 28 deletions.
4 changes: 2 additions & 2 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ spec:
driver
properties:
enabled:
description: 'Enabled enables the AWS EBS CSI driver Default:
false'
description: 'Enabled enables the AWS EBS CSI driver. Can
only be set to true. Default: true'
type: boolean
managed:
description: Managed controls if aws-ebs-csi-driver is manged
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,9 @@ type CloudConfiguration struct {

// EBSCSIDriverSpec is the config for the AWS EBS CSI driver
type EBSCSIDriverSpec struct {
// Enabled enables the AWS EBS CSI driver
// Default: false
Enabled *bool `json:"enabled,omitempty"`
// Enabled enables the AWS EBS CSI driver. Can only be set to true.
// Default: true
Enabled *bool `json:"-"`

// Managed controls if aws-ebs-csi-driver is manged and deployed by kOps.
// The deployment of aws-ebs-csi-driver is skipped if this is set to false.
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,8 @@ type CloudConfiguration struct {

// EBSCSIDriverSpec is the config for the AWS EBS CSI driver
type EBSCSIDriverSpec struct {
// Enabled enables the AWS EBS CSI driver
// Default: false
// Enabled enables the AWS EBS CSI driver. Can only be set to true.
// Default: true
Enabled *bool `json:"enabled,omitempty"`

// Managed controls if aws-ebs-csi-driver is manged and deployed by kOps.
Expand Down
5 changes: 2 additions & 3 deletions pkg/apis/kops/v1alpha3/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,8 @@ type CloudConfiguration struct {

// EBSCSIDriverSpec is the config for the AWS EBS CSI driver
type EBSCSIDriverSpec struct {
// Enabled enables the AWS EBS CSI driver
// Default: false
Enabled *bool `json:"enabled,omitempty"`
// Enabled enables the AWS EBS CSI driver.
Enabled *bool `json:"-"`

// Managed controls if aws-ebs-csi-driver is manged and deployed by kOps.
// The deployment of aws-ebs-csi-driver is skipped if this is set to false.
Expand Down
11 changes: 4 additions & 7 deletions pkg/apis/kops/validation/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func awsValidateCluster(c *kops.Cluster, strict bool) field.ErrorList {
allErrs = append(allErrs, awsValidateLoadBalancerSubnets(lbPath.Child("subnets"), c.Spec)...)
}

allErrs = append(allErrs, awsValidateExternalCloudControllerManager(c)...)
allErrs = append(allErrs, awsValidateEBSCSIDriver(c)...)

if c.Spec.Authentication != nil && c.Spec.Authentication.AWS != nil {
allErrs = append(allErrs, awsValidateIAMAuthenticator(field.NewPath("spec", "authentication", "aws"), c.Spec.Authentication.AWS)...)
Expand All @@ -63,16 +63,13 @@ func awsValidateCluster(c *kops.Cluster, strict bool) field.ErrorList {
return allErrs
}

func awsValidateExternalCloudControllerManager(cluster *kops.Cluster) (allErrs field.ErrorList) {
func awsValidateEBSCSIDriver(cluster *kops.Cluster) (allErrs field.ErrorList) {
c := cluster.Spec

if c.ExternalCloudControllerManager == nil {
return allErrs
}
fldPath := field.NewPath("spec", "externalCloudControllerManager")
fldPath := field.NewPath("spec", "cloudProvider", "aws", "ebsCSIDriver", "enabled")
if !hasAWSEBSCSIDriver(c) {
allErrs = append(allErrs, field.Forbidden(fldPath,
"AWS external CCM cannot be used without enabling spec.cloudProvider.aws.ebsCSIDriverSpec."))
"must not be disabled"))
}
return allErrs
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/kops/validation/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestAWSValidateExternalCloudConfig(t *testing.T) {
cluster := &kops.Cluster{
Spec: g.Input,
}
errs := awsValidateExternalCloudControllerManager(cluster)
errs := awsValidateEBSCSIDriver(cluster)

testErrors(t, g.Input, errs, g.ExpectedErrors)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/components/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(o interface{}) error {
c.FeatureGates = make(map[string]string)
}

if clusterSpec.CloudProvider.AWS != nil && clusterSpec.CloudProvider.AWS.EBSCSIDriver != nil && fi.ValueOf(clusterSpec.CloudProvider.AWS.EBSCSIDriver.Enabled) {
if clusterSpec.CloudProvider.AWS != nil {

if _, found := c.FeatureGates["InTreePluginAWSUnregister"]; !found {
c.FeatureGates["InTreePluginAWSUnregister"] = "true"
Expand Down
4 changes: 0 additions & 4 deletions pkg/model/components/awsebscsidriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ func (b *AWSEBSCSIDriverOptionsBuilder) BuildOptions(o interface{}) error {
}
c := aws.EBSCSIDriver

if !fi.ValueOf(c.Enabled) {
return nil
}

if c.Version == nil {
version := "v1.14.1"
c.Version = &version
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/components/kubecontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
}
}

if clusterSpec.CloudProvider.AWS != nil && clusterSpec.CloudProvider.AWS.EBSCSIDriver != nil && fi.ValueOf(clusterSpec.CloudProvider.AWS.EBSCSIDriver.Enabled) {
if clusterSpec.CloudProvider.AWS != nil {

if kcm.FeatureGates == nil {
kcm.FeatureGates = make(map[string]string)
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/components/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error {
clusterSpec.Kubelet.FeatureGates = make(map[string]string)
}

if clusterSpec.CloudProvider.AWS != nil && clusterSpec.CloudProvider.AWS.EBSCSIDriver != nil && fi.ValueOf(clusterSpec.CloudProvider.AWS.EBSCSIDriver.Enabled) {
if clusterSpec.CloudProvider.AWS != nil {
if _, found := clusterSpec.Kubelet.FeatureGates["CSIMigrationAWS"]; !found && b.IsKubernetesLT("1.27") {
clusterSpec.Kubelet.FeatureGates["CSIMigrationAWS"] = "true"
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/components/kubescheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (b *KubeSchedulerOptionsBuilder) BuildOptions(o interface{}) error {
}
}

if clusterSpec.CloudProvider.AWS != nil && clusterSpec.CloudProvider.AWS.EBSCSIDriver != nil && fi.ValueOf(clusterSpec.CloudProvider.AWS.EBSCSIDriver.Enabled) {
if clusterSpec.CloudProvider.AWS != nil {

if config.FeatureGates == nil {
config.FeatureGates = make(map[string]string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,7 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext)
serviceAccountRoles = append(serviceAccountRoles, &awscloudcontrollermanager.ServiceAccount{})
}
}
if b.Cluster.Spec.CloudProvider.AWS != nil && b.Cluster.Spec.CloudProvider.AWS.EBSCSIDriver != nil &&
fi.ValueOf(b.Cluster.Spec.CloudProvider.AWS.EBSCSIDriver.Enabled) &&
if b.Cluster.Spec.CloudProvider.AWS != nil &&
(b.Cluster.Spec.CloudProvider.AWS.EBSCSIDriver.Managed == nil || fi.ValueOf(b.Cluster.Spec.CloudProvider.AWS.EBSCSIDriver.Managed)) {
key := "aws-ebs-csi-driver.addons.k8s.io"

Expand Down

0 comments on commit 6379a60

Please sign in to comment.