Skip to content

Commit

Permalink
write default kubeletConfig to config path in drop-in dir versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbaker1 committed Jan 30, 2024
1 parent da91c80 commit a45686f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions nodeadm/internal/kubelet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type kubeletConfig struct {
HairpinMode string `json:"hairpinMode"`
ProtectKernelDefaults bool `json:"protectKernelDefaults"`
ReadOnlyPort int `json:"readOnlyPort"`
Logging logsapi.LoggingConfiguration `json:"logging"`
Logging loggingConfiguration `json:"logging"`
SerializeImagePulls bool `json:"serializeImagePulls"`
ServerTLSBootstrap bool `json:"serverTLSBootstrap"`
TLSCipherSuites []string `json:"tlsCipherSuites"`
Expand All @@ -79,6 +79,10 @@ type kubeletConfig struct {
RegisterWithTaints []v1.Taint `json:"registerWithTaints,omitempty"`
}

type loggingConfiguration struct {
Verbosity logsapi.VerbosityLevel `json:"verbosity"`
}

// Creates an internal kubelet configuration from the public facing bootstrap
// kubelet configuration with additional sane defaults.
func defaultKubeletSubConfig() kubeletConfig {
Expand Down Expand Up @@ -117,7 +121,7 @@ func defaultKubeletSubConfig() kubeletConfig {
HairpinMode: "hairpin-veth",
ProtectKernelDefaults: true,
ReadOnlyPort: 0,
Logging: logsapi.LoggingConfiguration{
Logging: loggingConfiguration{
Verbosity: 2,
},
SerializeImagePulls: false,
Expand Down Expand Up @@ -317,20 +321,22 @@ func (k *kubelet) writeKubeletConfigToDir(cfg *api.NodeConfig, userKubeletConfig
return err
}

dirPath := path.Join(kubeletConfigRoot, kubeletConfigDir)
k.flags["config-dir"] = dirPath

zap.L().Info("Enabling kubelet config drop-in dir..")
k.setEnv("KUBELET_CONFIG_DROPIN_DIR_ALPHA", "on")
configPath := path.Join(kubeletConfigRoot, kubeletConfigFile)
k.flags["config"] = configPath

filePath := path.Join(dirPath, "99-defaults.conf")
zap.L().Info("Writing kubelet config to drop-in file..", zap.String("path", filePath))
if err := util.WriteFileWithDir(filePath, kubeletConfigBytes, kubeletConfigPerm); err != nil {
zap.L().Info("Writing kubelet config to file..", zap.String("path", configPath))
if err := util.WriteFileWithDir(configPath, kubeletConfigBytes, kubeletConfigPerm); err != nil {
return err
}

if userKubeletConfig != nil && len(userKubeletConfig) > 0 {
filePath = path.Join(dirPath, "00-overrides.conf")
dirPath := path.Join(kubeletConfigRoot, kubeletConfigDir)
k.flags["config-dir"] = dirPath

zap.L().Info("Enabling kubelet config drop-in dir..")
k.setEnv("KUBELET_CONFIG_DROPIN_DIR_ALPHA", "on")

filePath := path.Join(dirPath, "00-overrides.conf")
zap.L().Info("Writing user kubelet config to drop-in file..", zap.String("path", filePath))
if err := util.WriteFileWithDir(filePath, userKubeletConfig, kubeletConfigPerm); err != nil {
return err
Expand Down

0 comments on commit a45686f

Please sign in to comment.