diff --git a/cmd/agent/main.go b/cmd/agent/main.go index d51f776..e4b92d5 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -52,6 +52,7 @@ func main() { var clusterName string var spokeKubeconfig string var featureGatesFlags map[string]bool + var leaseHealthCheck bool logger := klogr.New() klog.SetOutput(os.Stdout) @@ -69,7 +70,7 @@ func main() { "feature-gates", "A set of key=value pairs that describe feature gates for alpha/experimental features. "+ "Options are:\n"+strings.Join(features.FeatureGates.KnownFeatures(), "\n")) - + flag.BoolVar(&leaseHealthCheck, "lease-health-check", false, "Use lease to report health check.") flag.Parse() ctrl.SetLogger(logger) @@ -191,11 +192,13 @@ func main() { ctx, cancel := context.WithCancel(ctrl.SetupSignalHandler()) defer cancel() - leaseUpdater, err := health.NewAddonHealthUpdater(mgr.GetConfig(), clusterName, spokeCfg, spokeNamespace) - if err != nil { - klog.Fatalf("unable to create healthiness lease updater for controller %v", "ManagedServiceAccount") + if leaseHealthCheck { + leaseUpdater, err := health.NewAddonHealthUpdater(mgr.GetConfig(), clusterName, spokeCfg, spokeNamespace) + if err != nil { + klog.Fatalf("unable to create healthiness lease updater for controller %v", "ManagedServiceAccount") + } + go leaseUpdater.Start(ctx) } - go leaseUpdater.Start(ctx) cc, err := addonutils.NewConfigChecker("managed-serviceaccount-agent", getHubKubeconfigPath()) if err != nil { diff --git a/go.mod b/go.mod index f57c5ca..e37215c 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( k8s.io/component-base v0.27.4 k8s.io/klog/v2 v2.90.1 k8s.io/utils v0.0.0-20230209194617-a36077c30491 - open-cluster-management.io/addon-framework v0.7.1-0.20230922012530-9d049de615d8 - open-cluster-management.io/api v0.11.1-0.20230921010001-9cb6321fa748 + open-cluster-management.io/addon-framework v0.8.0 + open-cluster-management.io/api v0.12.0 sigs.k8s.io/controller-runtime v0.15.1 ) diff --git a/go.sum b/go.sum index cffc3d1..1b74aae 100644 --- a/go.sum +++ b/go.sum @@ -331,10 +331,10 @@ k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5F k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -open-cluster-management.io/addon-framework v0.7.1-0.20230922012530-9d049de615d8 h1:YPOgQZ+Yb5bLIBXYVepPBkGh5dDIGxn/sFl5RkjkvW0= -open-cluster-management.io/addon-framework v0.7.1-0.20230922012530-9d049de615d8/go.mod h1:eI9o2LMXLBQK/IZ55X0zZiop2L9YDdL81ZoHWb9Pc0M= -open-cluster-management.io/api v0.11.1-0.20230921010001-9cb6321fa748 h1:OjemV/LWwBuKDZJLfEPw51w0Zbd9HKgpkxGtPclOjkQ= -open-cluster-management.io/api v0.11.1-0.20230921010001-9cb6321fa748/go.mod h1:/CZhelEH+30/pX7vXGSZOzLMX0zvjthYOkT/5ZTzVTQ= +open-cluster-management.io/addon-framework v0.8.0 h1:i1OReMHuZIoAw2Q04SLjkieU25DnxYilzVZzBNyROwU= +open-cluster-management.io/addon-framework v0.8.0/go.mod h1:20DP06VXhJ9RE1PetAMEQyeFCP7+nhs92pCAkqbWUOg= +open-cluster-management.io/api v0.12.0 h1:sNkj4k2XyWA/GLsTiFg82bLIZ7JDZKkLLLyZjJUlJMs= +open-cluster-management.io/api v0.12.0/go.mod h1:/CZhelEH+30/pX7vXGSZOzLMX0zvjthYOkT/5ZTzVTQ= sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUTb/+4c= sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/pkg/addon/manager/manifests/templates/deployment.yaml b/pkg/addon/manager/manifests/templates/deployment.yaml index af7cf4f..a694493 100644 --- a/pkg/addon/manager/manifests/templates/deployment.yaml +++ b/pkg/addon/manager/manifests/templates/deployment.yaml @@ -42,6 +42,7 @@ spec: - --leader-elect=false - --cluster-name={{ .ClusterName }} - --kubeconfig=/etc/hub/kubeconfig + - --lease-health-check=true volumeMounts: - name: hub-kubeconfig mountPath: /etc/hub/