Skip to content

Commit 8ddb794

Browse files
authored
Fix dual-stack for self-managed nodes and NPN (#1048)
1 parent 816b5a3 commit 8ddb794

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

module-workers.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ module "workers" {
7878
worker_nsg_ids = concat(var.worker_nsg_ids, [try(module.network.worker_nsg_id, null)])
7979
worker_subnet_id = try(module.network.worker_subnet_id, "") # safe destroy; validated in submodule
8080
preemptible_config = var.worker_preemptible_config
81+
enable_ipv6 = var.enable_ipv6
8182

8283
# Tagging
8384
tag_namespace = var.tag_namespace

modules/workers/instance.tf

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ resource "oci_core_instance" "workers" {
6161

6262
create_vnic_details {
6363
assign_private_dns_record = var.assign_dns
64+
assign_ipv6ip = each.value.assign_ipv6ip
6465
assign_public_ip = each.value.assign_public_ip
6566
nsg_ids = each.value.nsg_ids
6667
subnet_id = each.value.subnet_id
@@ -86,12 +87,17 @@ resource "oci_core_instance" "workers" {
8687
},
8788

8889
# Add labels required for NPN CNI.
89-
var.cni_type == "npn" ? {
90-
oke-native-pod-networking = true
91-
oke-max-pods = var.max_pods_per_node
92-
pod-subnets = coalesce(var.pod_subnet_id, var.worker_subnet_id, "none")
93-
pod-nsgids = join(",", each.value.pod_nsg_ids)
94-
} : {},
90+
var.cni_type == "npn" ? merge(
91+
{
92+
oke-native-pod-networking = true
93+
oke-max-pods = var.max_pods_per_node
94+
pod-subnets = coalesce(var.pod_subnet_id, var.worker_subnet_id, "none")
95+
pod-nsgids = join(",", each.value.pod_nsg_ids)
96+
},
97+
var.enable_ipv6 ?
98+
{
99+
ip-families = "IPv4,IPv6"
100+
}: {} ) : {},
95101

96102
# Only provide cluster DNS service address if set explicitly; determined automatically in practice.
97103
coalesce(var.cluster_dns, "none") == "none" ? {} : { kubedns_svc_ip = var.cluster_dns },

modules/workers/instanceconfig.tf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ resource "oci_core_instance_configuration" "workers" {
4343

4444
create_vnic_details {
4545
assign_private_dns_record = var.assign_dns
46+
assign_ipv6ip = each.value.assign_ipv6ip
4647
assign_public_ip = each.value.assign_public_ip
4748
nsg_ids = each.value.nsg_ids
4849
subnet_id = each.value.subnet_id
@@ -64,12 +65,17 @@ resource "oci_core_instance_configuration" "workers" {
6465
},
6566

6667
# Add labels required for NPN CNI.
67-
var.cni_type == "npn" ? {
68-
oke-native-pod-networking = true
69-
oke-max-pods = var.max_pods_per_node
70-
pod-subnets = coalesce(var.pod_subnet_id, var.worker_subnet_id, "none")
71-
pod-nsgids = join(",", each.value.pod_nsg_ids)
72-
} : {},
68+
var.cni_type == "npn" ? merge(
69+
{
70+
oke-native-pod-networking = true
71+
oke-max-pods = var.max_pods_per_node
72+
pod-subnets = coalesce(var.pod_subnet_id, var.worker_subnet_id, "none")
73+
pod-nsgids = join(",", each.value.pod_nsg_ids)
74+
},
75+
var.enable_ipv6 ?
76+
{
77+
ip-families = "IPv4,IPv6"
78+
}: {} ) : {},
7379

7480
# Only provide cluster DNS service address if set explicitly; determined automatically in practice.
7581
coalesce(var.cluster_dns, "none") == "none" ? {} : { kubedns_svc_ip = var.cluster_dns },
@@ -154,6 +160,7 @@ resource "oci_core_instance_configuration" "workers" {
154160

155161
create_vnic_details {
156162
assign_private_dns_record = lookup(vnic.value, "assign_private_dns_record", null)
163+
assign_ipv6ip = lookup(vnic.value, "assign_ipv6ip", null)
157164
assign_public_ip = lookup(vnic.value, "assign_public_ip", null)
158165
display_name = vnic.key
159166
defined_tags = lookup(vnic.value, "defined_tags", null)

modules/workers/locals.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ locals {
2424
allow_autoscaler = false
2525
legacy_imds_endpoints_disabled = var.legacy_imds_endpoints_disabled
2626
assign_public_ip = var.assign_public_ip
27+
assign_ipv6ip = var.enable_ipv6 ? true : false
2728
autoscale = false
2829
block_volume_type = var.block_volume_type
2930
boot_volume_size = local.boot_volume_size

modules/workers/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ variable "cni_type" {
100100
}
101101
}
102102

103+
variable "enable_ipv6" {
104+
default = false
105+
description = "Whether to create a dual-stack (IPv4/IPv6) cluster."
106+
type = bool
107+
}
108+
103109
variable "pod_subnet_id" { type = string }
104110
variable "worker_subnet_id" { type = string }
105111

@@ -340,3 +346,4 @@ variable "compute_clusters" {
340346
description = "Whether to create compute clusters shared by nodes across multiple worker pools enabled for 'compute-cluster'."
341347
type = map(any)
342348
}
349+

variables-workers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ variable "worker_compute_clusters" {
7171

7272
variable "worker_is_public" {
7373
default = false
74-
description = "Whether to provision workers with public IPs allocated by default when unspecified on a pool."
74+
description = "Whether to provision workers with public IPs allocated by default when unspecified on a pool. It should be true when creating dual-stack clusters."
7575
type = bool
7676
}
7777

0 commit comments

Comments
 (0)