Skip to content
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

Repair AL2023 with IPv6 node creation #8120

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,10 @@ type KubernetesNetworkConfig struct {
// Valid variants are `IPFamily` constants
// +optional
IPFamily string `json:"ipFamily,omitempty"`
// ServiceIPv4CIDR is the CIDR range from where `ClusterIP`s are assigned
// ServiceIPv4CIDR is the IPv4 CIDR range from where `ClusterIP`s are assigned
ServiceIPv4CIDR string `json:"serviceIPv4CIDR,omitempty"`
// ServiceIPv6CIDR is the IPv6 CIDR range from where `ClusterIP`s are assigned
ServiceIPv6CIDR string `json:"serviceIPv6CIDR,omitempty"`
}

func (k *KubernetesNetworkConfig) IPv6Enabled() bool {
Expand Down Expand Up @@ -1213,13 +1215,18 @@ func (c *ClusterConfig) IPv6Enabled() bool {

// SetClusterState updates the cluster state and populates the ClusterStatus using *eks.Cluster.
func (c *ClusterConfig) SetClusterState(cluster *ekstypes.Cluster) error {
if networkConfig := cluster.KubernetesNetworkConfig; networkConfig != nil && networkConfig.ServiceIpv4Cidr != nil {
c.Status.KubernetesNetworkConfig = &KubernetesNetworkConfig{
ServiceIPv4CIDR: *networkConfig.ServiceIpv4Cidr,
if networkConfig := cluster.KubernetesNetworkConfig; networkConfig != nil {
knc := &KubernetesNetworkConfig{}
if networkConfig.ServiceIpv4Cidr != nil {
knc.IPFamily = IPV4Family
knc.ServiceIPv4CIDR = aws.ToString(networkConfig.ServiceIpv4Cidr)
}
c.KubernetesNetworkConfig = &KubernetesNetworkConfig{
ServiceIPv4CIDR: aws.ToString(cluster.KubernetesNetworkConfig.ServiceIpv4Cidr),
if networkConfig.ServiceIpv6Cidr != nil {
knc.IPFamily = IPV6Family
knc.ServiceIPv6CIDR = aws.ToString(networkConfig.ServiceIpv6Cidr)
}
c.KubernetesNetworkConfig = knc
c.Status.KubernetesNetworkConfig = knc
}
data, err := base64.StdEncoding.DecodeString(*cluster.CertificateAuthority.Data)
if err != nil {
Expand Down
9 changes: 8 additions & 1 deletion pkg/nodebootstrap/al2023.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ func (m *AL2023) createMinimalNodeConfig() (*nodeadm.NodeConfig, error) {
}

clusterStatus := m.cfg.Status
var serviceCIDR string
if clusterStatus.KubernetesNetworkConfig.ServiceIPv6CIDR != "" {
serviceCIDR = clusterStatus.KubernetesNetworkConfig.ServiceIPv6CIDR
} else {
serviceCIDR = clusterStatus.KubernetesNetworkConfig.ServiceIPv4CIDR
}

return &nodeadm.NodeConfig{
TypeMeta: metav1.TypeMeta{
Kind: nodeadmapi.KindNodeConfig,
Expand All @@ -143,7 +150,7 @@ func (m *AL2023) createMinimalNodeConfig() (*nodeadm.NodeConfig, error) {
Name: m.cfg.Metadata.Name,
APIServerEndpoint: clusterStatus.Endpoint,
CertificateAuthority: clusterStatus.CertificateAuthorityData,
CIDR: clusterStatus.KubernetesNetworkConfig.ServiceIPv4CIDR,
CIDR: serviceCIDR,
},
Kubelet: kubeletOptions,
},
Expand Down
37 changes: 37 additions & 0 deletions pkg/nodebootstrap/al2023_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

type al2023Entry struct {
overrideClusterSettings func(*api.ClusterConfig)
overrideNodegroupSettings func(api.NodePool)
expectedUserData string
}
Expand All @@ -34,6 +35,10 @@ var _ = DescribeTable("Unmanaged AL2023", func(e al2023Entry) {
ng := api.NewNodeGroup()
makeDefaultNPSettings(ng)

if e.overrideClusterSettings != nil {
e.overrideClusterSettings(cfg)
}

if e.overrideNodegroupSettings != nil {
e.overrideNodegroupSettings(ng)
}
Expand All @@ -51,6 +56,14 @@ var _ = DescribeTable("Unmanaged AL2023", func(e al2023Entry) {
Entry("default", al2023Entry{
expectedUserData: wrapMIMEParts(xTablesLock + nodeConfig),
}),
Entry("ipv6", al2023Entry{
overrideClusterSettings: func(cc *api.ClusterConfig) {
cc.Status.KubernetesNetworkConfig.IPFamily = api.IPV6Family
cc.Status.KubernetesNetworkConfig.ServiceIPv6CIDR = "fd00:facc:76a1::/108"
cc.Status.KubernetesNetworkConfig.ServiceIPv4CIDR = ""
},
expectedUserData: wrapMIMEParts(xTablesLock + nodeConfigIPv6),
}),
Entry("efa enabled", al2023Entry{
overrideNodegroupSettings: func(np api.NodePool) {
np.BaseNodeGroup().EFAEnabled = aws.Bool(true)
Expand Down Expand Up @@ -424,6 +437,30 @@ spec:
flags:
- --node-labels=alpha.eksctl.io/nodegroup-name=al2023-mng-test

`
nodeConfigIPv6 = `--//
Content-Type: application/node.eks.aws

apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
metadata:
creationTimestamp: null
spec:
cluster:
apiServerEndpoint: https://test.xxx.us-west-2.eks.amazonaws.com
certificateAuthority: dGVzdCBDQQ==
cidr: fd00:facc:76a1::/108
name: al2023-test
containerd: {}
instance:
localStorage: {}
kubelet:
config:
clusterDNS:
- 10.100.0.10
flags:
- --node-labels=alpha.eksctl.io/nodegroup-name=al2023-mng-test

`
managedNodeConfig = `--//
Content-Type: application/node.eks.aws
Expand Down
2 changes: 1 addition & 1 deletion pkg/nodebootstrap/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewManagedBootstrapper(clusterConfig *api.ClusterConfig, ng *api.ManagedNod
// GetClusterDNS returns the DNS address to use
func GetClusterDNS(clusterConfig *api.ClusterConfig) (string, error) {
networkConfig := clusterConfig.Status.KubernetesNetworkConfig
if networkConfig == nil {
if networkConfig == nil || networkConfig.ServiceIPv4CIDR == "" {
return "", nil
}

Expand Down
Loading