mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #8764 from eparis/sd_notify
API server explicitly notify systemd of successful startup
This commit is contained in:
commit
3db1f69eea
5
Godeps/Godeps.json
generated
5
Godeps/Godeps.json
generated
@ -98,6 +98,11 @@
|
|||||||
"ImportPath": "github.com/coreos/go-semver/semver",
|
"ImportPath": "github.com/coreos/go-semver/semver",
|
||||||
"Rev": "6fe83ccda8fb9b7549c9ab4ba47f47858bc950aa"
|
"Rev": "6fe83ccda8fb9b7549c9ab4ba47f47858bc950aa"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/coreos/go-systemd/daemon",
|
||||||
|
"Comment": "v2-27-g97e243d",
|
||||||
|
"Rev": "97e243d21a8e232e9d8af38ba2366dfcfceebeba"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/coreos/go-systemd/dbus",
|
"ImportPath": "github.com/coreos/go-systemd/dbus",
|
||||||
"Comment": "v2-27-g97e243d",
|
"Comment": "v2-27-g97e243d",
|
||||||
|
31
Godeps/_workspace/src/github.com/coreos/go-systemd/daemon/sdnotify.go
generated
vendored
Normal file
31
Godeps/_workspace/src/github.com/coreos/go-systemd/daemon/sdnotify.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Code forked from Docker project
|
||||||
|
package daemon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var SdNotifyNoSocket = errors.New("No socket")
|
||||||
|
|
||||||
|
// SdNotify sends a message to the init daemon. It is common to ignore the error.
|
||||||
|
func SdNotify(state string) error {
|
||||||
|
socketAddr := &net.UnixAddr{
|
||||||
|
Name: os.Getenv("NOTIFY_SOCKET"),
|
||||||
|
Net: "unixgram",
|
||||||
|
}
|
||||||
|
|
||||||
|
if socketAddr.Name == "" {
|
||||||
|
return SdNotifyNoSocket
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
_, err = conn.Write([]byte(state))
|
||||||
|
return err
|
||||||
|
}
|
@ -40,6 +40,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
forked "github.com/GoogleCloudPlatform/kubernetes/third_party/forked/coreos/go-etcd/etcd"
|
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/coreos/go-etcd/etcd"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -448,6 +449,10 @@ func (s *APIServer) Run(_ []string) error {
|
|||||||
glog.Infof("Using self-signed cert (%s, %s)", s.TLSCertFile, s.TLSPrivateKeyFile)
|
glog.Infof("Using self-signed cert (%s, %s)", s.TLSCertFile, s.TLSPrivateKeyFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// err == systemd.SdNotifyNoSocket when not running on a systemd system
|
||||||
|
if err := systemd.SdNotify("READY=1\n"); err != nil && err != systemd.SdNotifyNoSocket {
|
||||||
|
glog.Errorf("Unable to send systemd daemon sucessful start message: %v\n", err)
|
||||||
|
}
|
||||||
if err := secureServer.ListenAndServeTLS(s.TLSCertFile, s.TLSPrivateKeyFile); err != nil {
|
if err := secureServer.ListenAndServeTLS(s.TLSCertFile, s.TLSPrivateKeyFile); err != nil {
|
||||||
glog.Errorf("Unable to listen for secure (%v); will try again.", err)
|
glog.Errorf("Unable to listen for secure (%v); will try again.", err)
|
||||||
}
|
}
|
||||||
@ -462,6 +467,12 @@ func (s *APIServer) Run(_ []string) error {
|
|||||||
WriteTimeout: ReadWriteTimeout,
|
WriteTimeout: ReadWriteTimeout,
|
||||||
MaxHeaderBytes: 1 << 20,
|
MaxHeaderBytes: 1 << 20,
|
||||||
}
|
}
|
||||||
|
if secureLocation == "" {
|
||||||
|
// err == systemd.SdNotifyNoSocket when not running on a systemd system
|
||||||
|
if err := systemd.SdNotify("READY=1\n"); err != nil && err != systemd.SdNotifyNoSocket {
|
||||||
|
glog.Errorf("Unable to send systemd daemon sucessful start message: %v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
glog.Infof("Serving insecurely on %s", insecureLocation)
|
glog.Infof("Serving insecurely on %s", insecureLocation)
|
||||||
glog.Fatal(http.ListenAndServe())
|
glog.Fatal(http.ListenAndServe())
|
||||||
return nil
|
return nil
|
||||||
|
@ -18,6 +18,7 @@ ExecStart=/usr/bin/kube-apiserver \
|
|||||||
$KUBE_ADMISSION_CONTROL \
|
$KUBE_ADMISSION_CONTROL \
|
||||||
$KUBE_API_ARGS
|
$KUBE_API_ARGS
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
Type=notify
|
||||||
LimitNOFILE=65536
|
LimitNOFILE=65536
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
Loading…
Reference in New Issue
Block a user