Skip to content

Commit

Permalink
Set cluster DNS in bootstrap if ClusterIP range specified (eksctl-io…
Browse files Browse the repository at this point in the history
  • Loading branch information
weaveworksbot authored Sep 28, 2020
1 parent 625a540 commit ed665e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/nodebootstrap/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nodebootstrap

import (
"fmt"
"net"
"sort"
"strings"

Expand Down Expand Up @@ -83,6 +84,17 @@ func clusterDNS(spec *api.ClusterConfig, ng *api.NodeGroup) string {
if ng.ClusterDNS != "" {
return ng.ClusterDNS
}
if spec.KubernetesNetworkConfig != nil && spec.KubernetesNetworkConfig.ServiceIPv4CIDR != "" {
if _, ipnet, err := net.ParseCIDR(spec.KubernetesNetworkConfig.ServiceIPv4CIDR); err != nil {
panic(errors.Wrap(err, "invalid IPv4 CIDR for kubernetesNetworkConfig.serviceIPv4CIDR"))
} else {
prefix := strings.Split(ipnet.IP.String(), ".")
if len(prefix) != 4 {
panic(errors.Wrap(err, "invalid IPv4 CIDR for kubernetesNetworkConfig.serviceIPv4CIDR"))
}
return strings.Join([]string{prefix[0], prefix[1], prefix[2], "10"}, ".")
}
}
// Default service network is 10.100.0.0, but it gets set 172.20.0.0 automatically when pod network
// is anywhere within 10.0.0.0/8
if spec.VPC.CIDR != nil && spec.VPC.CIDR.IP[0] == 10 {
Expand Down

0 comments on commit ed665e5

Please sign in to comment.