Skip to content

Commit

Permalink
chore: cleanup some knative const, delete env SYSTEM_NAMESPACE FROM o…
Browse files Browse the repository at this point in the history
…perator.

Signed-off-by: Lan Liang <[email protected]>
  • Loading branch information
liangyuanpeng committed Aug 17, 2024
1 parent bb7468a commit da6f325
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 15 deletions.
4 changes: 0 additions & 4 deletions kwok/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ spec:
value: "{{ .Values.controller.metrics.port }}"
- name: HEALTH_PROBE_PORT
value: "{{ .Values.controller.healthProbe.port }}"
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MEMORY_LIMIT
valueFrom:
resourceFieldRef:
Expand Down
4 changes: 1 addition & 3 deletions pkg/operator/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"go.uber.org/zap/zapcore"
"knative.dev/pkg/changeset"

"knative.dev/pkg/logging/logkey"

"sigs.k8s.io/karpenter/pkg/operator/options"
)

Expand Down Expand Up @@ -84,7 +82,7 @@ func WithCommit(logger *zap.Logger) *zap.Logger {
return logger
}
// Enrich logs with the components git revision.
return logger.With(zap.String(logkey.Commit, revision))
return logger.With(zap.String("commit", revision))
}

type ignoreDebugEventsSink struct {
Expand Down
3 changes: 0 additions & 3 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import (
"k8s.io/utils/clock"
knativeinjection "knative.dev/pkg/injection"
"knative.dev/pkg/signals"
"knative.dev/pkg/system"
"knative.dev/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -113,7 +112,6 @@ type Operator struct {
func NewOperator() (context.Context, *Operator) {
// Root Context
ctx := signals.NewContext()
ctx = knativeinjection.WithNamespaceScope(ctx, system.Namespace())

// Options
ctx = injection.WithOptionsOrDie(ctx, options.Injectables...)
Expand Down Expand Up @@ -154,7 +152,6 @@ func NewOperator() (context.Context, *Operator) {
LeaderElection: !options.FromContext(ctx).DisableLeaderElection,
LeaderElectionID: "karpenter-leader-election",
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
LeaderElectionNamespace: system.Namespace(),
LeaderElectionReleaseOnCancel: true,
Metrics: server.Options{
BindAddress: fmt.Sprintf(":%d", options.FromContext(ctx).MetricsPort),
Expand Down
3 changes: 0 additions & 3 deletions pkg/test/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package test
import (
"context"
"log"
"os"
"strings"

"github.com/awslabs/operatorpkg/option"
Expand All @@ -30,7 +29,6 @@ import (
"k8s.io/apimachinery/pkg/util/version"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"knative.dev/pkg/system"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
Expand Down Expand Up @@ -88,7 +86,6 @@ func NewEnvironment(options ...option.Function[EnvironmentOptions]) *Environment
opts := option.Resolve(options...)
ctx, cancel := context.WithCancel(context.Background())

os.Setenv(system.NamespaceEnvKey, "default")
version := version.MustParseSemantic(strings.Replace(env.WithDefaultString("K8S_VERSION", "1.30.x"), ".x", ".0", -1))
environment := envtest.Environment{Scheme: scheme.Scheme, CRDs: opts.crds}
if version.Minor() >= 21 {
Expand Down
2 changes: 0 additions & 2 deletions test/pkg/environment/common/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
. "sigs.k8s.io/karpenter/pkg/utils/testing" //nolint:stylecheck
"sigs.k8s.io/karpenter/test/pkg/debug"

"knative.dev/pkg/system"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -77,7 +76,6 @@ func NewEnvironment(t *testing.T) *Environment {
config := NewConfig()
client := NewClient(ctx, config)

lo.Must0(os.Setenv(system.NamespaceEnvKey, "kube-system"))
if val, ok := os.LookupEnv("GIT_REF"); ok {
ctx = context.WithValue(ctx, GitRefContextKey, val)
}
Expand Down

0 comments on commit da6f325

Please sign in to comment.