Skip to content
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
9 changes: 2 additions & 7 deletions pkg/actions/nodegroup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/weaveworks/eksctl/pkg/kubernetes"
"github.com/weaveworks/eksctl/pkg/printers"
"github.com/weaveworks/eksctl/pkg/utils"
utilsstrings "github.com/weaveworks/eksctl/pkg/utils/strings"
"github.com/weaveworks/eksctl/pkg/utils/tasks"
"github.com/weaveworks/eksctl/pkg/vpc"

Expand Down Expand Up @@ -73,10 +72,6 @@ func (m *Manager) Create(options CreateOpts, nodegroupFilter filter.NodegroupFil
return errors.New("Managed Nodegroups are not supported for this cluster version. Please update the cluster before adding managed nodegroups")
}

if utilsstrings.Value(cfg.VPC.IPFamily) == string(api.IPV6Family) && len(cfg.NodeGroups) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out this will eventually call the task creation in the end. Which means this will eventually fail there so there is no need to duplicate this logic in the create.

return errors.New("unmanaged nodegroups are not supported with IPv6 clusters")
}

if err := eks.ValidateBottlerocketSupport(ctl.ControlPlaneVersion(), cmdutils.ToKubeNodeGroups(cfg)); err != nil {
return err
}
Expand Down Expand Up @@ -137,7 +132,7 @@ func (m *Manager) Create(options CreateOpts, nodegroupFilter filter.NodegroupFil
return cmdutils.PrintNodeGroupDryRunConfig(clusterConfigCopy, os.Stdout)
}

if err := m.nodeCreationTasks(options, nodegroupFilter, supportsManagedNodes, isOwnedCluster); err != nil {
if err := m.nodeCreationTasks(supportsManagedNodes, isOwnedCluster); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused parameters

return err
}

Expand All @@ -152,7 +147,7 @@ func (m *Manager) Create(options CreateOpts, nodegroupFilter filter.NodegroupFil
return nil
}

func (m *Manager) nodeCreationTasks(options CreateOpts, nodegroupFilter filter.NodegroupFilter, supportsManagedNodes, isOwnedCluster bool) error {
func (m *Manager) nodeCreationTasks(supportsManagedNodes, isOwnedCluster bool) error {
cfg := m.cfg
meta := cfg.Metadata
init := m.init
Expand Down
50 changes: 0 additions & 50 deletions pkg/actions/nodegroup/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import (
"fmt"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"

"github.com/pkg/errors"

"github.com/weaveworks/eksctl/pkg/actions/nodegroup"
Expand All @@ -19,7 +17,6 @@ import (
"github.com/weaveworks/eksctl/pkg/kubernetes"
"github.com/weaveworks/eksctl/pkg/testutils"
"github.com/weaveworks/eksctl/pkg/testutils/mockprovider"
utilsstrings "github.com/weaveworks/eksctl/pkg/utils/strings"
)

type ngEntry struct {
Expand Down Expand Up @@ -302,53 +299,6 @@ var _ = DescribeTable("Create", func(t ngEntry) {
}),
)

var _ = Describe("create", func() {
When("creating an unmanaged nodegroup for an ipv6 cluster", func() {
It("returns an error", func() {
cfg := newClusterConfig()
cfg.Metadata.Version = api.Version1_21
cfg.IAM = &api.ClusterIAM{
WithOIDC: api.Enabled(),
}
cfg.Addons = []*api.Addon{
{
Name: api.VPCCNIAddon,
},
{
Name: api.KubeProxyAddon,
},
{
Name: api.CoreDNSAddon,
},
}
cfg.VPC.IPFamily = utilsstrings.Pointer(string(api.IPV6Family))

p := mockprovider.NewMockProvider()
ctl := &eks.ClusterProvider{
Provider: p,
Status: &eks.ProviderStatus{
ClusterInfo: &eks.ClusterInfo{
Cluster: testutils.NewFakeCluster("my-cluster", ""),
},
},
}
m := nodegroup.New(cfg, ctl, nil)

k := &fakes.FakeKubeProvider{}
k.SupportsManagedNodesReturns(true, nil)
m.MockKubeProvider(k)

init := &fakes.FakeNodeGroupInitialiser{}
m.MockNodeGroupService(init)

ngFilter := utilFakes.FakeNodegroupFilter{}

err := m.Create(nodegroup.CreateOpts{}, &ngFilter)
Expect(err).To(MatchError(ContainSubstring("unmanaged nodegroups are not supported with IPv6 clusters")))
})
})
})

func newClusterConfig() *api.ClusterConfig {
return &api.ClusterConfig{
TypeMeta: api.ClusterConfigTypeMeta(),
Expand Down
10 changes: 9 additions & 1 deletion pkg/cfn/manager/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/kris-nova/logger"
"github.com/pkg/errors"
"github.com/tidwall/gjson"

"github.com/weaveworks/eksctl/pkg/nodebootstrap"
utilsstrings "github.com/weaveworks/eksctl/pkg/utils/strings"

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/cfn/builder"
Expand Down Expand Up @@ -80,7 +82,13 @@ func (c *StackCollection) createNodeGroupTask(errs chan error, ng *api.NodeGroup

func (c *StackCollection) createManagedNodeGroupTask(errorCh chan error, ng *api.ManagedNodeGroup, forceAddCNIPolicy bool, vpcImporter vpc.Importer) error {
name := c.makeNodeGroupStackName(ng.Name)

cluster, err := c.DescribeClusterStack()
if err != nil {
return err
}
if cluster == nil && utilsstrings.Value(c.spec.VPC.IPFamily) == string(api.IPV6Family) {
return errors.New("managed nodegroups cannot be created on IPv6 unowned clusters")
}
logger.Info("building managed nodegroup stack %q", name)
bootstrapper := nodebootstrap.NewManagedBootstrapper(c.spec, ng)
stack := builder.NewManagedNodeGroup(c.ec2API, c.spec, ng, builder.NewLaunchTemplateFetcher(c.ec2API), bootstrapper, forceAddCNIPolicy, vpcImporter)
Expand Down
39 changes: 39 additions & 0 deletions pkg/cfn/manager/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
"github.com/stretchr/testify/mock"

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/testutils/mockprovider"
utilsstrings "github.com/weaveworks/eksctl/pkg/utils/strings"
vpcfakes "github.com/weaveworks/eksctl/pkg/vpc/fakes"
)

Expand Down Expand Up @@ -135,4 +139,39 @@ var _ = Describe("StackCollection Tasks", func() {
})
})
})
Describe("ManagedNodeGroupTask", func() {
When("creating managed nodegroups on a ipv6 cluster", func() {
var (
p *mockprovider.MockProvider
cfg *api.ClusterConfig
stackManager *StackCollection
)
BeforeEach(func() {
p = mockprovider.NewMockProvider()
cfg = newClusterConfig("test-ipv6-cluster")
cfg.VPC.IPFamily = utilsstrings.Pointer(string(api.IPV6Family))
stackManager = NewStackCollection(p, cfg)
})
It("returns an error", func() {
p.MockCloudFormation().On("ListStacksPages", mock.Anything, mock.Anything).Return(nil)
ng := api.NewManagedNodeGroup()
fakeVPCImporter := new(vpcfakes.FakeImporter)
tasks := stackManager.NewManagedNodeGroupTask([]*api.ManagedNodeGroup{ng}, false, fakeVPCImporter)
errs := tasks.DoAllSync()
Expect(errs).To(HaveLen(1))
Expect(errs[0]).To(MatchError(ContainSubstring("managed nodegroups cannot be created on IPv6 unowned clusters")))
})
When("finding the stack fails", func() {
It("returns the stack error", func() {
p.MockCloudFormation().On("ListStacksPages", mock.Anything, mock.Anything).Return(errors.New("not found"))
ng := api.NewManagedNodeGroup()
fakeVPCImporter := new(vpcfakes.FakeImporter)
tasks := stackManager.NewManagedNodeGroupTask([]*api.ManagedNodeGroup{ng}, false, fakeVPCImporter)
errs := tasks.DoAllSync()
Expect(errs).To(HaveLen(1))
Expect(errs[0]).To(MatchError(ContainSubstring("not found")))
})
})
})
})
})
1 change: 1 addition & 0 deletions userdocs/src/usage/vpc-networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ This is an in config file setting only. When IPv6 is set, the following restrict
- managed addons are defined as shows above
- version must be => 1.21
- unmanaged nodegroups are not yet supported with IPv6 clusters
- managed nodegroup creation is not supported with un-owned IPv6 clusters
- `vpc.NAT` and `serviceIPv4CIDR` fields are created by eksctl for ipv6 clusters and thus, are not supported configuration options
- AutoAllocateIPv6 is not supported together with IPv6

Expand Down