mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Enable systemd ready notification for k3s server
Disables k8s generic api server systemd ready notification and send our own ready notification after server available and kubeconfig available. Make sure we unset the NOTIFY_SOCKET environment variable by passing `true` to SdNotify so the agent can start containers.
This commit is contained in:
parent
17f9f355bb
commit
107b5f3985
@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
systemd "github.com/coreos/go-systemd/daemon"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/natefinch/lumberjack"
|
||||
"github.com/pkg/errors"
|
||||
@ -99,6 +100,9 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
||||
}
|
||||
|
||||
logrus.Info("Starting k3s ", app.App.Version)
|
||||
notifySocket := os.Getenv("NOTIFY_SOCKET")
|
||||
os.Unsetenv("NOTIFY_SOCKET")
|
||||
|
||||
ctx := signal.SigTermCancelContext(context.Background())
|
||||
certs, err := server.StartServer(ctx, &serverConfig)
|
||||
if err != nil {
|
||||
@ -106,6 +110,10 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
||||
}
|
||||
|
||||
logrus.Info("k3s is up and running")
|
||||
if notifySocket != "" {
|
||||
os.Setenv("NOTIFY_SOCKET", notifySocket)
|
||||
systemd.SdNotify(true, "READY=1")
|
||||
}
|
||||
|
||||
if cfg.DisableAgent {
|
||||
<-ctx.Done()
|
||||
|
Loading…
Reference in New Issue
Block a user