@@ -22,6 +22,7 @@ import (
2222 "go.uber.org/cadence"
2323 "go.uber.org/cadence/workflow"
2424
25+ "github.com/banzaicloud/pipeline/internal/cluster/clustersetup"
2526 "github.com/banzaicloud/pipeline/pkg/sdk/brn"
2627 "github.com/banzaicloud/pipeline/pkg/sdk/cadence/lib/pipeline/processlog"
2728)
@@ -47,19 +48,26 @@ type CreateClusterWorkflowInput struct {
4748 PipelineExternalURLInsecure bool
4849 OIDCEnabled bool
4950 VPCID string
51+ KubernetesVersion string
5052}
5153
5254type CreateClusterWorkflow struct {
53- DefaultNodeVolumeSize int
54- GlobalRegion string
55- processLogger processlog.ProcessLogger
55+ DefaultEBSCSIDriverChartVersion string
56+ DefaultNodeVolumeSize int
57+ GlobalRegion string
58+ processLogger processlog.ProcessLogger
5659}
5760
58- func NewCreateClusterWorkflow (defaultNodeVolumeSize int , globalRegion string ) CreateClusterWorkflow {
61+ func NewCreateClusterWorkflow (
62+ defaultEBSCSIDriverChartVersion string ,
63+ defaultNodeVolumeSize int ,
64+ globalRegion string ,
65+ ) CreateClusterWorkflow {
5966 return CreateClusterWorkflow {
60- DefaultNodeVolumeSize : defaultNodeVolumeSize ,
61- GlobalRegion : globalRegion ,
62- processLogger : processlog .New (),
67+ DefaultEBSCSIDriverChartVersion : defaultEBSCSIDriverChartVersion ,
68+ DefaultNodeVolumeSize : defaultNodeVolumeSize ,
69+ GlobalRegion : globalRegion ,
70+ processLogger : processlog .New (),
6371 }
6472}
6573
@@ -406,9 +414,9 @@ func (w CreateClusterWorkflow) Execute(ctx workflow.Context, input CreateCluster
406414
407415 // Create nodes
408416 {
409- futures := make ([]workflow.Future , len (nodePools ))
417+ futures := make ([]workflow.Future , 0 , len (nodePools ))
410418
411- for i , np := range nodePools {
419+ for _ , np := range nodePools {
412420 if ! np .Master {
413421 subnetIDs := np .Subnets
414422 if len (np .Subnets ) == 0 {
@@ -430,19 +438,51 @@ func (w CreateClusterWorkflow) Execute(ctx workflow.Context, input CreateCluster
430438 SSHKeyName : keyOut .KeyName ,
431439 }
432440
433- futures [i ] = workflow .ExecuteActivity (ctx , CreateWorkerPoolActivityName , createWorkerPoolActivityInput )
441+ futures = append (
442+ futures ,
443+ workflow .ExecuteActivity (ctx , CreateWorkerPoolActivityName , createWorkerPoolActivityInput ),
444+ )
434445 }
435446 }
436447
437- errs := make ([]error , len (futures ))
438- for i , future := range futures {
448+ errs := make ([]error , 0 , len (futures ))
449+ for index , future := range futures {
439450 if future != nil {
440- errs [i ] = errors .Wrapf (future .Get (ctx , nil ), "couldn't create nodepool %q" , nodePools [i ].Name )
451+ if err := future .Get (ctx , nil ); err != nil {
452+ errs = append (errs , errors .Wrapf (err , "couldn't create nodepool %q" , nodePools [index ].Name ))
453+ }
441454 }
442455 }
443456
444- return errors .Combine (errs ... )
457+ if len (errs ) > 0 {
458+ return errors .Combine (errs ... )
459+ }
460+ }
461+
462+ // Note: install EBS CSI driver for PVCs from K8s 1.23.
463+ // Source: https://docs.aws.amazon.com/eks/latest/userguide/ebs-csi.html
464+ {
465+ activityInput := clustersetup.DeployAWSEBSCSIDriverActivityInput {
466+ ClusterID : input .ClusterID ,
467+ KubernetesVersion : input .KubernetesVersion ,
468+ ChartVersion : w .DefaultEBSCSIDriverChartVersion ,
469+ }
470+
471+ err := workflow .ExecuteActivity (
472+ ctx ,
473+ clustersetup .DeployAWSEBSCSIDriverActivityName ,
474+ activityInput ,
475+ ).Get (ctx , nil )
476+ if err != nil {
477+ return errors .WrapIfWithDetails (
478+ err ,
479+ "installing EBS CSI driver Helm chart failed" ,
480+ "activityInput" , activityInput ,
481+ )
482+ }
445483 }
484+
485+ return nil
446486}
447487
448488type decodableError struct {
0 commit comments