Skip to content
Open
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
2 changes: 2 additions & 0 deletions bootstrap/eks/internal/userdata/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const (
defaultBootstrapCommand = "/etc/eks/bootstrap.sh"

nodeUserData = `#cloud-config
{{- if .Files }}
{{template "files" .Files}}
{{- end }}
runcmd:
{{- template "commands" .PreBootstrapCommands }}
- {{ .BootstrapCommand }} {{.ClusterName}} {{- template "args" . }}
Expand Down
42 changes: 25 additions & 17 deletions bootstrap/eks/internal/userdata/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func TestNewNode(t *testing.T) {
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster
`),
Expand All @@ -67,7 +66,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --kubelet-extra-args '--node-labels=node-role.undistro.io/infra=true --register-with-taints=dedicated=infra:NoSchedule'
`),
Expand All @@ -81,7 +79,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --container-runtime containerd
`),
Expand All @@ -99,7 +96,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --kubelet-extra-args '--node-labels=node-role.undistro.io/infra=true --register-with-taints=dedicated=infra:NoSchedule' --container-runtime containerd
`),
Expand All @@ -114,7 +110,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --ip-family ipv6 --service-ipv6-cidr fe80:0000:0000:0000:0204:61ff:fe9d:f156/24
`),
Expand All @@ -128,7 +123,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --use-max-pods false
`),
Expand All @@ -142,7 +136,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --aws-api-retry-attempts 5
`),
Expand All @@ -157,7 +150,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --pause-container-account 12345678 --pause-container-version v1
`),
Expand All @@ -171,7 +163,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --dns-cluster-ip 192.168.0.1
`),
Expand All @@ -185,7 +176,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster --docker-config-json '{"debug":true}'
`),
Expand All @@ -199,7 +189,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- "date"
- "echo \"testing\""
Expand All @@ -215,7 +204,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster
- "date"
Expand All @@ -232,7 +220,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- "echo \"testing pre\""
- /etc/eks/bootstrap.sh test-cluster
Expand All @@ -248,7 +235,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /custom/mybootstrap.sh test-cluster
`),
Expand Down Expand Up @@ -280,7 +266,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster
disk_setup:
Expand Down Expand Up @@ -323,6 +308,31 @@ write_files:
fs.inotify.max_user_instances=256
runcmd:
- /etc/eks/bootstrap.sh test-cluster
`),
},
{
name: "with empty files",
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
Files: []eksbootstrapv1.File{},
},
},
expectedBytes: []byte(`#cloud-config
runcmd:
- /etc/eks/bootstrap.sh test-cluster
`),
},
{
name: "with nil files",
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
},
},
expectedBytes: []byte(`#cloud-config
runcmd:
- /etc/eks/bootstrap.sh test-cluster
`),
},
{
Expand All @@ -337,7 +347,6 @@ runcmd:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster
ntp:
Expand All @@ -363,7 +372,6 @@ ntp:
},
},
expectedBytes: []byte(`#cloud-config
write_files:
runcmd:
- /etc/eks/bootstrap.sh test-cluster
users:
Expand Down
Loading