mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 05:01:46 +00:00
API server explicitly notify systemd of successful startup
Use the systemd $NOTIFY_SOCKET convention for kube-apiserver startup. This allows it to be part of dependency trees and for consumers to wait until it is listening on its ports. The $NOTIFY_SOCKET protocol is described here: http://www.freedesktop.org/software/systemd/man/sd_notify.html Currently this is limited to the kube-apiserver process. Other kube processes are internal kubernetes moving points. The API server is the entry point relied on by callers. 100% stolen from Stef Walter from: https://github.com/GoogleCloudPlatform/kubernetes/pull/8316
This commit is contained in:
@@ -40,6 +40,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
forked "github.com/GoogleCloudPlatform/kubernetes/third_party/forked/coreos/go-etcd/etcd"
|
||||
systemd "github.com/coreos/go-systemd/daemon"
|
||||
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"github.com/golang/glog"
|
||||
@@ -455,6 +456,7 @@ func (s *APIServer) Run(_ []string) error {
|
||||
glog.Infof("Using self-signed cert (%s, %s)", s.TLSCertFile, s.TLSPrivateKeyFile)
|
||||
}
|
||||
}
|
||||
_ = systemd.SdNotify("READY=1\n")
|
||||
if err := secureServer.ListenAndServeTLS(s.TLSCertFile, s.TLSPrivateKeyFile); err != nil {
|
||||
glog.Errorf("Unable to listen for secure (%v); will try again.", err)
|
||||
}
|
||||
@@ -469,6 +471,9 @@ func (s *APIServer) Run(_ []string) error {
|
||||
WriteTimeout: ReadWriteTimeout,
|
||||
MaxHeaderBytes: 1 << 20,
|
||||
}
|
||||
if secureLocation == "" {
|
||||
_ = systemd.SdNotify("READY=1\n")
|
||||
}
|
||||
glog.Infof("Serving insecurely on %s", insecureLocation)
|
||||
glog.Fatal(http.ListenAndServe())
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user