Skip to content

Commit fe086e6

Browse files
committed
Rebase
1 parent 3dd858f commit fe086e6

5 files changed

+365
-7
lines changed

api/v1beta2/types.go

-7
Original file line numberDiff line numberDiff line change
@@ -873,13 +873,6 @@ type Subnet struct {
873873
// within this subnet (for example, `bminstance1.subnet123.vcn1.oraclevcn.com`).
874874
// +optional
875875
DnsLabel *string `json:"dnsLabel,omitempty"`
876-
877-
// Use this to enable IPv6 hextet for this subnet. The VCN must be enabled for IPv6.
878-
// You can't change this subnet characteristic later. All subnets are /64 in size. The subnet
879-
// portion of the IPv6 address is the fourth hextet from the left (1111 in the following example).
880-
// Example: `2001:0db8:0123:1111::/64`
881-
// +optional
882-
Ipv6CidrBlockHextet *string `json:"ipv6CidrBlockHextet,omitempty"`
883876
}
884877

885878
// NSG defines configuration for a Network Security Group.

cloud/scope/subnet_reconciler.go

+32
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ package scope
1818

1919
import (
2020
"context"
21+
<<<<<<< HEAD
22+
=======
23+
"flag"
24+
>>>>>>> 62b4eb0d (added ipv6 feature, ipv6 and paravirtualized templates)
2125
"fmt"
2226
"net"
2327
"strings"
@@ -106,6 +110,7 @@ func (s *ClusterScope) CreateSubnet(ctx context.Context, spec infrastructurev1be
106110
}
107111

108112
resp, err := s.VCNClient.GetVcn(ctx, core.GetVcnRequest{VcnId: s.getVcnId()})
113+
<<<<<<< HEAD
109114

110115
var ipv6subnetCIDR_Ptr *string
111116

@@ -133,6 +138,29 @@ func (s *ClusterScope) CreateSubnet(ctx context.Context, spec infrastructurev1be
133138
ipv6subnetCIDR_Ptr = &ipv6subnetCIDR
134139
}
135140

141+
=======
142+
vcnCIDR := resp.Vcn.Ipv6CidrBlocks[0]
143+
144+
ip, _, err := net.ParseCIDR(vcnCIDR)
145+
if err != nil {
146+
panic(err)
147+
}
148+
149+
// Split into hextets
150+
hextets := strings.Split(ip.String(), ":")
151+
152+
// Modify the 4th hextet (index 3)
153+
originalHextet := hextets[3]
154+
if len(originalHextet) < 4 {
155+
originalHextet = fmt.Sprintf("%04s", originalHextet) // pad with leading zeros if needed
156+
}
157+
newHextet := originalHextet[:2] + *spec.Ipv6CidrBlockHextet
158+
hextets[3] = newHextet
159+
160+
// Reconstruct the IPv6 address with a /64 CIDR
161+
subnetCIDR := flag.String("Subnet CIDR", strings.Join(hextets, ":")+"/64", "Subnet CIDR block")
162+
163+
>>>>>>> 62b4eb0d (added ipv6 feature, ipv6 and paravirtualized templates)
136164
createSubnetDetails := core.CreateSubnetDetails{
137165
CompartmentId: common.String(s.GetCompartmentId()),
138166
CidrBlock: common.String(spec.CIDR),
@@ -144,7 +172,11 @@ func (s *ClusterScope) CreateSubnet(ctx context.Context, spec infrastructurev1be
144172
FreeformTags: s.GetFreeFormTags(),
145173
DefinedTags: s.GetDefinedTags(),
146174
DnsLabel: spec.DnsLabel,
175+
<<<<<<< HEAD
147176
Ipv6CidrBlock: ipv6subnetCIDR_Ptr,
177+
=======
178+
Ipv6CidrBlock: subnetCIDR,
179+
>>>>>>> 62b4eb0d (added ipv6 feature, ipv6 and paravirtualized templates)
148180
}
149181

150182
if spec.SecurityList != nil {

config/crd/bases/infrastructure.cluster.x-k8s.io_ociclusters.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,18 @@ spec:
597597
DNS label to form a fully qualified domain name (FQDN)
598598
for each VNIC within this subnet (for example, `bminstance1.subnet123.vcn1.oraclevcn.com`).
599599
type: string
600+
<<<<<<< HEAD
600601
ipv6CidrBlockHextet:
601602
description: Subnet IPv6 CIDR.
602603
type: string
604+
=======
605+
<<<<<<< HEAD
606+
=======
607+
ipv6CidrBlockHextet:
608+
description: Subnet IPv6 CIDR.
609+
type: string
610+
>>>>>>> 76d14f28 (added ipv6 feature, ipv6 and paravirtualized templates)
611+
>>>>>>> 62b4eb0d (added ipv6 feature, ipv6 and paravirtualized templates)
603612
id:
604613
description: Subnet OCID.
605614
type: string
@@ -1881,9 +1890,18 @@ spec:
18811890
DNS label to form a fully qualified domain name (FQDN)
18821891
for each VNIC within this subnet (for example, `bminstance1.subnet123.vcn1.oraclevcn.com`).
18831892
type: string
1893+
<<<<<<< HEAD
1894+
ipv6CidrBlockHextet:
1895+
description: Subnet IPv6 CIDR.
1896+
type: string
1897+
=======
1898+
<<<<<<< HEAD
1899+
=======
18841900
ipv6CidrBlockHextet:
18851901
description: Subnet IPv6 CIDR.
18861902
type: string
1903+
>>>>>>> 76d14f28 (added ipv6 feature, ipv6 and paravirtualized templates)
1904+
>>>>>>> 62b4eb0d (added ipv6 feature, ipv6 and paravirtualized templates)
18871905
id:
18881906
description: Subnet OCID.
18891907
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
labels:
5+
cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}"
6+
name: "${CLUSTER_NAME}"
7+
namespace: "${NAMESPACE}"
8+
spec:
9+
clusterNetwork:
10+
pods:
11+
cidrBlocks:
12+
- ${POD_CIDR:="192.168.0.0/16"}
13+
serviceDomain: ${SERVICE_DOMAIN:="cluster.local"}
14+
services:
15+
cidrBlocks:
16+
- ${SERVICE_CIDR:="10.128.0.0/12"}
17+
infrastructureRef:
18+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
19+
kind: OCICluster
20+
name: "${CLUSTER_NAME}"
21+
namespace: "${NAMESPACE}"
22+
controlPlaneRef:
23+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
24+
kind: KubeadmControlPlane
25+
name: "${CLUSTER_NAME}-control-plane"
26+
namespace: "${NAMESPACE}"
27+
---
28+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
29+
kind: OCICluster
30+
metadata:
31+
labels:
32+
cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}"
33+
name: "${CLUSTER_NAME}"
34+
spec:
35+
compartmentId: "${OCI_COMPARTMENT_ID}"
36+
networkSpec:
37+
vcn:
38+
isIpv6Enabled: true
39+
isOracleGuaAllocationEnabled: true
40+
subnets:
41+
- ipv6CidrBlockHextet: "01"
42+
name: control-plane-endpoint
43+
role: control-plane-endpoint
44+
type: public
45+
- ipv6CidrBlockHextet: "02"
46+
name: control-plane
47+
role: control-plane
48+
type: private
49+
- ipv6CidrBlockHextet: "03"
50+
name: service-lb
51+
role: service-lb
52+
type: public
53+
- ipv6CidrBlockHextet: "04"
54+
name: worker
55+
role: worker
56+
type: private
57+
---
58+
kind: KubeadmControlPlane
59+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
60+
metadata:
61+
name: "${CLUSTER_NAME}-control-plane"
62+
namespace: "${NAMESPACE}"
63+
spec:
64+
version: "${KUBERNETES_VERSION}"
65+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
66+
machineTemplate:
67+
infrastructureRef:
68+
kind: OCIMachineTemplate
69+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
70+
name: "${CLUSTER_NAME}-control-plane"
71+
namespace: "${NAMESPACE}"
72+
kubeadmConfigSpec:
73+
clusterConfiguration:
74+
kubernetesVersion: ${KUBERNETES_VERSION}
75+
apiServer:
76+
certSANs: [localhost, 127.0.0.1]
77+
dns: {}
78+
etcd: {}
79+
networking: {}
80+
scheduler: {}
81+
initConfiguration:
82+
nodeRegistration:
83+
criSocket: /var/run/containerd/containerd.sock
84+
kubeletExtraArgs:
85+
cloud-provider: external
86+
provider-id: oci://{{ ds["id"] }}
87+
joinConfiguration:
88+
discovery: {}
89+
nodeRegistration:
90+
criSocket: /var/run/containerd/containerd.sock
91+
kubeletExtraArgs:
92+
cloud-provider: external
93+
provider-id: oci://{{ ds["id"] }}
94+
---
95+
kind: OCIMachineTemplate
96+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
97+
metadata:
98+
name: "${CLUSTER_NAME}-control-plane"
99+
spec:
100+
template:
101+
spec:
102+
imageId: "${OCI_IMAGE_ID}"
103+
compartmentId: "${OCI_COMPARTMENT_ID}"
104+
shape: "${OCI_CONTROL_PLANE_MACHINE_TYPE=VM.Standard.E5.Flex}"
105+
shapeConfig:
106+
ocpus: "${OCI_CONTROL_PLANE_MACHINE_TYPE_OCPUS=1}"
107+
metadata:
108+
ssh_authorized_keys: "${OCI_SSH_KEY}"
109+
isPvEncryptionInTransitEnabled: ${OCI_CONTROL_PLANE_PV_TRANSIT_ENCRYPTION=true}
110+
networkDetails:
111+
assignIpv6Ip: true
112+
---
113+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
114+
kind: OCIMachineTemplate
115+
metadata:
116+
name: "${CLUSTER_NAME}-md-0"
117+
spec:
118+
template:
119+
spec:
120+
imageId: "${OCI_IMAGE_ID}"
121+
compartmentId: "${OCI_COMPARTMENT_ID}"
122+
shape: "${OCI_NODE_MACHINE_TYPE=VM.Standard.E5.Flex}"
123+
shapeConfig:
124+
ocpus: "${OCI_NODE_MACHINE_TYPE_OCPUS=1}"
125+
metadata:
126+
ssh_authorized_keys: "${OCI_SSH_KEY}"
127+
isPvEncryptionInTransitEnabled: ${OCI_NODE_PV_TRANSIT_ENCRYPTION=true}
128+
networkDetails:
129+
assignIpv6Ip: true
130+
---
131+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
132+
kind: KubeadmConfigTemplate
133+
metadata:
134+
name: "${CLUSTER_NAME}-md-0"
135+
spec:
136+
template:
137+
spec:
138+
joinConfiguration:
139+
nodeRegistration:
140+
kubeletExtraArgs:
141+
cloud-provider: external
142+
provider-id: oci://{{ ds["id"] }}
143+
---
144+
apiVersion: cluster.x-k8s.io/v1beta1
145+
kind: MachineDeployment
146+
metadata:
147+
name: "${CLUSTER_NAME}-md-0"
148+
spec:
149+
clusterName: "${CLUSTER_NAME}"
150+
replicas: ${NODE_MACHINE_COUNT}
151+
selector:
152+
matchLabels:
153+
template:
154+
spec:
155+
clusterName: "${CLUSTER_NAME}"
156+
version: "${KUBERNETES_VERSION}"
157+
bootstrap:
158+
configRef:
159+
name: "${CLUSTER_NAME}-md-0"
160+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
161+
kind: KubeadmConfigTemplate
162+
infrastructureRef:
163+
name: "${CLUSTER_NAME}-md-0"
164+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
165+
kind: OCIMachineTemplate

0 commit comments

Comments
 (0)