mirror of https://github.com/kubernetes/kops.git
Don't start kubelet in protokube
Previously as an optimization we would start the kubelet from protokube, after we had mounted the disks. This helped avoid e.g. the apiserver going into backoff waiting for etcd. However, this no longer achieves anything with etcd-manager - nothing happens on this front until after we start the kubelet anyway. Doing this both takes protokube out of the dependency sequence here (slightly faster boot time), but also removes the systemd dependency from the protokube image. (So we can get a smaller image, perhaps even distroless)
This commit is contained in:
parent
e1f422920f
commit
6cdf9d5001
|
|
@ -283,11 +283,6 @@ func (b *KubeletBuilder) buildSystemdService() *nodetasks.Service {
|
|||
Definition: s(manifestString),
|
||||
}
|
||||
|
||||
// @check if we are a master allow protokube to start kubelet
|
||||
if b.IsMaster {
|
||||
service.Running = fi.Bool(false)
|
||||
}
|
||||
|
||||
service.InitDefaults()
|
||||
|
||||
return service
|
||||
|
|
|
|||
|
|
@ -18,14 +18,11 @@ package protokube
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"k8s.io/klog"
|
||||
utilexec "k8s.io/utils/exec"
|
||||
"k8s.io/utils/nsenter"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -144,14 +141,6 @@ func (k *KubeBoot) syncOnce(ctx context.Context) error {
|
|||
klog.V(4).Infof("protokube management of etcd not enabled; won't scan for volumes")
|
||||
}
|
||||
|
||||
// Ensure kubelet is running. We avoid doing this automatically so
|
||||
// that when kubelet comes up the first time, all volume mounts
|
||||
// and DNS are available, avoiding the scenario where
|
||||
// etcd/apiserver retry too many times and go into backoff.
|
||||
if err := startKubeletService(); err != nil {
|
||||
klog.Warningf("error ensuring kubelet started: %v", err)
|
||||
}
|
||||
|
||||
if k.Master {
|
||||
if k.BootstrapMasterNodeLabels {
|
||||
if err := bootstrapMasterNodeLabels(ctx, k.Kubernetes, k.NodeName); err != nil {
|
||||
|
|
@ -178,43 +167,6 @@ func (k *KubeBoot) syncOnce(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// startKubeletService is responsible for checking and if not starting the kubelet service
|
||||
func startKubeletService() error {
|
||||
// TODO: Check/log status of kubelet
|
||||
// (in particular, we want to avoid kubernetes/kubernetes#40123 )
|
||||
klog.V(2).Infof("ensuring that kubelet systemd service is running")
|
||||
|
||||
// We run systemctl from the hostfs so we don't need systemd in our image
|
||||
// (and we don't risk version skew)
|
||||
|
||||
exec := utilexec.New()
|
||||
if Containerized {
|
||||
e, err := nsenter.NewNsenter(pathFor("/"), utilexec.New())
|
||||
if err != nil {
|
||||
return fmt.Errorf("error building nsenter executor: %v", err)
|
||||
}
|
||||
exec = e
|
||||
}
|
||||
|
||||
systemctlCommand := "systemctl"
|
||||
|
||||
output, err := exec.Command(systemctlCommand, "status", "--no-block", "kubelet").CombinedOutput()
|
||||
klog.V(2).Infof("'systemctl status kubelet' output:\n%s", string(output))
|
||||
if err == nil {
|
||||
klog.V(2).Infof("kubelet systemd service already running")
|
||||
return nil
|
||||
}
|
||||
|
||||
klog.Infof("kubelet systemd service not running. Starting")
|
||||
output, err = exec.Command(systemctlCommand, "start", "--no-block", "kubelet").CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error starting kubelet: %v\nOutput: %s", err, output)
|
||||
}
|
||||
klog.V(2).Infof("'systemctl start kubelet' output:\n%s", string(output))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func pathFor(hostPath string) string {
|
||||
if hostPath[0] != '/' {
|
||||
klog.Fatalf("path was not absolute: %q", hostPath)
|
||||
|
|
|
|||
Loading…
Reference in New Issue