Skip to content

Commit 110f084

Browse files
authored
Merge pull request #646 from jsturtevant/ipv6
✨ Add single stack IPv6 support
2 parents bc043d3 + c05182f commit 110f084

File tree

63 files changed

+2790
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2790
-228
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,12 @@ create-workload-cluster: $(ENVSUBST)
449449
timeout --foreground 600 bash -c "while ! kubectl --kubeconfig=./kubeconfig get nodes | grep master; do sleep 1; done"
450450

451451
# Deploy calico
452-
kubectl --kubeconfig=./kubeconfig apply -f templates/addons/calico.yaml
452+
@if [[ "${CLUSTER_TEMPLATE}" == *ipv6* ]]; then \
453+
kubectl --kubeconfig=./kubeconfig apply -f templates/addons/calico-ipv6.yaml; \
454+
else \
455+
kubectl --kubeconfig=./kubeconfig apply -f templates/addons/calico.yaml; \
456+
fi
457+
453458

454459
@echo 'run "kubectl --kubeconfig=./kubeconfig ..." to work with the new target cluster'
455460

api/v1alpha2/azurecluster_conversion.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ func (src *AzureCluster) ConvertTo(dstRaw conversion.Hub) error { // nolint
5959
}
6060

6161
dst.Status.FailureDomains = restored.Status.FailureDomains
62+
dst.Spec.NetworkSpec.Vnet.CIDRBlocks = restored.Spec.NetworkSpec.Vnet.CIDRBlocks
6263

6364
for _, restoredSubnet := range restored.Spec.NetworkSpec.Subnets {
6465
if restoredSubnet != nil {
6566
for _, dstSubnet := range dst.Spec.NetworkSpec.Subnets {
6667
if dstSubnet != nil && dstSubnet.Name == restoredSubnet.Name {
6768
dstSubnet.RouteTable = restoredSubnet.RouteTable
68-
69+
dstSubnet.CIDRBlocks = restoredSubnet.CIDRBlocks
6970
dstSubnet.SecurityGroup.IngressRules = restoredSubnet.SecurityGroup.IngressRules
7071
}
7172
}
@@ -203,6 +204,11 @@ func Convert_v1alpha3_NetworkSpec_To_v1alpha2_NetworkSpec(in *infrav1alpha3.Netw
203204
return nil
204205
}
205206

207+
// Convert_v1alpha3_VnetSpec_To_v1alpha2_VnetSpec.
208+
func Convert_v1alpha3_VnetSpec_To_v1alpha2_VnetSpec(in *infrav1alpha3.VnetSpec, out *VnetSpec, s apiconversion.Scope) error { //nolint
209+
return autoConvert_v1alpha3_VnetSpec_To_v1alpha2_VnetSpec(in, out, s)
210+
}
211+
206212
// Convert_v1alpha2_SubnetSpec_To_v1alpha3_SubnetSpec.
207213
func Convert_v1alpha2_SubnetSpec_To_v1alpha3_SubnetSpec(in *SubnetSpec, out *infrav1alpha3.SubnetSpec, s apiconversion.Scope) error { //nolint
208214
return autoConvert_v1alpha2_SubnetSpec_To_v1alpha3_SubnetSpec(in, out, s)

api/v1alpha2/azuremachine_conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func restoreAzureMachineSpec(restored, dst *infrav1alpha3.AzureMachineSpec) {
5757
dst.AcceleratedNetworking = restored.AcceleratedNetworking
5858
}
5959
dst.FailureDomain = restored.FailureDomain
60+
dst.EnableIPForwarding = restored.EnableIPForwarding
6061
if restored.SpotVMOptions != nil {
6162
dst.SpotVMOptions = restored.SpotVMOptions.DeepCopy()
6263
}

api/v1alpha2/zz_generated.conversion.go

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

api/v1alpha3/azurecluster_default.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ const (
2929
DefaultNodeSubnetCIDR = "10.1.0.0/16"
3030
)
3131

32+
const (
33+
// DefaultVnetIPv6CIDR is the ipv6 Vnet CIDR
34+
DefaultVnetIPv6CIDR = "2001:1234:5678:9a00::/56"
35+
// DefaultControlPlaneSubnetIPv6CIDR is the default Control Plane Subnet CIDR
36+
DefaultControlPlaneSubnetIPv6CIDR = "2001:1234:5678:9abc::/64"
37+
// DefaultNodeSubnetIPv6CIDR is the default Node Subnet CIDR
38+
DefaultNodeSubnetIPv6CIDR = "2001:1234:5678:9abd::/64"
39+
)
40+
3241
func (c *AzureCluster) setDefaults() {
3342
c.setNetworkSpecDefaults()
3443
}
@@ -52,8 +61,8 @@ func (c *AzureCluster) setVnetDefaults() {
5261
if c.Spec.NetworkSpec.Vnet.Name == "" {
5362
c.Spec.NetworkSpec.Vnet.Name = generateVnetName(c.ObjectMeta.Name)
5463
}
55-
if c.Spec.NetworkSpec.Vnet.CidrBlock == "" {
56-
c.Spec.NetworkSpec.Vnet.CidrBlock = DefaultVnetCIDR
64+
if len(c.Spec.NetworkSpec.Vnet.CIDRBlocks) == 0 {
65+
c.Spec.NetworkSpec.Vnet.CIDRBlocks = []string{DefaultVnetCIDR}
5766
}
5867
}
5968

@@ -73,8 +82,8 @@ func (c *AzureCluster) setSubnetDefaults() {
7382
if cpSubnet.Name == "" {
7483
cpSubnet.Name = generateControlPlaneSubnetName(c.ObjectMeta.Name)
7584
}
76-
if cpSubnet.CidrBlock == "" {
77-
cpSubnet.CidrBlock = DefaultControlPlaneSubnetCIDR
85+
if len(cpSubnet.CIDRBlocks) == 0 {
86+
cpSubnet.CIDRBlocks = []string{DefaultControlPlaneSubnetCIDR}
7887
}
7988
if cpSubnet.SecurityGroup.Name == "" {
8089
cpSubnet.SecurityGroup.Name = generateControlPlaneSecurityGroupName(c.ObjectMeta.Name)
@@ -86,8 +95,8 @@ func (c *AzureCluster) setSubnetDefaults() {
8695
if nodeSubnet.Name == "" {
8796
nodeSubnet.Name = generateNodeSubnetName(c.ObjectMeta.Name)
8897
}
89-
if nodeSubnet.CidrBlock == "" {
90-
nodeSubnet.CidrBlock = DefaultNodeSubnetCIDR
98+
if len(nodeSubnet.CIDRBlocks) == 0 {
99+
nodeSubnet.CIDRBlocks = []string{DefaultNodeSubnetCIDR}
91100
}
92101
if nodeSubnet.SecurityGroup.Name == "" {
93102
nodeSubnet.SecurityGroup.Name = generateNodeSecurityGroupName(c.ObjectMeta.Name)

api/v1alpha3/azurecluster_default_test.go

Lines changed: 104 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestVnetDefaults(t *testing.T) {
9898
Vnet: VnetSpec{
9999
ResourceGroup: "custom-vnet",
100100
Name: "my-vnet",
101-
CidrBlock: DefaultVnetCIDR,
101+
CIDRBlocks: []string{DefaultVnetCIDR},
102102
},
103103
Subnets: Subnets{
104104
{
@@ -138,7 +138,7 @@ func TestVnetDefaults(t *testing.T) {
138138
Vnet: VnetSpec{
139139
ResourceGroup: "cluster-test",
140140
Name: "cluster-test-vnet",
141-
CidrBlock: DefaultVnetCIDR,
141+
CIDRBlocks: []string{DefaultVnetCIDR},
142142
},
143143
},
144144
},
@@ -154,7 +154,7 @@ func TestVnetDefaults(t *testing.T) {
154154
ResourceGroup: "cluster-test",
155155
NetworkSpec: NetworkSpec{
156156
Vnet: VnetSpec{
157-
CidrBlock: "10.0.0.0/16",
157+
CIDRBlocks: []string{"10.0.0.0/16"},
158158
},
159159
},
160160
},
@@ -169,7 +169,38 @@ func TestVnetDefaults(t *testing.T) {
169169
Vnet: VnetSpec{
170170
ResourceGroup: "cluster-test",
171171
Name: "cluster-test-vnet",
172-
CidrBlock: "10.0.0.0/16",
172+
CIDRBlocks: []string{"10.0.0.0/16"},
173+
},
174+
},
175+
},
176+
},
177+
},
178+
{
179+
name: "IPv6 enabled",
180+
cluster: &AzureCluster{
181+
ObjectMeta: v1.ObjectMeta{
182+
Name: "cluster-test",
183+
},
184+
Spec: AzureClusterSpec{
185+
ResourceGroup: "cluster-test",
186+
NetworkSpec: NetworkSpec{
187+
Vnet: VnetSpec{
188+
CIDRBlocks: []string{DefaultVnetCIDR, DefaultVnetIPv6CIDR},
189+
},
190+
},
191+
},
192+
},
193+
output: &AzureCluster{
194+
ObjectMeta: v1.ObjectMeta{
195+
Name: "cluster-test",
196+
},
197+
Spec: AzureClusterSpec{
198+
ResourceGroup: "cluster-test",
199+
NetworkSpec: NetworkSpec{
200+
Vnet: VnetSpec{
201+
ResourceGroup: "cluster-test",
202+
Name: "cluster-test-vnet",
203+
CIDRBlocks: []string{DefaultVnetCIDR, DefaultVnetIPv6CIDR},
173204
},
174205
},
175206
},
@@ -217,14 +248,14 @@ func TestSubnetDefaults(t *testing.T) {
217248
{
218249
Role: SubnetControlPlane,
219250
Name: "cluster-test-controlplane-subnet",
220-
CidrBlock: DefaultControlPlaneSubnetCIDR,
251+
CIDRBlocks: []string{DefaultControlPlaneSubnetCIDR},
221252
SecurityGroup: SecurityGroup{Name: "cluster-test-controlplane-nsg"},
222253
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
223254
},
224255
{
225256
Role: SubnetNode,
226257
Name: "cluster-test-node-subnet",
227-
CidrBlock: DefaultNodeSubnetCIDR,
258+
CIDRBlocks: []string{DefaultNodeSubnetCIDR},
228259
SecurityGroup: SecurityGroup{Name: "cluster-test-node-nsg"},
229260
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
230261
},
@@ -243,14 +274,14 @@ func TestSubnetDefaults(t *testing.T) {
243274
NetworkSpec: NetworkSpec{
244275
Subnets: Subnets{
245276
{
246-
Role: SubnetControlPlane,
247-
Name: "my-controlplane-subnet",
248-
CidrBlock: "10.0.0.16/24",
277+
Role: SubnetControlPlane,
278+
Name: "my-controlplane-subnet",
279+
CIDRBlocks: []string{"10.0.0.16/24"},
249280
},
250281
{
251-
Role: SubnetNode,
252-
Name: "my-node-subnet",
253-
CidrBlock: "10.1.0.16/24",
282+
Role: SubnetNode,
283+
Name: "my-node-subnet",
284+
CIDRBlocks: []string{"10.1.0.16/24"},
254285
},
255286
},
256287
},
@@ -266,14 +297,14 @@ func TestSubnetDefaults(t *testing.T) {
266297
{
267298
Role: SubnetControlPlane,
268299
Name: "my-controlplane-subnet",
269-
CidrBlock: "10.0.0.16/24",
300+
CIDRBlocks: []string{"10.0.0.16/24"},
270301
SecurityGroup: SecurityGroup{Name: "cluster-test-controlplane-nsg"},
271302
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
272303
},
273304
{
274305
Role: SubnetNode,
275306
Name: "my-node-subnet",
276-
CidrBlock: "10.1.0.16/24",
307+
CIDRBlocks: []string{"10.1.0.16/24"},
277308
SecurityGroup: SecurityGroup{Name: "cluster-test-node-nsg"},
278309
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
279310
},
@@ -313,14 +344,14 @@ func TestSubnetDefaults(t *testing.T) {
313344
{
314345
Role: SubnetControlPlane,
315346
Name: "cluster-test-controlplane-subnet",
316-
CidrBlock: DefaultControlPlaneSubnetCIDR,
347+
CIDRBlocks: []string{DefaultControlPlaneSubnetCIDR},
317348
SecurityGroup: SecurityGroup{Name: "cluster-test-controlplane-nsg"},
318349
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
319350
},
320351
{
321352
Role: SubnetNode,
322353
Name: "cluster-test-node-subnet",
323-
CidrBlock: DefaultNodeSubnetCIDR,
354+
CIDRBlocks: []string{DefaultNodeSubnetCIDR},
324355
SecurityGroup: SecurityGroup{Name: "cluster-test-node-nsg"},
325356
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
326357
},
@@ -356,17 +387,72 @@ func TestSubnetDefaults(t *testing.T) {
356387
{
357388
Role: SubnetNode,
358389
Name: "my-node-subnet",
359-
CidrBlock: DefaultNodeSubnetCIDR,
390+
CIDRBlocks: []string{DefaultNodeSubnetCIDR},
360391
SecurityGroup: SecurityGroup{Name: "cluster-test-node-nsg"},
361392
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
362393
},
363394
{
364395
Role: SubnetControlPlane,
365396
Name: "cluster-test-controlplane-subnet",
366-
CidrBlock: DefaultControlPlaneSubnetCIDR,
397+
CIDRBlocks: []string{DefaultControlPlaneSubnetCIDR},
398+
SecurityGroup: SecurityGroup{Name: "cluster-test-controlplane-nsg"},
399+
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
400+
},
401+
},
402+
},
403+
},
404+
},
405+
},
406+
{
407+
name: "subnets specified with IPv6 enabled",
408+
cluster: &AzureCluster{
409+
ObjectMeta: v1.ObjectMeta{
410+
Name: "cluster-test",
411+
},
412+
Spec: AzureClusterSpec{
413+
NetworkSpec: NetworkSpec{
414+
Vnet: VnetSpec{
415+
CIDRBlocks: []string{"2001:be00::1/56"},
416+
},
417+
Subnets: Subnets{
418+
{
419+
Name: "cluster-test-controlplane-subnet",
420+
Role: "control-plane",
421+
CIDRBlocks: []string{"2001:beef::1/64"},
422+
},
423+
{
424+
Name: "cluster-test-node-subnet",
425+
Role: "node",
426+
CIDRBlocks: []string{"2001:beea::1/64"},
427+
},
428+
},
429+
},
430+
},
431+
},
432+
output: &AzureCluster{
433+
ObjectMeta: v1.ObjectMeta{
434+
Name: "cluster-test",
435+
},
436+
Spec: AzureClusterSpec{
437+
NetworkSpec: NetworkSpec{
438+
Vnet: VnetSpec{
439+
CIDRBlocks: []string{"2001:be00::1/56"},
440+
},
441+
Subnets: Subnets{
442+
{
443+
Role: SubnetControlPlane,
444+
Name: "cluster-test-controlplane-subnet",
445+
CIDRBlocks: []string{"2001:beef::1/64"},
367446
SecurityGroup: SecurityGroup{Name: "cluster-test-controlplane-nsg"},
368447
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
369448
},
449+
{
450+
Role: SubnetNode,
451+
Name: "cluster-test-node-subnet",
452+
CIDRBlocks: []string{"2001:beea::1/64"},
453+
SecurityGroup: SecurityGroup{Name: "cluster-test-node-nsg"},
454+
RouteTable: RouteTable{Name: "cluster-test-node-routetable"},
455+
},
370456
},
371457
},
372458
},

api/v1alpha3/azuremachine_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ type AzureMachineSpec struct {
8787
// +optional
8888
AllocatePublicIP bool `json:"allocatePublicIP,omitempty"`
8989

90+
// EnableIPForwarding enables IP Forwarding in Azure which is required for some CNI's to send traffic from a pods on one machine
91+
// to another. This is required for IpV6 with Calico in combination with User Defined Routes (set by the Azure Cloud Controller
92+
// manager). Default is false for disabled.
93+
// +optional
94+
EnableIPForwarding bool `json:"enableIPForwarding,omitempty"`
95+
9096
// AcceleratedNetworking enables or disables Azure accelerated networking. If omitted, it will be set based on
9197
// whether the requested VMSize supports accelerated networking.
9298
// If AcceleratedNetworking is set to true with a VMSize that does not support it, Azure will return an error.

0 commit comments

Comments
 (0)