Skip to content

Commit 7a33223

Browse files
committed
Disable access entry creation for self-managed nodes on clusters with CONFIG_MAP only
1 parent 025550a commit 7a33223

File tree

6 files changed

+42
-26
lines changed

6 files changed

+42
-26
lines changed

pkg/apis/eksctl.io/v1alpha5/zz_generated.defaults.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cfn/manager/create_tasks.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"github.com/pkg/errors"
99
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010

11+
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
12+
1113
"github.com/weaveworks/eksctl/pkg/actions/accessentry"
1214
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
1315
iamoidc "github.com/weaveworks/eksctl/pkg/iam/oidc"
@@ -24,7 +26,7 @@ const (
2426
// NewTasksToCreateCluster defines all tasks required to create a cluster along
2527
// with some nodegroups; see CreateAllNodeGroups for how onlyNodeGroupSubset works.
2628
func (c *StackCollection) NewTasksToCreateCluster(ctx context.Context, nodeGroups []*api.NodeGroup,
27-
managedNodeGroups []*api.ManagedNodeGroup, accessEntries []api.AccessEntry, accessEntryCreator accessentry.CreatorInterface, postClusterCreationTasks ...tasks.Task) *tasks.TaskTree {
29+
managedNodeGroups []*api.ManagedNodeGroup, accessConfig *api.AccessConfig, accessEntryCreator accessentry.CreatorInterface, postClusterCreationTasks ...tasks.Task) *tasks.TaskTree {
2830
taskTree := tasks.TaskTree{Parallel: false}
2931

3032
taskTree.Append(&createClusterTask{
@@ -34,8 +36,8 @@ func (c *StackCollection) NewTasksToCreateCluster(ctx context.Context, nodeGroup
3436
ctx: ctx,
3537
})
3638

37-
if len(accessEntries) > 0 {
38-
taskTree.Append(accessEntryCreator.CreateTasks(ctx, accessEntries))
39+
if len(accessConfig.AccessEntries) > 0 {
40+
taskTree.Append(accessEntryCreator.CreateTasks(ctx, accessConfig.AccessEntries))
3941
}
4042

4143
appendNodeGroupTasksTo := func(taskTree *tasks.TaskTree) {
@@ -44,7 +46,8 @@ func (c *StackCollection) NewTasksToCreateCluster(ctx context.Context, nodeGroup
4446
Parallel: true,
4547
IsSubTask: true,
4648
}
47-
if unmanagedNodeGroupTasks := c.NewUnmanagedNodeGroupTask(ctx, nodeGroups, false, false, false, vpcImporter); unmanagedNodeGroupTasks.Len() > 0 {
49+
disableAccessEntryCreation := accessConfig.AuthenticationMode == ekstypes.AuthenticationModeConfigMap
50+
if unmanagedNodeGroupTasks := c.NewUnmanagedNodeGroupTask(ctx, nodeGroups, false, false, disableAccessEntryCreation, vpcImporter); unmanagedNodeGroupTasks.Len() > 0 {
4851
unmanagedNodeGroupTasks.IsSubTask = true
4952
nodeGroupTasks.Append(unmanagedNodeGroupTasks)
5053
}

pkg/cfn/manager/fakes/fake_stack_manager.go

Lines changed: 8 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cfn/manager/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ type StackManager interface {
8989
NewTasksToDeleteClusterWithNodeGroups(ctx context.Context, clusterStack *Stack, nodeGroupStacks []NodeGroupStack, clusterOperable bool, newOIDCManager NewOIDCManager, newTasksToDeleteAddonIAM NewTasksToDeleteAddonIAM, newTasksToDeletePodIdentityRole NewTasksToDeletePodIdentityRole, cluster *ekstypes.Cluster, clientSetGetter kubernetes.ClientSetGetter, wait, force bool, cleanup func(chan error, string) error) (*tasks.TaskTree, error)
9090
NewTasksToCreateIAMServiceAccounts(serviceAccounts []*api.ClusterIAMServiceAccount, oidc *iamoidc.OpenIDConnectManager, clientSetGetter kubernetes.ClientSetGetter) *tasks.TaskTree
9191
NewTaskToDeleteUnownedNodeGroup(ctx context.Context, clusterName, nodegroup string, nodeGroupDeleter NodeGroupDeleter, waitCondition *DeleteWaitCondition) tasks.Task
92-
NewTasksToCreateCluster(ctx context.Context, nodeGroups []*api.NodeGroup, managedNodeGroups []*api.ManagedNodeGroup, accessEntries []api.AccessEntry, accessEntryCreator accessentry.CreatorInterface, postClusterCreationTasks ...tasks.Task) *tasks.TaskTree
92+
NewTasksToCreateCluster(ctx context.Context, nodeGroups []*api.NodeGroup, managedNodeGroups []*api.ManagedNodeGroup, accessConfig *api.AccessConfig, accessEntryCreator accessentry.CreatorInterface, postClusterCreationTasks ...tasks.Task) *tasks.TaskTree
9393
NewTasksToDeleteIAMServiceAccounts(ctx context.Context, serviceAccounts []string, clientSetGetter kubernetes.ClientSetGetter, wait bool) (*tasks.TaskTree, error)
9494
NewTasksToDeleteNodeGroups(stacks []NodeGroupStack, shouldDelete func(_ string) bool, wait bool, cleanup func(chan error, string) error) (*tasks.TaskTree, error)
9595
NewTasksToDeleteOIDCProviderWithIAMServiceAccounts(ctx context.Context, newOIDCManager NewOIDCManager, cluster *ekstypes.Cluster, clientSetGetter kubernetes.ClientSetGetter, force bool) (*tasks.TaskTree, error)

pkg/cfn/manager/tasks_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ var _ = Describe("StackCollection Tasks", func() {
7575

7676
It("should have nice description", func() {
7777
fakeVPCImporter := new(vpcfakes.FakeImporter)
78+
accessConfig := &api.AccessConfig{}
7879
// TODO use DescribeTable
7980

8081
// The supportsManagedNodes argument has no effect on the Describe call, so the values are alternated
@@ -99,7 +100,7 @@ var _ = Describe("StackCollection Tasks", func() {
99100
Expect(tasks.Describe()).To(Equal(`no tasks`))
100101
}
101102
{
102-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar", "foo"), nil, nil, nil)
103+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar", "foo"), nil, accessConfig, nil)
103104
Expect(tasks.Describe()).To(Equal(`
104105
2 sequential tasks: { create cluster control plane "test-cluster",
105106
2 parallel sub-tasks: {
@@ -110,18 +111,18 @@ var _ = Describe("StackCollection Tasks", func() {
110111
`))
111112
}
112113
{
113-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar"), nil, nil, nil)
114+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar"), nil, accessConfig, nil)
114115
Expect(tasks.Describe()).To(Equal(`
115116
2 sequential tasks: { create cluster control plane "test-cluster", create nodegroup "bar"
116117
}
117118
`))
118119
}
119120
{
120-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), nil, nil, nil, nil)
121+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), nil, nil, accessConfig, nil)
121122
Expect(tasks.Describe()).To(Equal(`1 task: { create cluster control plane "test-cluster" }`))
122123
}
123124
{
124-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar", "foo"), makeManagedNodeGroups("m1", "m2"), nil, nil)
125+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar", "foo"), makeManagedNodeGroups("m1", "m2"), accessConfig, nil)
125126
Expect(tasks.Describe()).To(Equal(`
126127
2 sequential tasks: { create cluster control plane "test-cluster",
127128
2 parallel sub-tasks: {
@@ -138,7 +139,7 @@ var _ = Describe("StackCollection Tasks", func() {
138139
`))
139140
}
140141
{
141-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar", "foo"), makeManagedNodeGroupsWithPropagatedTags("m1", "m2"), nil, nil)
142+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar", "foo"), makeManagedNodeGroupsWithPropagatedTags("m1", "m2"), accessConfig, nil)
142143
Expect(tasks.Describe()).To(Equal(`
143144
2 sequential tasks: { create cluster control plane "test-cluster",
144145
2 parallel sub-tasks: {
@@ -161,7 +162,7 @@ var _ = Describe("StackCollection Tasks", func() {
161162
`))
162163
}
163164
{
164-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("foo"), makeManagedNodeGroups("m1"), nil, nil)
165+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("foo"), makeManagedNodeGroups("m1"), accessConfig, nil)
165166
Expect(tasks.Describe()).To(Equal(`
166167
2 sequential tasks: { create cluster control plane "test-cluster",
167168
2 parallel sub-tasks: {
@@ -172,7 +173,7 @@ var _ = Describe("StackCollection Tasks", func() {
172173
`))
173174
}
174175
{
175-
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar"), nil, nil, nil, &task{id: 1})
176+
tasks := stackManager.NewTasksToCreateCluster(context.Background(), makeNodeGroups("bar"), nil, accessConfig, nil, &task{id: 1})
176177
Expect(tasks.Describe()).To(Equal(`
177178
2 sequential tasks: { create cluster control plane "test-cluster",
178179
2 sequential sub-tasks: {

pkg/ctl/create/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func doCreateCluster(cmd *cmdutils.Cmd, ngFilter *filter.NodeGroupFilter, params
360360
postClusterCreationTasks.Append(preNodegroupAddons)
361361
}
362362

363-
taskTree := stackManager.NewTasksToCreateCluster(ctx, cfg.NodeGroups, cfg.ManagedNodeGroups, cfg.AccessConfig.AccessEntries, makeAccessEntryCreator(cfg.Metadata.Name, stackManager), postClusterCreationTasks)
363+
taskTree := stackManager.NewTasksToCreateCluster(ctx, cfg.NodeGroups, cfg.ManagedNodeGroups, cfg.AccessConfig, makeAccessEntryCreator(cfg.Metadata.Name, stackManager), postClusterCreationTasks)
364364

365365
logger.Info(taskTree.Describe())
366366
if errs := taskTree.DoAllSync(); len(errs) > 0 {

0 commit comments

Comments
 (0)