Skip to content

Commit c31f7a2

Browse files
fletcherwndbaker1
andauthored
feat(nodeadm): add network name resolution aspect (#2556)
This PR adds support for network name resolution config to the NodeConfig, allow users to override DNS nameservers and/or search domains. --------- Co-authored-by: Nick Baker <nbakerd@amazon.com>
1 parent 937dabd commit c31f7a2

File tree

18 files changed

+345
-11
lines changed

18 files changed

+345
-11
lines changed

nodeadm/api/v1alpha1/nodeconfig_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ type ContainerdOptions struct {
9292
type InstanceOptions struct {
9393
LocalStorage LocalStorageOptions `json:"localStorage,omitempty"`
9494
Environment EnvironmentOptions `json:"environment,omitempty"`
95+
Network NetworkOptions `json:"network,omitempty"`
96+
}
97+
98+
// NetworkOptions are parameters used to configure networking on the host OS.
99+
type NetworkOptions struct {
100+
// Nameservers are servers for the instance's network name resolution. The
101+
// list may include both IPv4 and IPv6 addresses.
102+
// see: https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html#DNS=
103+
Nameservers []string `json:"nameservers,omitempty"`
104+
105+
// Domains are search entries for the instance's network name resolution.
106+
// see: https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html#Domains=
107+
Domains []string `json:"domains,omitempty"`
95108
}
96109

97110
// EnvironmentOptions configures environment variables for the system and systemd services.

nodeadm/api/v1alpha1/zz_generated.deepcopy.go

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

nodeadm/cmd/nodeadm/init/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (c *initCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error {
125125
log.Info("Setting up system config aspects...")
126126
configAspects := []system.SystemAspect{
127127
system.NewInstanceEnvironmentAspect(),
128+
system.NewResolveAspect(),
128129
}
129130
if err := c.setupAspects(log, nodeConfig, configAspects); err != nil {
130131
return err

nodeadm/crds/node.eks.aws_nodeconfigs.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ spec:
141141
- Mount
142142
type: string
143143
type: object
144+
network:
145+
description: NetworkOptions are parameters used to configure networking
146+
on the host OS.
147+
properties:
148+
domains:
149+
description: |-
150+
Domains are search entries for the instance's network name resolution.
151+
see: https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html#Domains=
152+
items:
153+
type: string
154+
type: array
155+
nameservers:
156+
description: |-
157+
Nameservers are servers for the instance's network name resolution. The
158+
list may include both IPv4 and IPv6 addresses.
159+
see: https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html#DNS=
160+
items:
161+
type: string
162+
type: array
163+
type: object
144164
type: object
145165
kubelet:
146166
description: KubeletOptions are additional parameters passed to `kubelet`.

nodeadm/doc/api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ _Appears in:_
8686
| --- | --- |
8787
| `localStorage` _[LocalStorageOptions](#localstorageoptions)_ | |
8888
| `environment` _[EnvironmentOptions](#environmentoptions)_ | |
89+
| `network` _[NetworkOptions](#networkoptions)_ | |
8990

9091
#### KubeletOptions
9192

@@ -126,6 +127,18 @@ _Appears in:_
126127
.Validation:
127128
- Enum: [RAID0 RAID10 Mount]
128129

130+
#### NetworkOptions
131+
132+
NetworkOptions are parameters used to configure networking on the host OS.
133+
134+
_Appears in:_
135+
- [InstanceOptions](#instanceoptions)
136+
137+
| Field | Description |
138+
| --- | --- |
139+
| `nameservers` _string array_ | Nameservers are servers for the instance's network name resolution. The<br />list may include both IPv4 and IPv6 addresses.<br />see: https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html#DNS= |
140+
| `domains` _string array_ | Domains are search entries for the instance's network name resolution.<br />see: https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html#Domains= |
141+
129142
#### NodeConfig
130143

131144
NodeConfig is the primary configuration object for `nodeadm`.

nodeadm/internal/api/bridge/zz_generated.conversion.go

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

nodeadm/internal/api/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ const (
102102
type InstanceOptions struct {
103103
LocalStorage LocalStorageOptions `json:"localStorage,omitempty"`
104104
Environment EnvironmentOptions `json:"environment,omitempty"`
105+
Network NetworkOptions `json:"network,omitempty"`
106+
}
107+
108+
type NetworkOptions struct {
109+
Nameservers []string `json:"nameservers,omitempty"`
110+
Domains []string `json:"domains,omitempty"`
105111
}
106112

107113
type EnvironmentOptions map[string]map[string]string

nodeadm/internal/api/zz_generated.deepcopy.go

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

nodeadm/internal/system/environment.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ import (
1717
)
1818

1919
const (
20-
instanceEnvironmentAspectName = "instance-environment"
21-
nodeadmEnvironmentAspectName = "nodeadm-environment"
22-
systemdEnvironmentConfPath = "/etc/systemd/system.conf.d/environment.conf"
23-
serviceDropinPathBase = "/etc/systemd/system"
20+
systemdEnvironmentConfPath = "/etc/systemd/system.conf.d/environment.conf"
21+
serviceDropinPathBase = "/etc/systemd/system"
2422
)
2523

2624
const systemdConfigTemplate = `[Manager]
@@ -48,7 +46,7 @@ type nodeadmEnvironmentAspect struct{}
4846
type instanceEnvironmentAspect struct{}
4947

5048
func (a *nodeadmEnvironmentAspect) Name() string {
51-
return nodeadmEnvironmentAspectName
49+
return "nodeadm-environment"
5250
}
5351

5452
func (a *nodeadmEnvironmentAspect) Setup(cfg *api.NodeConfig) error {
@@ -66,7 +64,7 @@ func (a *nodeadmEnvironmentAspect) Setup(cfg *api.NodeConfig) error {
6664
}
6765

6866
func (a *instanceEnvironmentAspect) Name() string {
69-
return instanceEnvironmentAspectName
67+
return "instance-environment"
7068
}
7169

7270
func (a *instanceEnvironmentAspect) Setup(cfg *api.NodeConfig) error {

nodeadm/internal/system/local_disk.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import (
99
"go.uber.org/zap"
1010
)
1111

12-
const localDiskAspectName = "local-disk"
13-
1412
func NewLocalDiskAspect() SystemAspect {
1513
return &localDiskAspect{}
1614
}
1715

1816
type localDiskAspect struct{}
1917

2018
func (a *localDiskAspect) Name() string {
21-
return localDiskAspectName
19+
return "local-disk"
2220
}
2321

2422
func (a *localDiskAspect) Setup(cfg *api.NodeConfig) error {

0 commit comments

Comments
 (0)