Skip to content

Commit

Permalink
Dont wrap kubelet systemd envs
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbaker1 committed Jul 12, 2024
1 parent 620f325 commit bd195ee
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nodeadm/internal/kubelet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (k *kubelet) writeKubeletConfigToDir(cfg *api.NodeConfig) error {
k.flags["config-dir"] = dirPath

zap.L().Info("Enabling kubelet config drop-in dir..")
k.setEnv("KUBELET_CONFIG_DROPIN_DIR_ALPHA", "on")
k.environment["KUBELET_CONFIG_DROPIN_DIR_ALPHA"] = "on"
filePath := path.Join(dirPath, "00-nodeadm.conf")

// merge in default type metadata like kind and apiVersion in case the
Expand Down
7 changes: 3 additions & 4 deletions nodeadm/internal/kubelet/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ 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"`, eKey, eValue))
kubeletEnvironment = append(kubeletEnvironment, fmt.Sprintf(`%s=%s`, sanitize(eKey), sanitize(eValue)))
}
return util.WriteFileWithDir(kubeletEnvironmentFilePath, []byte(strings.Join(kubeletEnvironment, "\n")), kubeletConfigPerm)
}

// Add values to the environment variables map in a terse manner
func (k *kubelet) setEnv(envName string, envArg string) {
k.environment[envName] = envArg
func sanitize(s string) string {
return strings.ReplaceAll(s, "\n", " ")
}
3 changes: 3 additions & 0 deletions nodeadm/test/e2e/cases/kubelet-flags/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ spec:
- --v=5
- --node-labels=foo=bar,foo2=baz
- --register-with-taints=foo=bar:NoSchedule
- |
--foo
--bar
2 changes: 1 addition & 1 deletion nodeadm/test/e2e/cases/kubelet-flags/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"$'
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 '--hostname-override=i-1234567890abcdef0'

0 comments on commit bd195ee

Please sign in to comment.