-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add support for creating IPv6 VPC and cluster #4317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nikimanoledaki
merged 9 commits into
eksctl-io:ipv6
from
nikimanoledaki:v6-vpc-creation
Oct 26, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2b40460
Implement default workflow to add IPv6 VPC resources
nikimanoledaki f89020f
wait for addons to be healthy only if there are nodegroups
54c262a
Passing IpFamily field to Control Plane CF template
nikimanoledaki e787a72
Commenting ipFamily test and code due to CF bug
nikimanoledaki 827c47e
Adding AssignIpv6AddressOnCreation task after cluster creation due to…
nikimanoledaki c68641b
Revert "Commenting ipFamily test and code due to CF bug"
nikimanoledaki 02efa0d
Refactoring integration test to wait for Service to eventually exist
nikimanoledaki 67f8226
Updating goformation with ipFamily changes
nikimanoledaki 3237ad2
Implement review feedback
nikimanoledaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| //go:build integration | ||
| // +build integration | ||
|
|
||
| package ipv6 | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/aws/aws-sdk-go/aws" | ||
| cfn "github.com/aws/aws-sdk-go/service/cloudformation" | ||
| awsec2 "github.com/aws/aws-sdk-go/service/ec2" | ||
| . "github.com/weaveworks/eksctl/integration/matchers" | ||
| . "github.com/weaveworks/eksctl/integration/runner" | ||
| "github.com/weaveworks/eksctl/integration/tests" | ||
| api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5" | ||
| "github.com/weaveworks/eksctl/pkg/cfn/builder" | ||
| "github.com/weaveworks/eksctl/pkg/eks" | ||
| "github.com/weaveworks/eksctl/pkg/testutils" | ||
| "github.com/xgfone/netaddr" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/client-go/kubernetes" | ||
|
|
||
| . "github.com/onsi/ginkgo" | ||
| . "github.com/onsi/gomega" | ||
| ) | ||
|
|
||
| var params *tests.Params | ||
|
|
||
| func init() { | ||
| // Call testing.Init() prior to tests.NewParams(), as otherwise -test.* will not be recognised. See also: https://golang.org/doc/go1.13#testing | ||
| testing.Init() | ||
| params = tests.NewParams("IPv6") | ||
| } | ||
|
|
||
| func TestIPv6(t *testing.T) { | ||
| testutils.RegisterAndRun(t) | ||
| } | ||
|
|
||
| var _ = Describe("(Integration) [EKS IPv6 test]", func() { | ||
| var ( | ||
| clusterConfig *api.ClusterConfig | ||
| ) | ||
|
|
||
| Context("Creating a cluster with IPv6", func() { | ||
| clusterName := params.NewClusterName("ipv6") | ||
|
|
||
| BeforeSuite(func() { | ||
| clusterConfig = api.NewClusterConfig() | ||
| clusterConfig.Metadata.Name = clusterName | ||
| clusterConfig.Metadata.Version = "1.21" | ||
| clusterConfig.Metadata.Region = params.Region | ||
| clusterConfig.VPC.IPFamily = aws.String("IPv6") | ||
| clusterConfig.VPC.NAT = nil | ||
| clusterConfig.IAM.WithOIDC = api.Enabled() | ||
| clusterConfig.Addons = []*api.Addon{ | ||
| { | ||
| Name: api.VPCCNIAddon, | ||
| }, | ||
| { | ||
| Name: api.KubeProxyAddon, | ||
| }, | ||
| { | ||
| Name: api.CoreDNSAddon, | ||
| }, | ||
| } | ||
|
|
||
| data, err := json.Marshal(clusterConfig) | ||
| Expect(err).ToNot(HaveOccurred()) | ||
|
|
||
| cmd := params.EksctlCreateCmd. | ||
| WithArgs( | ||
| "cluster", | ||
| "--config-file", "-", | ||
| "--verbose", "4", | ||
| ). | ||
| WithoutArg("--region", params.Region). | ||
| WithStdin(bytes.NewReader(data)) | ||
| Expect(cmd).To(RunSuccessfully()) | ||
| }) | ||
|
|
||
| AfterSuite(func() { | ||
| cmd := params.EksctlDeleteCmd.WithArgs( | ||
| "cluster", clusterName, | ||
| "--verbose", "2", | ||
| ) | ||
| Expect(cmd).To(RunSuccessfully()) | ||
| }) | ||
|
|
||
| It("should support ipv6", func() { | ||
| By("creating a VPC that has an IPv6 CIDR") | ||
| awsSession := NewSession(params.Region) | ||
| cfnSession := cfn.New(awsSession) | ||
|
|
||
| var describeStackOut *cfn.DescribeStacksOutput | ||
| describeStackOut, err := cfnSession.DescribeStacks(&cfn.DescribeStacksInput{ | ||
| StackName: aws.String(fmt.Sprintf("eksctl-%s-cluster", clusterName)), | ||
| }) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| var vpcID string | ||
| for _, output := range describeStackOut.Stacks[0].Outputs { | ||
| if *output.OutputKey == builder.VPCResourceKey { | ||
| vpcID = *output.OutputValue | ||
| } | ||
| } | ||
|
|
||
| ec2 := awsec2.New(awsSession) | ||
| vpcOutput, err := ec2.DescribeVpcs(&awsec2.DescribeVpcsInput{ | ||
| VpcIds: aws.StringSlice([]string{vpcID}), | ||
| }) | ||
| Expect(err).NotTo(HaveOccurred(), vpcOutput.GoString()) | ||
| Expect(vpcOutput.Vpcs[0].Ipv6CidrBlockAssociationSet).To(HaveLen(1)) | ||
|
|
||
| // TODO: get rid of this once CF bug is fixed https://github.com/weaveworks/eksctl/issues/4363 | ||
| By("setting AssignIpv6AddressOnCreation to true for each public subnet") | ||
| var publicSubnets string | ||
| for _, output := range describeStackOut.Stacks[0].Outputs { | ||
| if *output.OutputKey == builder.PublicSubnetsOutputKey { | ||
| publicSubnets = *output.OutputValue | ||
| } | ||
| } | ||
|
|
||
| subnetsOutput, err := ec2.DescribeSubnets(&awsec2.DescribeSubnetsInput{ | ||
| SubnetIds: aws.StringSlice(strings.Split(publicSubnets, ",")), | ||
| }) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(len(subnetsOutput.Subnets)).To(BeNumerically(">", 0)) | ||
| for _, s := range subnetsOutput.Subnets { | ||
| Expect(*s.AssignIpv6AddressOnCreation).To(BeTrue()) | ||
| } | ||
|
|
||
| By("ensuring the K8s cluster has IPv6 enabled") | ||
| var clientSet *kubernetes.Clientset | ||
| ctl, err := eks.New(&api.ProviderConfig{Region: params.Region}, clusterConfig) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| err = ctl.RefreshClusterStatus(clusterConfig) | ||
| Expect(err).ShouldNot(HaveOccurred()) | ||
| clientSet, err = ctl.NewStdClientSet(clusterConfig) | ||
| Expect(err).ShouldNot(HaveOccurred()) | ||
|
|
||
| svcName := "ipv6-service" | ||
| _, err = clientSet.CoreV1().Services("default").Create(context.TODO(), &corev1.Service{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: svcName, | ||
| }, | ||
| Spec: corev1.ServiceSpec{ | ||
| IPFamilies: []corev1.IPFamily{corev1.IPv6Protocol}, | ||
| Selector: map[string]string{"app": "ipv6"}, | ||
| Ports: []corev1.ServicePort{corev1.ServicePort{ | ||
| Protocol: corev1.ProtocolTCP, | ||
| Port: 80, | ||
| }}, | ||
| }, | ||
| }, metav1.CreateOptions{}) | ||
| Expect(err).ShouldNot(HaveOccurred()) | ||
|
|
||
| Eventually(func() int { | ||
| svc, err := clientSet.CoreV1().Services("default").Get(context.TODO(), svcName, metav1.GetOptions{}) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| svcIP, err := netaddr.NewIPAddress(svc.Spec.ClusterIP) | ||
| if err != nil { | ||
| return 0 | ||
| } | ||
| return svcIP.Version() | ||
| }, 5*time.Second, time.Minute).Should(Equal(6)) | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.