Skip to content

Commit

Permalink
fix: Add operator namespace env
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Jul 18, 2023
1 parent 3e37470 commit 846731a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")

mode = os.Getenv("OPERATOR_MODE")
)

func init() {
Expand All @@ -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()

Expand Down
9 changes: 9 additions & 0 deletions pkg/wandb/cdk8s/operator.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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(),
},
Expand Down

0 comments on commit 846731a

Please sign in to comment.