Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CRDs in credentials operator to allow creds operator to start before intents operator with no CRDs in Helm chart #140

Merged
merged 1 commit into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/otterize/credentials-operator/src/operatorconfig"
otterizev1alpha3 "github.com/otterize/intents-operator/src/operator/api/v1alpha3"
mutatingwebhookconfiguration "github.com/otterize/intents-operator/src/operator/controllers/mutating_webhook_controller"
"github.com/otterize/intents-operator/src/operator/otterizecrds"
operatorwebhooks "github.com/otterize/intents-operator/src/operator/webhooks"
"github.com/otterize/intents-operator/src/shared"
"github.com/otterize/intents-operator/src/shared/awsagent"
Expand All @@ -62,6 +63,7 @@ import (
"github.com/spiffe/go-spiffe/v2/workloadapi"
"os"
"path"
"sigs.k8s.io/controller-runtime/pkg/client"
controllerruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -143,7 +145,7 @@ func main() {
LeaderElectionID: "credentials-operator.otterize.com",
})
if err != nil {
logrus.WithError(err).Panic("unable to start manager")
logrus.WithError(err).Panic("unable to initialize manager")
}

signalHandlerCtx := ctrl.SetupSignalHandler()
Expand All @@ -152,6 +154,18 @@ func main() {
logrus.Panic("POD_NAMESPACE environment variable is required")
}

directClient, err := client.New(ctrl.GetConfigOrDie(), client.Options{Scheme: mgr.GetScheme()})
if err != nil {
logrus.WithError(err).Panic("unable to create kubernetes API client")
}

// Required for cases where the intents operator starts after the credentials operator, and the credentials
// operator requires ClientIntents to be deployed.
err = otterizecrds.Ensure(signalHandlerCtx, directClient, podNamespace)
if err != nil {
logrus.WithError(err).Panic("unable to ensure otterize CRDs")
}

clusterUID, err := clusterutils.GetOrCreateClusterUID(signalHandlerCtx)
if err != nil {
logrus.WithError(err).Panic("Failed fetching cluster UID")
Expand Down
Loading