Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <arnob@appscode.com>
  • Loading branch information
ArnobKumarSaha committed Jul 11, 2024
1 parent e2d9dec commit 0fc10ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/cmds/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/types"
clientscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -102,8 +103,11 @@ func NewCmdWebhook(ctx context.Context) *cobra.Command {
os.Exit(1)
}

klog.Info("mgr.Add()")
if err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {
klog.Info("Inside mgr.Add()")
if mgr.GetCache().WaitForCacheSync(context.TODO()) {
klog.Info("cache is synced")
if err := updateMutatingWebhookCABundle(mgr, webhookName, certDir); err != nil {
setupLog.Error(err, "unable to update caBundle for MutatingWebhookConfiguration")
os.Exit(1)
Expand All @@ -118,6 +122,7 @@ func NewCmdWebhook(ctx context.Context) *cobra.Command {
setupLog.Error(err, "unable to setup webhook configuration updater")
os.Exit(1)
}
// mgr.GetCache().WaitForCacheSync(context.TODO())

setupLog.Info("starting manager")
if err := mgr.Start(ctx); err != nil {
Expand Down Expand Up @@ -165,5 +170,7 @@ func updateValidatingWebhookCABundle(mgr ctrl.Manager, name, certDir string) err
for i := range webhook.Webhooks {
webhook.Webhooks[i].ClientConfig.CABundle = caBundle
}
return mgr.GetClient().Update(context.TODO(), webhook, &client.UpdateOptions{})
err = mgr.GetClient().Update(context.TODO(), webhook, &client.UpdateOptions{})
klog.Infof("Updating validating webhook caBundle to %s", caBundle)
return err
}

0 comments on commit 0fc10ae

Please sign in to comment.