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

feat: Node-local DNS cache support #550

Merged
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
3 changes: 3 additions & 0 deletions pkg/apis/eksctl.io/v1alpha4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ type NodeGroup struct {

// +optional
OverrideBootstrapCommand *string `json:"overrideBootstrapCommand,omitempty"`

// +optional
ClusterDNS string `json:"clusterDNS,omitempty"`
}

// ListOptions returns metav1.ListOptions with label selector for the nodegroup
Expand Down
8 changes: 6 additions & 2 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ var _ = Describe("CloudFormation template builder API", func() {

cfg.NodeGroups[0].OverrideBootstrapCommand = &overrideBootstrapCommand

cfg.NodeGroups[0].ClusterDNS = "169.254.20.10"

rs := NewNodeGroupResourceSet(p, cfg, "eksctl-test-123-cluster", ng)
err := rs.AddAllResources()
It("should add all resources without errors", func() {
Expand Down Expand Up @@ -868,7 +870,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(kubeletEnv.Permissions).To(Equal("0644"))
Expect(strings.Split(kubeletEnv.Content, "\n")).To(Equal([]string{
"MAX_PODS=29",
"CLUSTER_DNS=10.100.0.10",
"CLUSTER_DNS=169.254.20.10",
"NODE_LABELS=os=al2",
}))

Expand Down Expand Up @@ -977,6 +979,8 @@ var _ = Describe("CloudFormation template builder API", func() {
"os": "ubuntu",
}

cfg.NodeGroups[0].ClusterDNS = "169.254.20.10"

cfg.NodeGroups[0].OverrideBootstrapCommand = &overrideBootstrapCommand

rs := NewNodeGroupResourceSet(p, cfg, "eksctl-test-123-cluster", ng)
Expand Down Expand Up @@ -1018,7 +1022,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(kubeletEnv.Permissions).To(Equal("0644"))
Expect(strings.Split(kubeletEnv.Content, "\n")).To(Equal([]string{
"MAX_PODS=29",
"CLUSTER_DNS=172.20.0.10",
"CLUSTER_DNS=169.254.20.10",
"NODE_LABELS=os=ubuntu",
}))

Expand Down
7 changes: 5 additions & 2 deletions pkg/nodebootstrap/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func makeClientConfigData(spec *api.ClusterConfig, ng *api.NodeGroup) ([]byte, e
return clientConfigData, nil
}

func clusterDNS(spec *api.ClusterConfig) string {
func clusterDNS(spec *api.ClusterConfig, ng *api.NodeGroup) string {
if ng.ClusterDNS != "" {
return ng.ClusterDNS
}
// 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a future improvement, we should probably move this into struct defaulting code path, and set the field to the default value. That is so the struct fully represents what's going on.

Expand All @@ -106,7 +109,7 @@ func makeKubeletParamsCommon(spec *api.ClusterConfig, ng *api.NodeGroup) []strin
// TODO: use componentconfig or kubelet config file – https://github.com/weaveworks/eksctl/issues/156
return []string{
fmt.Sprintf("MAX_PODS=%d", ng.MaxPodsPerNode),
fmt.Sprintf("CLUSTER_DNS=%s", clusterDNS(spec)),
fmt.Sprintf("CLUSTER_DNS=%s", clusterDNS(spec, ng)),
fmt.Sprintf("NODE_LABELS=%s", strings.Join(labels, ",")),
}
}
Expand Down