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:
Eric Paris
2015-05-24 18:15:19 -04:00
parent f015a21026
commit 28ac1b3395
4 changed files with 42 additions and 0 deletions

View File

@@ -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