Commit f970e49b authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Wait for apiserver to become healthy before starting agent controllers

It is possible that the apiserver may serve read requests but not allow writes yet, in which case flannel will crash on startup when trying to configure the subnet manager. Fix this by waiting for the apiserver to become fully ready before starting flannel and the network policy controller. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 9b39c1c1
...@@ -35,6 +35,7 @@ import ( ...@@ -35,6 +35,7 @@ import (
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
v1 "k8s.io/client-go/kubernetes/typed/core/v1" v1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
"k8s.io/controller-manager/app"
) )
var ( var (
...@@ -98,6 +99,9 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error { ...@@ -98,6 +99,9 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
if err != nil { if err != nil {
return err return err
} }
app.WaitForAPIServer(coreClient, 30*time.Second)
if !nodeConfig.NoFlannel { if !nodeConfig.NoFlannel {
if err := flannel.Run(ctx, nodeConfig, coreClient.CoreV1().Nodes()); err != nil { if err := flannel.Run(ctx, nodeConfig, coreClient.CoreV1().Nodes()); err != nil {
return err return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment