Skip to content

Commit

Permalink
Disable metrics-server default addon creation for unsupported regions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Diaz committed Jan 16, 2025
1 parent 714de76 commit be94ef8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/actions/addon/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import (
"github.com/weaveworks/eksctl/pkg/utils/tasks"
)

func CreateAddonTasks(ctx context.Context, cfg *api.ClusterConfig, clusterProvider *eks.ClusterProvider, iamRoleCreator IAMRoleCreator, forceAll bool, timeout time.Duration) (*tasks.TaskTree, *tasks.TaskTree, *tasks.GenericTask, []string) {
func CreateAddonTasks(ctx context.Context, cfg *api.ClusterConfig, clusterProvider *eks.ClusterProvider, iamRoleCreator IAMRoleCreator, forceAll bool, timeout time.Duration, region string) (*tasks.TaskTree, *tasks.TaskTree, *tasks.GenericTask, []string) {
var addons []*api.Addon
var autoDefaultAddonNames []string
if !cfg.AddonsConfig.DisableDefaultAddons {
addons = make([]*api.Addon, len(cfg.Addons))
copy(addons, cfg.Addons)

for addonName, addonInfo := range api.KnownAddons {
if addonInfo.IsDefault && !slices.ContainsFunc(cfg.Addons, func(a *api.Addon) bool {
if addonInfo.IsDefault && !slices.Contains(addonInfo.ExcludedRegions, region) && !slices.ContainsFunc(cfg.Addons, func(a *api.Addon) bool {
return strings.EqualFold(a.Name, addonName)
}) {
if !cfg.IsAutoModeEnabled() || addonInfo.IsDefaultAutoMode {
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/known_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var KnownAddons = map[string]struct {
IsDefault bool
CreateBeforeNodeGroup bool
IsDefaultAutoMode bool
ExcludedRegions []string
}{
VPCCNIAddon: {
IsDefault: true,
Expand All @@ -28,6 +29,15 @@ var KnownAddons = map[string]struct {
IsDefault: true,
CreateBeforeNodeGroup: true,
IsDefaultAutoMode: true,
ExcludedRegions: []string{
RegionCNNorthwest1,
RegionCNNorth1,
RegionUSISOEast1,
RegionUSISOWest1,
RegionUSISOBEast1,
RegionUSGovWest1,
RegionUSGovEast1,
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/create/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func doCreateCluster(cmd *cmdutils.Cmd, ngFilter *filter.NodeGroupFilter, params
ClusterName: cfg.Metadata.Name,
StackCreator: stackManager,
}
preNodegroupAddons, postAddons, updateVPCCNITask, autoDefaultAddons := addon.CreateAddonTasks(ctx, cfg, ctl, iamRoleCreator, true, cmd.ProviderConfig.WaitTimeout)
preNodegroupAddons, postAddons, updateVPCCNITask, autoDefaultAddons := addon.CreateAddonTasks(ctx, cfg, ctl, iamRoleCreator, true, cmd.ProviderConfig.WaitTimeout, meta.Region)
if len(autoDefaultAddons) > 0 {
logger.Info("default addons %s were not specified, will install them as EKS addons", strings.Join(autoDefaultAddons, ", "))
}
Expand Down

0 comments on commit be94ef8

Please sign in to comment.