Skip to content

Commit ca0154a

Browse files
author
Christopher Haar
authored
Merge pull request #1627 from liubog2008/add-svc-cidr
feat(eks): add kubernetes network config support
2 parents cbc5c75 + d13fa49 commit ca0154a

4 files changed

Lines changed: 208 additions & 0 deletions

File tree

apis/eks/v1beta1/types.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ type ClusterParameters struct {
6262
// +optional
6363
EncryptionConfig []EncryptionConfig `json:"encryptionConfig,omitempty"`
6464

65+
// The Kubernetes network configuration for the cluster.
66+
// +immutable
67+
// +optional
68+
KubernetesNetworkConfig *KubernetesNetworkConfigRequest `json:"kubernetesNetworkConfig,omitempty"`
69+
6570
// Enable or disable exporting the Kubernetes control plane logs for your cluster
6671
// to CloudWatch Logs. By default, cluster control plane logs aren't exported
6772
// to CloudWatch Logs. For more information, see Amazon EKS Cluster Control
@@ -151,6 +156,55 @@ type Provider struct {
151156
KeyArn string `json:"keyArn"`
152157
}
153158

159+
// IPFamily specifies the ip family
160+
type IPFamily string
161+
162+
const (
163+
// IPFamilyIpv4 means ipv4
164+
IPFamilyIpv4 IPFamily = "ipv4"
165+
// IPFamilyIpv6 means ipv6
166+
IPFamilyIpv6 IPFamily = "ipv6"
167+
)
168+
169+
// KubernetesNetworkConfigRequest specifies the Kubernetes network configuration for the cluster.
170+
type KubernetesNetworkConfigRequest struct {
171+
// Specify which IP family is used to assign Kubernetes pod and service IP
172+
// addresses. If you don't specify a value, ipv4 is used by default. You can only
173+
// specify an IP family when you create a cluster and can't change this value once
174+
// the cluster is created. If you specify ipv6, the VPC and subnets that you
175+
// specify for cluster creation must have both IPv4 and IPv6 CIDR blocks assigned
176+
// to them. You can't specify ipv6 for clusters in China Regions. You can only
177+
// specify ipv6 for 1.21 and later clusters that use version 1.10.1 or later of the
178+
// Amazon VPC CNI add-on. If you specify ipv6, then ensure that your VPC meets the
179+
// requirements listed in the considerations listed in Assigning IPv6 addresses to
180+
// pods and services
181+
// (https://docs.aws.amazon.com/eks/latest/userguide/cni-ipv6.html) in the Amazon
182+
// EKS User Guide. Kubernetes assigns services IPv6 addresses from the unique local
183+
// address range (fc00::/7). You can't specify a custom IPv6 CIDR block. Pod
184+
// addresses are assigned from the subnet's IPv6 CIDR.
185+
IPFamily IPFamily `json:"ipFamily"`
186+
187+
// Don't specify a value if you select ipv6 for ipFamily. The CIDR block to assign
188+
// Kubernetes service IP addresses from. If you don't specify a block, Kubernetes
189+
// assigns addresses from either the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks. We
190+
// recommend that you specify a block that does not overlap with resources in other
191+
// networks that are peered or connected to your VPC. The block must meet the
192+
// following requirements:
193+
//
194+
// * Within one of the following private IP address
195+
// blocks: 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16.
196+
//
197+
// * Doesn't overlap with
198+
// any CIDR block assigned to the VPC that you selected for VPC.
199+
//
200+
// * Between /24 and
201+
// /12.
202+
//
203+
// You can only specify a custom CIDR block when you create a cluster and
204+
// can't change this value once the cluster is created.
205+
ServiceIpv4Cidr string `json:"serviceIpv4Cidr,omitempty"`
206+
}
207+
154208
// Logging in the logging configuration for a cluster.
155209
type Logging struct {
156210
// The cluster control plane logging configuration for your cluster.
@@ -277,6 +331,9 @@ type ClusterObservation struct {
277331
// Amazon Web Services cloud.
278332
OutpostConfig OutpostConfigResponse `json:"outpostConfig,omitempty"`
279333

334+
// The Kubernetes network configuration for the cluster.
335+
KubernetesNetworkConfig KubernetesNetworkConfigResponse `json:"kubernetesNetworkConfig,omitempty"`
336+
280337
// The VPC configuration used by the cluster control plane. Amazon EKS VPC resources
281338
// have specific requirements to work properly with Kubernetes. For more information,
282339
// see Cluster VPC Considerations (https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html)
@@ -351,6 +408,32 @@ type OutpostConfigResponse struct {
351408
// contains filtered or unexported fields
352409
}
353410

411+
// KubernetesNetworkConfigResponse specifies the Kubernetes network configuration for the cluster.
412+
// The response contains a value for serviceIpv6Cidr or serviceIpv4Cidr, but not both.
413+
type KubernetesNetworkConfigResponse struct {
414+
// The IP family used to assign Kubernetes pod and service IP addresses. The IP
415+
// family is always ipv4, unless you have a 1.21 or later cluster running version
416+
// 1.10.1 or later of the Amazon VPC CNI add-on and specified ipv6 when you created
417+
// the cluster.
418+
IPFamily IPFamily `json:"ipFamily,omitempty"`
419+
420+
// The CIDR block that Kubernetes pod and service IP addresses are assigned from.
421+
// Kubernetes assigns addresses from an IPv4 CIDR block assigned to a subnet that
422+
// the node is in. If you didn't specify a CIDR block when you created the cluster,
423+
// then Kubernetes assigns addresses from either the 10.100.0.0/16 or 172.20.0.0/16
424+
// CIDR blocks. If this was specified, then it was specified when the cluster was
425+
// created and it can't be changed.
426+
ServiceIpv4Cidr string `json:"serviceIpv4Cidr,omitempty"`
427+
428+
// The CIDR block that Kubernetes pod and service IP addresses are assigned from if
429+
// you created a 1.21 or later cluster with version 1.10.1 or later of the Amazon
430+
// VPC CNI add-on and specified ipv6 for ipFamily when you created the cluster.
431+
// Kubernetes assigns service addresses from the unique local address range
432+
// (fc00::/7) because you can't specify a custom IPv6 CIDR block when you create
433+
// the cluster.
434+
ServiceIpv6Cidr string `json:"serviceIpv6Cidr,omitempty"`
435+
}
436+
354437
// VpcConfigResponse is the observed VPC configuration for a cluster.
355438
type VpcConfigResponse struct {
356439
// The cluster security group that was created by Amazon EKS for the cluster.

apis/eks/v1beta1/zz_generated.deepcopy.go

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

package/crds/eks.aws.crossplane.io_clusters.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,47 @@ spec:
9797
- resources
9898
type: object
9999
type: array
100+
kubernetesNetworkConfig:
101+
description: The Kubernetes network configuration for the cluster.
102+
properties:
103+
ipFamily:
104+
description: Specify which IP family is used to assign Kubernetes
105+
pod and service IP addresses. If you don't specify a value,
106+
ipv4 is used by default. You can only specify an IP family
107+
when you create a cluster and can't change this value once
108+
the cluster is created. If you specify ipv6, the VPC and
109+
subnets that you specify for cluster creation must have
110+
both IPv4 and IPv6 CIDR blocks assigned to them. You can't
111+
specify ipv6 for clusters in China Regions. You can only
112+
specify ipv6 for 1.21 and later clusters that use version
113+
1.10.1 or later of the Amazon VPC CNI add-on. If you specify
114+
ipv6, then ensure that your VPC meets the requirements listed
115+
in the considerations listed in Assigning IPv6 addresses
116+
to pods and services (https://docs.aws.amazon.com/eks/latest/userguide/cni-ipv6.html)
117+
in the Amazon EKS User Guide. Kubernetes assigns services
118+
IPv6 addresses from the unique local address range (fc00::/7).
119+
You can't specify a custom IPv6 CIDR block. Pod addresses
120+
are assigned from the subnet's IPv6 CIDR.
121+
type: string
122+
serviceIpv4Cidr:
123+
description: "Don't specify a value if you select ipv6 for
124+
ipFamily. The CIDR block to assign Kubernetes service IP
125+
addresses from. If you don't specify a block, Kubernetes
126+
assigns addresses from either the 10.100.0.0/16 or 172.20.0.0/16
127+
CIDR blocks. We recommend that you specify a block that
128+
does not overlap with resources in other networks that are
129+
peered or connected to your VPC. The block must meet the
130+
following requirements: \n * Within one of the following
131+
private IP address blocks: 10.0.0.0/8, 172.16.0.0/12, or
132+
192.168.0.0/16. \n * Doesn't overlap with any CIDR block
133+
assigned to the VPC that you selected for VPC. \n * Between
134+
/24 and /12. \n You can only specify a custom CIDR block
135+
when you create a cluster and can't change this value once
136+
the cluster is created."
137+
type: string
138+
required:
139+
- ipFamily
140+
type: object
100141
logging:
101142
description: "Enable or disable exporting the Kubernetes control
102143
plane logs for your cluster to CloudWatch Logs. By default,
@@ -697,6 +738,37 @@ spec:
697738
type: string
698739
type: object
699740
type: object
741+
kubernetesNetworkConfig:
742+
description: The Kubernetes network configuration for the cluster.
743+
properties:
744+
ipFamily:
745+
description: The IP family used to assign Kubernetes pod and
746+
service IP addresses. The IP family is always ipv4, unless
747+
you have a 1.21 or later cluster running version 1.10.1
748+
or later of the Amazon VPC CNI add-on and specified ipv6
749+
when you created the cluster.
750+
type: string
751+
serviceIpv4Cidr:
752+
description: The CIDR block that Kubernetes pod and service
753+
IP addresses are assigned from. Kubernetes assigns addresses
754+
from an IPv4 CIDR block assigned to a subnet that the node
755+
is in. If you didn't specify a CIDR block when you created
756+
the cluster, then Kubernetes assigns addresses from either
757+
the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks. If this
758+
was specified, then it was specified when the cluster was
759+
created and it can't be changed.
760+
type: string
761+
serviceIpv6Cidr:
762+
description: The CIDR block that Kubernetes pod and service
763+
IP addresses are assigned from if you created a 1.21 or
764+
later cluster with version 1.10.1 or later of the Amazon
765+
VPC CNI add-on and specified ipv6 for ipFamily when you
766+
created the cluster. Kubernetes assigns service addresses
767+
from the unique local address range (fc00::/7) because you
768+
can't specify a custom IPv6 CIDR block when you create the
769+
cluster.
770+
type: string
771+
type: object
700772
outpostConfig:
701773
description: An object representing the configuration of your
702774
local Amazon EKS cluster on an Amazon Web Services Outpost.

pkg/clients/eks/eks.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ func GenerateCreateClusterInput(name string, p *v1beta1.ClusterParameters) *eks.
122122
c.EncryptionConfig = GenerateEncryptionConfig(p)
123123
}
124124

125+
if p.KubernetesNetworkConfig != nil {
126+
c.KubernetesNetworkConfig = &ekstypes.KubernetesNetworkConfigRequest{
127+
IpFamily: ekstypes.IpFamily(p.KubernetesNetworkConfig.IPFamily),
128+
}
129+
if p.KubernetesNetworkConfig.ServiceIpv4Cidr != "" {
130+
c.KubernetesNetworkConfig.ServiceIpv4Cidr = awsclients.String(p.KubernetesNetworkConfig.ServiceIpv4Cidr)
131+
}
132+
}
133+
125134
c.ResourcesVpcConfig = &ekstypes.VpcConfigRequest{
126135
EndpointPrivateAccess: p.ResourcesVpcConfig.EndpointPrivateAccess,
127136
EndpointPublicAccess: p.ResourcesVpcConfig.EndpointPublicAccess,
@@ -257,6 +266,14 @@ func GenerateObservation(cluster *ekstypes.Cluster) v1beta1.ClusterObservation {
257266
}
258267
}
259268

269+
if cluster.KubernetesNetworkConfig != nil {
270+
o.KubernetesNetworkConfig = v1beta1.KubernetesNetworkConfigResponse{
271+
IPFamily: v1beta1.IPFamily(cluster.KubernetesNetworkConfig.IpFamily),
272+
ServiceIpv4Cidr: awsclients.StringValue(cluster.KubernetesNetworkConfig.ServiceIpv4Cidr),
273+
ServiceIpv6Cidr: awsclients.StringValue(cluster.KubernetesNetworkConfig.ServiceIpv6Cidr),
274+
}
275+
}
276+
260277
if cluster.ResourcesVpcConfig != nil {
261278
o.ResourcesVpcConfig = v1beta1.VpcConfigResponse{
262279
ClusterSecurityGroupID: awsclients.StringValue(cluster.ResourcesVpcConfig.ClusterSecurityGroupId),

0 commit comments

Comments
 (0)