Skip to content
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
5 changes: 5 additions & 0 deletions examples/29-vpc-with-ip-family.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ metadata:
vpc:
ipFamily: IPv6

addons:
- name: vpc-cni
- name: coredns
- name: kube-proxy

managedNodeGroups: []
7 changes: 7 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ const (
IPV6Family IPFamily = "IPv6"
)

// Values for core addons
const (
VPCCNIAddon = "vpc-cni"
KubeProxyAddon = "kube-proxy"
CoreDNSAddon = "coredns"
)

var (
// DefaultIPFamily defines the default IP family to use when creating a new VPC.
DefaultIPFamily = IPV4Family
Expand Down
24 changes: 24 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,34 @@ func (c *ClusterConfig) ValidateVPCConfig() error {
if *v != string(IPV4Family) && *v != string(IPV6Family) {
return fmt.Errorf("invalid value %s for ipFamily; allowed are %s and %s", *v, IPV4Family, IPV6Family)
}
// This is the new vpc check, I need this check when the user sets it.
if *v == string(IPV6Family) {
if missing := c.addonContainsManagedAddons([]string{VPCCNIAddon, CoreDNSAddon, KubeProxyAddon}); len(missing) != 0 {
return fmt.Errorf("the default core addons must be defined in case of IPv6; missing addon(s): %s", strings.Join(missing, ", "))
}
}
}
return nil
}

// addonContainsManagedAddons finds managed addons in the config and returns those it couldn't find.
func (c *ClusterConfig) addonContainsManagedAddons(addons []string) []string {
var missing []string
for _, a := range addons {
found := false
for _, add := range c.Addons {
if strings.ToLower(add.Name) == a {
found = true
break
}
}
if !found {
missing = append(missing, a)
}
}
return missing
}

// ValidateClusterEndpointConfig checks the endpoint configuration for potential issues
func (c *ClusterConfig) ValidateClusterEndpointConfig() error {
if !c.HasClusterEndpointAccess() {
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,26 @@ var _ = Describe("ClusterConfig validation", func() {
It("accepts that setting", func() {
ipv6 := string(api.IPV6Family)
cfg.VPC.IPFamily = &ipv6
cfg.Addons = append(cfg.Addons,
&api.Addon{Name: api.KubeProxyAddon},
&api.Addon{Name: api.CoreDNSAddon},
&api.Addon{Name: api.VPCCNIAddon},
)
err = cfg.ValidateVPCConfig()
Expect(err).ToNot(HaveOccurred())
})
})
When("ipFamily is set ot IPv6 but no managed addons are provided", func() {
It("it returns an error including which addons are missing", func() {
ipv6 := string(api.IPV6Family)
cfg.VPC.IPFamily = &ipv6
cfg.Addons = append(cfg.Addons,
&api.Addon{Name: api.KubeProxyAddon},
)
err = cfg.ValidateVPCConfig()
Expect(err).To(MatchError(ContainSubstring("the default core addons must be defined in case of IPv6; missing addon(s): vpc-cni, coredns")))
})
})
When("ipFamily isn't IPv4 or IPv6", func() {
It("returns an error", func() {
invalid := "invalid"
Expand Down
7 changes: 6 additions & 1 deletion userdocs/src/usage/vpc-networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ metadata:

vpc:
ipFamily: IPv6 # or IPv4

addons:
- name: vpc-cni
- name: coredns
- name: kube-proxy
```

This is an in config file setting only. The default value is `IPv4`.
This is an in config file setting only and default core addons need to be defined when IPv6 is set. The default value is `IPv4`.

## Change VPC CIDR

Expand Down