Skip to content

Commit 7c9d1cb

Browse files
committed
feat: add support for EKS service on AWS
Review - securityGroups Review - use Network, still only one subnet (required 2+) Define multiple CIDRs Remove unused Use standard networking az
1 parent 355ae63 commit 7c9d1cb

29 files changed

+14078
-11
lines changed

cmd/mapt/cmd/aws/aws.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package aws
33
import (
44
"github.com/redhat-developer/mapt/cmd/mapt/cmd/aws/hosts"
55
"github.com/redhat-developer/mapt/cmd/mapt/cmd/aws/services"
6+
params "github.com/redhat-developer/mapt/cmd/mapt/cmd/constants"
67
"github.com/spf13/cobra"
8+
"github.com/spf13/pflag"
79
"github.com/spf13/viper"
810
)
911

@@ -23,12 +25,17 @@ func GetCmd() *cobra.Command {
2325
return nil
2426
},
2527
}
28+
29+
flagSet := pflag.NewFlagSet(cmd, pflag.ExitOnError)
30+
params.AddCommonFlags(flagSet)
31+
c.PersistentFlags().AddFlagSet(flagSet)
2632

2733
c.AddCommand(
2834
hosts.GetMacCmd(),
2935
hosts.GetWindowsCmd(),
3036
hosts.GetRHELCmd(),
3137
hosts.GetFedoraCmd(),
32-
services.GetMacPoolCmd())
38+
services.GetMacPoolCmd(),
39+
services.GetEKSCmd())
3340
return c
3441
}

cmd/mapt/cmd/aws/constants/contants.go renamed to cmd/mapt/cmd/aws/constants/constants.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ const (
2121
MACFixedLocationDesc string = "if this flag is set the host will be created only on the region set by the AWS Env (AWS_DEFAULT_REGION)"
2222
MACDHID string = "dedicated-host-id"
2323
MACDHIDDesc string = "id for the dedicated host"
24+
25+
ParamRegion = "location"
26+
ParamRegionDesc = "location for created resources in case spot flag (if available) is not passed"
27+
ParamVMSize = "vmsize"
28+
ParamVMSizeDesc = "size for the VM"
29+
DefaultVMSize = "t3.medium"
2430
)
2531

2632
func MACArchAsCirrusArch(arch string) *cirrus.Arch {

cmd/mapt/cmd/aws/services/eks.go

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package services
2+
3+
import (
4+
awsparams "github.com/redhat-developer/mapt/cmd/mapt/cmd/aws/constants"
5+
params "github.com/redhat-developer/mapt/cmd/mapt/cmd/constants"
6+
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
7+
awsEKS "github.com/redhat-developer/mapt/pkg/provider/aws/action/eks"
8+
"github.com/redhat-developer/mapt/pkg/util/logging"
9+
"github.com/spf13/cobra"
10+
"github.com/spf13/pflag"
11+
"github.com/spf13/viper"
12+
)
13+
14+
const (
15+
cmdEKS = "eks"
16+
cmdEKSDesc = "eks operations"
17+
18+
paramVersion = "version"
19+
paramVersionDesc = "EKS K8s cluster version"
20+
defaultParamVMSize = "t3.medium"
21+
paramVMSizeDesc = "VMSize to be used on the user pool. Typically this is used to provision spot node pools"
22+
defaultVersion = "1.31"
23+
paramScalingDesiredSize = "workers-desired"
24+
paramScalingDesiredSizeDesc = "Worker nodes scaling desired size"
25+
defaultScalingDesiredSize = "1"
26+
paramScalingMaxSize = "workers-max"
27+
paramScalingMaxSizeDesc = "Worker nodes scaling maximum size"
28+
defaultScalingMaxSize = "3"
29+
paramScalingMinSize = "workers-min"
30+
paramScalingMinSizeDesc = "Worker nodes scaling minimum size"
31+
defaultScalingMinSize = "1"
32+
paramAddons = "addons"
33+
paramAddonsDesc = "List of EKS addons to be installed, separated by commas."
34+
defaultAddons = ""
35+
)
36+
37+
func GetEKSCmd() *cobra.Command {
38+
c := &cobra.Command{
39+
Use: cmdEKS,
40+
Short: cmdEKSDesc,
41+
RunE: func(cmd *cobra.Command, args []string) error {
42+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
43+
return err
44+
}
45+
return nil
46+
},
47+
}
48+
c.AddCommand(getCreateEKS(), getDestroyEKS())
49+
return c
50+
}
51+
52+
func getCreateEKS() *cobra.Command {
53+
c := &cobra.Command{
54+
Use: params.CreateCmdName,
55+
Short: params.CreateCmdName,
56+
RunE: func(cmd *cobra.Command, args []string) error {
57+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
58+
return err
59+
}
60+
61+
if err := awsEKS.Create(
62+
&maptContext.ContextArgs{
63+
ProjectName: viper.GetString(params.ProjectName),
64+
BackedURL: viper.GetString(params.BackedURL),
65+
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
66+
Debug: viper.IsSet(params.Debug),
67+
DebugLevel: viper.GetUint(params.DebugLevel),
68+
Tags: viper.GetStringMapString(params.Tags),
69+
},
70+
&awsEKS.EKSRequest{
71+
Prefix: viper.GetString(params.ProjectName),
72+
Region: viper.GetString(awsparams.ParamRegion),
73+
VMSize: viper.GetString(awsparams.ParamVMSize),
74+
KubernetesVersion: viper.GetString(paramVersion),
75+
ScalingDesiredSize: viper.GetInt(paramScalingDesiredSize),
76+
ScalingMaxSize: viper.GetInt(paramScalingMaxSize),
77+
ScalingMinSize: viper.GetInt(paramScalingMinSize),
78+
Addons: viper.GetStringSlice(paramAddons),
79+
}); err != nil {
80+
logging.Error(err)
81+
}
82+
return nil
83+
},
84+
}
85+
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError)
86+
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
87+
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
88+
flagSet.StringP(awsparams.ParamRegion, "", "", awsparams.ParamRegionDesc)
89+
flagSet.StringP(awsparams.ParamVMSize, "", defaultParamVMSize, paramVMSizeDesc)
90+
flagSet.StringP(paramVersion, "", defaultVersion, paramVersionDesc)
91+
flagSet.StringP(paramScalingDesiredSize, "", defaultScalingDesiredSize, paramScalingDesiredSizeDesc)
92+
flagSet.StringP(paramScalingMaxSize, "", defaultScalingMaxSize, paramScalingMaxSizeDesc)
93+
flagSet.StringP(paramScalingMinSize, "", defaultScalingMinSize, paramScalingMinSizeDesc)
94+
flagSet.StringSliceP(paramAddons, "", []string{}, paramAddonsDesc)
95+
c.PersistentFlags().AddFlagSet(flagSet)
96+
return c
97+
}
98+
99+
func getDestroyEKS() *cobra.Command {
100+
return &cobra.Command{
101+
Use: params.DestroyCmdName,
102+
Short: params.DestroyCmdName,
103+
RunE: func(cmd *cobra.Command, args []string) error {
104+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
105+
return err
106+
}
107+
if err := awsEKS.Destroy(
108+
&maptContext.ContextArgs{
109+
ProjectName: viper.GetString(params.ProjectName),
110+
BackedURL: viper.GetString(params.BackedURL),
111+
Debug: viper.IsSet(params.Debug),
112+
DebugLevel: viper.GetUint(params.DebugLevel),
113+
}); err != nil {
114+
logging.Error(err)
115+
}
116+
return nil
117+
},
118+
}
119+
}

cmd/mapt/cmd/azure/services/aks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
paramVersion = "version"
2222
paramVersionDesc = "AKS K8s cluster version"
2323
paramVMSizeDesc = "VMSize to be used on the user pool. Typically this is used to provision spot node pools"
24-
defaultVersion = "1.30"
24+
defaultVersion = "1.31"
2525
paramOnlySystemPool = "only-system-pool"
2626
paramOnlySystemPoolDesc = "if we do not need bunch of resources we can run only the systempool. More info https://learn.microsoft.com/es-es/azure/aks/use-system-pools?tabs=azure-cli#system-and-user-node-pools"
2727
paramEnableAppRouting = "enable-app-routing"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package eks
2+
3+
const (
4+
stackName = "stackCreateEKS"
5+
awsEKSID = "aeks"
6+
outputKubeconfig = "eksKubeconfig"
7+
systemPoolVMSize = "t3.medium"
8+
)

0 commit comments

Comments
 (0)