mirror of https://github.com/k3s-io/k3s
Run TryStartKubelet conditionally; replace hard-code with constants.
parent
e8c58338a0
commit
54fb5736ed
|
@ -30,6 +30,8 @@ const (
|
|||
DefaultServiceDNSDomain = "cluster.local"
|
||||
// DefaultServicesSubnet defines default service subnet range
|
||||
DefaultServicesSubnet = "10.96.0.0/12"
|
||||
// DefaultClusterDNSIP defines default DNS IP
|
||||
DefaultClusterDNSIP = "10.96.0.10"
|
||||
// DefaultKubernetesVersion defines default kubernetes version
|
||||
DefaultKubernetesVersion = "stable-1.8"
|
||||
// DefaultAPIBindPort defines default API port
|
||||
|
@ -40,6 +42,8 @@ const (
|
|||
DefaultCertificatesDir = "/etc/kubernetes/pki"
|
||||
// DefaultImageRepository defines default image registry
|
||||
DefaultImageRepository = "gcr.io/google_containers"
|
||||
// DefaultManifestsDir defines default manifests directory
|
||||
DefaultManifestsDir = "/etc/kubernetes/manifests"
|
||||
|
||||
// DefaultEtcdDataDir defines default location of etcd where static pods will save data to
|
||||
DefaultEtcdDataDir = "/var/lib/etcd"
|
||||
|
|
|
@ -267,6 +267,9 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, skipPreFlight,
|
|||
if err := preflight.RunInitMasterChecks(utilsexec.New(), cfg, criSocket); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
preflight.TryStartKubelet()
|
||||
} else {
|
||||
fmt.Println("[preflight] Skipping pre-flight checks.")
|
||||
}
|
||||
|
@ -348,19 +351,19 @@ func (i *Init) Run(out io.Writer) error {
|
|||
}
|
||||
|
||||
if features.Enabled(i.cfg.FeatureGates, features.DynamicKubeletConfig) {
|
||||
// TODO: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
// NOTE: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
kubeletCfg := &kubeadmapi.KubeletConfiguration{
|
||||
BaseConfig: &kubeletconfigv1alpha1.KubeletConfiguration{
|
||||
PodManifestPath: "/etc/kubernetes/manifests",
|
||||
PodManifestPath: kubeadmapiext.DefaultManifestsDir,
|
||||
AllowPrivileged: utilpointer.BoolPtr(true),
|
||||
ClusterDNS: []string{"10.96.0.10"},
|
||||
ClusterDomain: "cluster.local",
|
||||
ClusterDNS: []string{kubeadmapiext.DefaultClusterDNSIP},
|
||||
ClusterDomain: kubeadmapiext.DefaultServiceDNSDomain,
|
||||
Authorization: kubeletconfigv1alpha1.KubeletAuthorization{
|
||||
Mode: "Webhook",
|
||||
Mode: kubeletconfigv1alpha1.KubeletAuthorizationModeWebhook,
|
||||
},
|
||||
Authentication: kubeletconfigv1alpha1.KubeletAuthentication{
|
||||
X509: kubeletconfigv1alpha1.KubeletX509Authentication{
|
||||
ClientCAFile: "/etc/kubernetes/pki/ca.crt",
|
||||
ClientCAFile: kubeadmapiext.DefaultCACertPath,
|
||||
},
|
||||
},
|
||||
CAdvisorPort: utilpointer.Int32Ptr(0),
|
||||
|
@ -392,12 +395,8 @@ func (i *Init) Run(out io.Writer) error {
|
|||
if err := CreateKubeletBaseConfigMapRBACRules(client, i.cfg.NodeName); err != nil {
|
||||
return fmt.Errorf("error creating kubelet base configmap RBAC rules: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
preflight.TryStartKubelet()
|
||||
|
||||
// waiter holds the apiclient.Waiter implementation of choice, responsible for querying the API server in various ways and waiting for conditions to be fulfilled
|
||||
waiter := getWaiter(i.dryRun, client)
|
||||
|
||||
|
|
|
@ -212,6 +212,9 @@ func NewJoin(cfgPath string, args []string, cfg *kubeadmapi.NodeConfiguration, s
|
|||
if err := preflight.RunJoinNodeChecks(utilsexec.New(), cfg, criSocket); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
preflight.TryStartKubelet()
|
||||
} else {
|
||||
fmt.Println("[preflight] Skipping pre-flight checks.")
|
||||
}
|
||||
|
@ -234,19 +237,15 @@ func (j *Join) Run(out io.Writer) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Try to start the kubelet service in case it's inactive
|
||||
preflight.TryStartKubelet()
|
||||
|
||||
if features.Enabled(j.cfg.FeatureGates, features.DynamicKubeletConfig) {
|
||||
// TODO: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
// NOTE: flag "--dynamic-config-dir" should be specified in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
||||
client, err := kubeconfigutil.ClientSetFromFile(kubeadmconstants.GetAdminKubeConfigPath())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = cmdutil.UpdateNodeWithConfigMap(client, j.cfg.NodeName)
|
||||
if err != nil {
|
||||
return nil
|
||||
if err = cmdutil.UpdateNodeWithConfigMap(client, j.cfg.NodeName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,10 +140,12 @@ const (
|
|||
// MasterConfigurationConfigMapKey specifies in what ConfigMap key the master configuration should be stored
|
||||
MasterConfigurationConfigMapKey = "MasterConfiguration"
|
||||
|
||||
// KubeletBaseConfigurationConfigMap specifies in what ConfigMap in the kube-system namespace the init kubelet configuration should be stored
|
||||
// KubeletBaseConfigurationConfigMap specifies in what ConfigMap in the kube-system namespace the initial remote configuration should be stored
|
||||
KubeletBaseConfigurationConfigMap = "kubelet-base-config-1.9"
|
||||
|
||||
// KubeletBaseConfigurationConfigMapKey specifies in what ConfigMap key the init kubelet configuration should be stored
|
||||
// KubeletBaseConfigurationConfigMapKey specifies in what ConfigMap key the initial remote configuration should be stored
|
||||
// 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.
|
||||
KubeletBaseConfigurationConfigMapKey = "kubelet"
|
||||
|
||||
// MinExternalEtcdVersion indicates minimum external etcd version which kubeadm supports
|
||||
|
|
Loading…
Reference in New Issue