Skip to content

Commit

Permalink
Enhance support for control-plane split
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Bigler <[email protected]>
  • Loading branch information
TheBigLee committed Oct 30, 2024
1 parent 12d2103 commit 456f498
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 27 deletions.
56 changes: 30 additions & 26 deletions cmd/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type controller struct {
leaderElect bool
enableWebhooks bool
enableAppcatWebhooks bool
enableProviderWebhooks bool
enableQuotas bool
enableEventForwarding bool
certDir string
Expand All @@ -46,6 +47,7 @@ func init() {
"Enabling this will ensure there is only one active controller manager.")
ControllerCMD.Flags().BoolVar(&c.enableWebhooks, "webhooks", true, "Disable the validation webhooks.")
ControllerCMD.Flags().BoolVar(&c.enableAppcatWebhooks, "appcat-webhooks", true, "Disable the appcat validation webhooks")
ControllerCMD.Flags().BoolVar(&c.enableProviderWebhooks, "provider-webhooks", true, "Disable the provider validation webhooks")
ControllerCMD.Flags().StringVar(&c.certDir, "certdir", "/etc/webhook/certs", "Set the webhook certificate directory")
ControllerCMD.Flags().BoolVar(&c.enableQuotas, "quotas", false, "Enable the quota webhooks, is only active if webhooks is also true")
ControllerCMD.Flags().BoolVar(&c.enableEventForwarding, "event-forwarding", true, "Disable event-forwarding")
Expand Down Expand Up @@ -96,7 +98,7 @@ func (c *controller) executeController(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("PLANS_NAMEPSACE env variable needs to be set for quota support")
}

err := setupWebhooks(mgr, c.enableQuotas, c.enableAppcatWebhooks)
err := setupWebhooks(mgr, c.enableQuotas, c.enableAppcatWebhooks, c.enableProviderWebhooks)
if err != nil {
return err
}
Expand All @@ -112,7 +114,7 @@ func (c *controller) executeController(cmd *cobra.Command, _ []string) error {
return mgr.Start(ctrl.SetupSignalHandler())
}

func setupWebhooks(mgr manager.Manager, withQuota bool, withAppcatWebhooks bool) error {
func setupWebhooks(mgr manager.Manager, withQuota bool, withAppcatWebhooks bool, withProviderWebhooks bool) error {
if withAppcatWebhooks {
err := webhooks.SetupPostgreSQLWebhookHandlerWithManager(mgr, withQuota)
if err != nil {
Expand Down Expand Up @@ -149,31 +151,33 @@ func setupWebhooks(mgr manager.Manager, withQuota bool, withAppcatWebhooks bool)
}
}

err := webhooks.SetupNamespaceDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupReleaseDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupMysqlDatabaseDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupMysqlGrantDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupMysqlUserDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupObjectDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
if withProviderWebhooks {
err := webhooks.SetupReleaseDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupMysqlDatabaseDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupMysqlGrantDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupMysqlUserDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupObjectDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
err = webhooks.SetupObjectv1alpha1DeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
}
err = webhooks.SetupObjectv1alpha1DeletionProtectionHandlerWithManager(mgr)
err := webhooks.SetupNamespaceDeletionProtectionHandlerWithManager(mgr)
if err != nil {
return err
}
Expand Down
18 changes: 17 additions & 1 deletion pkg/comp-functions/functions/common/instance_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"

xkube "github.com/vshn/appcat/v4/apis/kubernetes/v1alpha2"
"github.com/vshn/appcat/v4/apis/metadata"
v1 "github.com/vshn/appcat/v4/apis/vshn/v1"
"github.com/vshn/appcat/v4/pkg/common/quotas"
Expand Down Expand Up @@ -90,7 +91,22 @@ func createNamespaceObserver(claimNs string, instance string, svc *runtime.Servi
},
}

return svc.SetDesiredKubeObserveObject(ns, instance+claimNsObserverSuffix)
err := svc.SetDesiredKubeObserveObject(ns, instance+claimNsObserverSuffix)
if err != nil {
return err
}

nsObj := xkube.Object{}
err = svc.GetDesiredKubeObject(&nsObj, instance+claimNsObserverSuffix)
if err != nil {
return err
}

nsObj.SetLabels(map[string]string{
"appcat.vshn.io/provider-config": "local",
})

return svc.SetDesiredComposedResourceWithName(&nsObj, instance+claimNsObserverSuffix)
}

// Create the namespace for the service instance
Expand Down

0 comments on commit 456f498

Please sign in to comment.