diff --git a/nodeadm/internal/kubelet/environment.go b/nodeadm/internal/kubelet/environment.go index d275fc331..7c11b061f 100644 --- a/nodeadm/internal/kubelet/environment.go +++ b/nodeadm/internal/kubelet/environment.go @@ -2,7 +2,6 @@ package kubelet import ( "fmt" - "regexp" "strings" "github.com/awslabs/amazon-eks-ami/nodeadm/internal/api" @@ -31,11 +30,7 @@ func (k *kubelet) writeKubeletEnvironment(cfg *api.NodeConfig) error { // write additional environment variables var kubeletEnvironment []string for eKey, eValue := range k.environment { - kubeletEnvironment = append(kubeletEnvironment, fmt.Sprintf(`%s=%s`, sanitize(eKey), sanitize(eValue))) + kubeletEnvironment = append(kubeletEnvironment, fmt.Sprintf(`%s=%s`, eKey, eValue)) } return util.WriteFileWithDir(kubeletEnvironmentFilePath, []byte(strings.Join(kubeletEnvironment, "\n")), kubeletConfigPerm) } - -func sanitize(s string) string { - return regexp.MustCompile("[\n\r]").ReplaceAllString(s, " ") -} diff --git a/nodeadm/test/e2e/cases/kubelet-flags/config.yaml b/nodeadm/test/e2e/cases/kubelet-flags/config.yaml index bdf6441d8..8919683a5 100644 --- a/nodeadm/test/e2e/cases/kubelet-flags/config.yaml +++ b/nodeadm/test/e2e/cases/kubelet-flags/config.yaml @@ -14,6 +14,3 @@ spec: - --v=5 - --node-labels=foo=bar,foo2=baz - --register-with-taints=foo=bar:NoSchedule - - | - --foo - --bar diff --git a/nodeadm/test/e2e/cases/kubelet-flags/run.sh b/nodeadm/test/e2e/cases/kubelet-flags/run.sh index 5abd450a2..6de36c942 100755 --- a/nodeadm/test/e2e/cases/kubelet-flags/run.sh +++ b/nodeadm/test/e2e/cases/kubelet-flags/run.sh @@ -12,5 +12,5 @@ wait::dbus-ready nodeadm init --skip run --config-source file://config.yaml -assert::file-contains /etc/eks/kubelet/environment '--v=5 --node-labels=foo=bar,foo2=baz --register-with-taints=foo=bar:NoSchedule --foo --bar $' +assert::file-contains /etc/eks/kubelet/environment '--v=5 --node-labels=foo=bar,foo2=baz --register-with-taints=foo=bar:NoSchedule$' assert::file-contains /etc/eks/kubelet/environment '--hostname-override=i-1234567890abcdef0'