-
Notifications
You must be signed in to change notification settings - Fork 38
Include cluster UID in CONTROLLER_IDENTITY to prevent cross-cluster conflicts #307
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
Changes from 13 commits
356babc
c8be5a7
fbde10c
308207d
7632df8
3cd636b
4f88ede
bc0eb7f
629216e
a267835
22ede91
4df3f34
8eeb0d7
87c2006
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "flag" | ||
| "log/slog" | ||
| "os" | ||
|
|
@@ -13,7 +14,9 @@ import ( | |
| "github.com/temporalio/temporal-worker-controller/internal/controller" | ||
| "github.com/temporalio/temporal-worker-controller/internal/controller/clientpool" | ||
| "go.temporal.io/sdk/log" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
| clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||
| // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) | ||
|
|
@@ -112,6 +115,25 @@ func main() { | |
| os.Exit(1) | ||
| } | ||
|
|
||
| if os.Getenv(controller.IdentityEnvKey) == "" { | ||
| setupLog.Error(nil, "CONTROLLER_IDENTITY environment variable must be set") | ||
| os.Exit(1) | ||
| } | ||
| podNamespace := os.Getenv("POD_NAMESPACE") | ||
| if podNamespace == "" { | ||
| setupLog.Error(nil, "POD_NAMESPACE environment variable must be set") | ||
| os.Exit(1) | ||
| } | ||
| var ns corev1.Namespace | ||
| if err := mgr.GetAPIReader().Get(context.Background(), types.NamespacedName{Name: podNamespace}, &ns); err != nil { | ||
| setupLog.Error(err, "unable to fetch namespace UID for controller identity") | ||
| os.Exit(1) | ||
| } | ||
| if err := os.Setenv(controller.IdentityEnvKey, os.Getenv(controller.IdentityEnvKey)+"/"+string(ns.UID)); err != nil { | ||
| setupLog.Error(err, "unable to set CONTROLLER_IDENTITY") | ||
| os.Exit(1) | ||
| } | ||
|
Comment on lines
+132
to
+135
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so i have a feeling that this won't work only because we don't have the worker-controller's RBAC policies updated i checked here and noticed that the my feeling is that this call would then fail but happy to be proven wrong!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note - i just found out that envTest also won't test this since it's spins up a cluster with a permissive auth mode
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should just add describe namespace permission to the auth then, right? |
||
|
|
||
| setupLog.Info("starting manager") | ||
| if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { | ||
| setupLog.Error(err, "problem running manager") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already needed for WRT webhook (SA checks)