diff --git a/Dockerfile b/Dockerfile index 3a7aec9..e68cecc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,7 @@ WORKDIR / COPY --from=manager-builder /workspace/manager . USER 65532:65532 +ENV OPERATOR_MODE=production ENV DEPLOYER_API_URL=https://deploy.wandb.ai/api ENTRYPOINT ["/manager"] diff --git a/main.go b/main.go index 27f93cf..1cdf634 100644 --- a/main.go +++ b/main.go @@ -39,6 +39,8 @@ import ( var ( scheme = runtime.NewScheme() setupLog = ctrl.Log.WithName("setup") + + mode = os.Getenv("OPERATOR_MODE") ) func init() { @@ -59,7 +61,8 @@ func main() { "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") - opts := zap.Options{Development: true} + development := mode != "production" + opts := zap.Options{Development: development} opts.BindFlags(flag.CommandLine) flag.Parse() diff --git a/pkg/wandb/cdk8s/operator.go b/pkg/wandb/cdk8s/operator.go index 8615e8d..764759a 100644 --- a/pkg/wandb/cdk8s/operator.go +++ b/pkg/wandb/cdk8s/operator.go @@ -1,6 +1,8 @@ package cdk8s import ( + "os" + v1 "github.com/wandb/operator/api/v1" "github.com/wandb/operator/pkg/wandb/cdk8s/config" "github.com/wandb/operator/pkg/wandb/cdk8s/release" @@ -14,10 +16,17 @@ type operatorChannel struct { } func (c operatorChannel) Recommend(_ *config.Config) *config.Config { + opNs := os.Getenv("OPERATOR_NAMESPACE") + if opNs == "" { + opNs = "wandb" + } gvk, _ := apiutil.GVKForObject(c.wandb, c.scheme) return &config.Config{ Config: map[string]interface{}{ "console": map[string]interface{}{ + "operator": map[string]interface{}{ + "namespace": os.Getenv("OPERATOR_NAMESPACE"), + }, "name": c.wandb.GetName(), "namespace": c.wandb.GetNamespace(), },