mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Write marshalled kubeletconfig object to init-config-dir
This commit is contained in:
parent
5322cc5e02
commit
8565ee89c5
@ -155,6 +155,14 @@ const (
|
||||
// after https://github.com/kubernetes/kubernetes/pull/53833 being merged.
|
||||
KubeletBaseConfigurationConfigMapKey = "kubelet"
|
||||
|
||||
// KubeletBaseConfigurationDir specifies the directory on the node where stores the initial remote configuration of kubelet
|
||||
KubeletBaseConfigurationDir = "/var/lib/kubelet/config/init"
|
||||
|
||||
// KubeletBaseConfigurationFile specifies the file name on the node which stores initial remote configuration of kubelet
|
||||
// TODO: Use the constant ("kubelet.config.k8s.io") defined in pkg/kubelet/kubeletconfig/util/keys/keys.go
|
||||
// after https://github.com/kubernetes/kubernetes/pull/53833 being merged.
|
||||
KubeletBaseConfigurationFile = "kubelet"
|
||||
|
||||
// MinExternalEtcdVersion indicates minimum external etcd version which kubeadm supports
|
||||
MinExternalEtcdVersion = "3.0.14"
|
||||
|
||||
|
@ -19,6 +19,10 @@ package kubelet
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
rbac "k8s.io/api/rbac/v1"
|
||||
@ -92,6 +96,15 @@ func UpdateNodeWithConfigMap(client clientset.Interface, nodeName string) error
|
||||
return false, nil
|
||||
}
|
||||
|
||||
baseCongfig, err := yaml.Marshal(kubeletCfg.Data[kubeadmconstants.KubeletBaseConfigurationConfigMapKey])
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
baseCongfigFile := filepath.Join(kubeadmconstants.KubeletBaseConfigurationDir, kubeadmconstants.KubeletBaseConfigurationFile)
|
||||
if err := ioutil.WriteFile(baseCongfigFile, baseCongfig, 0644); err != nil {
|
||||
return false, fmt.Errorf("failed to write initial remote configuration of kubelet into file %q for node %s: %v", baseCongfigFile, nodeName, err)
|
||||
}
|
||||
|
||||
node.Spec.ConfigSource = &v1.NodeConfigSource{
|
||||
ConfigMapRef: &v1.ObjectReference{
|
||||
Name: kubeadmconstants.KubeletBaseConfigurationConfigMap,
|
||||
|
Loading…
Reference in New Issue
Block a user