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

AWS CSI driver #10467

Merged
merged 1 commit into from
Jan 12, 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
8 changes: 8 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ spec:
cloudConfig:
description: CloudConfiguration defines the cloud provider configuration
properties:
awsEBSCSIDriver:
rifelpet marked this conversation as resolved.
Show resolved Hide resolved
description: AWSEBSCSIDriver is the config for the AWS EBS CSI
driver
properties:
enabled:
description: Enabled enables the AWS EBS CSI driver
type: boolean
type: object
azure:
description: Azure cloud-config options
properties:
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,14 @@ type CloudConfiguration struct {
Openstack *OpenstackConfiguration `json:"openstack,omitempty"`
// Azure cloud-config options
Azure *AzureConfiguration `json:"azure,omitempty"`
// AWSEBSCSIDriver is the config for the AWS EBS CSI driver
AWSEBSCSIDriver *AWSEBSCSIDriver `json:"awsEBSCSIDriver,omitempty"`
}

// AWSEBSCSIDriver is the config for the AWS EBS CSI driver
type AWSEBSCSIDriver struct {
//Enabled enables the AWS EBS CSI driver
Enabled *bool `json:"enabled,omitempty"`
}

// NodeTerminationHandlerConfig determines the node termination handler configuration.
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,14 @@ type CloudConfiguration struct {
Openstack *OpenstackConfiguration `json:"openstack,omitempty"`
// Azure cloud-config options
Azure *AzureConfiguration `json:"azure,omitempty"`
// AWSEBSCSIDriver is the config for the AWS EBS CSI driver
AWSEBSCSIDriver *AWSEBSCSIDriver `json:"awsEBSCSIDriver,omitempty"`
}

// AWSEBSCSIDriver is the config for the AWS EBS CSI driver
type AWSEBSCSIDriver struct {
//Enabled enables the AWS EBS CSI driver
Enabled *bool `json:"enabled,omitempty"`
}

// NodeTerminationHandlerConfig determines the node termination handler configuration.
Expand Down
48 changes: 48 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

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

26 changes: 26 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

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

16 changes: 16 additions & 0 deletions pkg/apis/kops/validation/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,25 @@ func awsValidateCluster(c *kops.Cluster) field.ErrorList {
}
}

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

return allErrs
}

func awsValidateExternalCloudControllerManager(c kops.ClusterSpec) (allErrs field.ErrorList) {

if c.ExternalCloudControllerManager != nil {
if c.KubeControllerManager == nil || c.KubeControllerManager.ExternalCloudVolumePlugin != "aws" {
if c.CloudConfig == nil || c.CloudConfig.AWSEBSCSIDriver == nil || !fi.BoolValue(c.CloudConfig.AWSEBSCSIDriver.Enabled) {
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "externalCloudControllerManager"),
"AWS external CCM cannot be used without enabling spec.cloudConfig.AWSEBSCSIDriver or setting spec.kubeControllerManaager.externalCloudVolumePlugin set to `aws`"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this is needs to be a requirement. Users may have clusters that don't run any persistent volumes, for example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The challenge right now is that everyone else need to actively set one of these values to get a working cluster. I think that when we by default enable either using external CCM for AWS and/or external CSI driver we can relax the relax the requirement.

I suspect that the CSI driver will be more popular than the external CCM for the time being anyway. CSI driver does bring in additional features.

}
}
}
return allErrs

}

func awsValidateInstanceGroup(ig *kops.InstanceGroup, cloud awsup.AWSCloud) field.ErrorList {
allErrs := field.ErrorList{}

Expand Down
37 changes: 37 additions & 0 deletions pkg/apis/kops/validation/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,43 @@ import (
"k8s.io/kops/pkg/apis/kops"
)

func TestAWSValidateExternalCloudConfig(t *testing.T) {
grid := []struct {
Input kops.ClusterSpec
ExpectedErrors []string
}{
{
Input: kops.ClusterSpec{
ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{},
},
ExpectedErrors: []string{"Forbidden::spec.externalCloudControllerManager"},
},
{
Input: kops.ClusterSpec{
ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{},
CloudConfig: &kops.CloudConfiguration{
AWSEBSCSIDriver: &kops.AWSEBSCSIDriver{
Enabled: fi.Bool(true),
},
},
},
},
{
Input: kops.ClusterSpec{
ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{},
KubeControllerManager: &kops.KubeControllerManagerConfig{
ExternalCloudVolumePlugin: "aws",
},
},
},
}
for _, g := range grid {
errs := awsValidateExternalCloudControllerManager(g.Input)

testErrors(t, g.Input, errs, g.ExpectedErrors)
}
}

func TestValidateInstanceGroupSpec(t *testing.T) {
grid := []struct {
Input kops.InstanceGroupSpec
Expand Down
26 changes: 26 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

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

18 changes: 10 additions & 8 deletions pkg/model/components/kubecontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error

if clusterSpec.ExternalCloudControllerManager != nil {
kcm.CloudProvider = "external"

// External cloud provider disables KCM volume controllers, so
// most users would want to either install CSI or pass
// --external-cloud-volume-plugin to the KCM, which runs the
// KCM volume controllers.
if kcm.ExternalCloudVolumePlugin == "" {
klog.Infof("An external cloud controller manager is configured, but ExternalCloudVolumePlugin is not configured for the KCM. This means a CSI plugin must be installed by the user or else volume management might not work.")
}
}

kcm.LogLevel = 2
Expand Down Expand Up @@ -158,5 +150,15 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error
kcm.Controllers = []string{"*", "tokencleaner"}
}

if clusterSpec.CloudConfig != nil && clusterSpec.CloudConfig.AWSEBSCSIDriver != nil && fi.BoolValue(clusterSpec.CloudConfig.AWSEBSCSIDriver.Enabled) {

if kcm.FeatureGates == nil {
kcm.FeatureGates = make(map[string]string)
}
if _, found := kcm.FeatureGates["CSIMigrationAWSComplete"]; !found {
kcm.FeatureGates["CSIMigrationAWSComplete"] = "true"
}
}

return nil
}
6 changes: 6 additions & 0 deletions pkg/model/components/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error {
if clusterSpec.Kubelet.FeatureGates == nil {
clusterSpec.Kubelet.FeatureGates = make(map[string]string)
}

if clusterSpec.CloudConfig != nil && clusterSpec.CloudConfig.AWSEBSCSIDriver != nil && fi.BoolValue(clusterSpec.CloudConfig.AWSEBSCSIDriver.Enabled) {
if _, found := clusterSpec.Kubelet.FeatureGates["CSIMigrationAWSComplete"]; !found {
clusterSpec.Kubelet.FeatureGates["CSIMigrationAWSComplete"] = "true"
}
}
if _, found := clusterSpec.Kubelet.FeatureGates["ExperimentalCriticalPodAnnotation"]; !found {
if b.IsKubernetesLT("1.16") {
clusterSpec.Kubelet.FeatureGates["ExperimentalCriticalPodAnnotation"] = "true"
Expand Down
Loading