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

User can specify the namespace in yaml for knative-eventing #711

Merged
merged 6 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ required = [
# TODO why is this overridden?
[[override]]
name = "github.com/knative/pkg"
# HEAD as of 2019-01-16
revision = "d3a9e54be7d4213b4018135d82b586de45f6a694"
# HEAD as of 2019-2-11
revision = "ac1f8182274a10bde23df8f964484bce87f06752"

[[constraint]]
name = "github.com/knative/serving"
Expand Down
4 changes: 2 additions & 2 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/logconfig"
"github.com/knative/eventing/pkg/system"
"github.com/knative/pkg/system"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
"github.com/knative/pkg/configmap"
"github.com/knative/pkg/logging"
Expand Down Expand Up @@ -92,7 +92,7 @@ func main() {
}

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace)
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())
configMapWatcher.Watch(logconfig.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, logconfig.Controller, logconfig.Controller))
if err = configMapWatcher.Start(stopCh); err != nil {
logger.Fatalf("Failed to start controller config map watcher: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/fanoutsidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/knative/eventing/pkg/sidecar/configmap/filesystem"
"github.com/knative/eventing/pkg/sidecar/configmap/watcher"
"github.com/knative/eventing/pkg/sidecar/swappable"
"github.com/knative/eventing/pkg/system"
"github.com/knative/pkg/system"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -61,7 +61,7 @@ var (
func init() {
flag.IntVar(&port, "sidecar_port", -1, "The port to run the sidecar on.")
flag.StringVar(&configMapNoticer, "config_map_noticer", "", fmt.Sprintf("The system to notice changes to the ConfigMap. Valid values are: %s", configMapNoticerValues()))
flag.StringVar(&configMapNamespace, "config_map_namespace", system.Namespace, "The namespace of the ConfigMap that is watched for configuration.")
flag.StringVar(&configMapNamespace, "config_map_namespace", system.Namespace(), "The namespace of the ConfigMap that is watched for configuration.")
flag.StringVar(&configMapName, "config_map_name", defaultConfigMapName, "The name of the ConfigMap that is watched for configuration.")
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/logconfig"
"github.com/knative/eventing/pkg/system"
"github.com/knative/pkg/system"

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -69,7 +69,7 @@ func main() {
}

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace)
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())

configMapWatcher.Watch(logconfig.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, logconfig.Webhook, logconfig.Webhook))

Expand All @@ -86,7 +86,7 @@ func main() {
options := webhook.ControllerOptions{
ServiceName: "webhook",
DeploymentName: "webhook",
Namespace: system.Namespace,
Namespace: system.Namespace(),
Port: 443,
SecretName: "webhook-certs",
WebhookName: "webhook.eventing.knative.dev",
Expand Down
5 changes: 5 additions & 0 deletions config/500-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ spec:
volumeMounts:
- name: config-logging
mountPath: /etc/config-logging
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumes:
- name: config-logging
configMap:
Expand Down
5 changes: 5 additions & 0 deletions config/500-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ spec:
volumeMounts:
- name: config-logging
mountPath: /etc/config-logging
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumes:
- name: config-logging
configMap:
Expand Down
10 changes: 10 additions & 0 deletions config/provisioners/in-memory-channel/in-memory-channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ spec:
containers:
- name: controller
image: github.com/knative/eventing/pkg/provisioners/inmemory/controller
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

---

Expand Down Expand Up @@ -217,3 +222,8 @@ spec:
- --config_map_noticer=watcher
- --config_map_namespace=knative-eventing
- --config_map_name=in-memory-channel-dispatcher-config-map
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
19 changes: 19 additions & 0 deletions contrib/gcppubsub/config/gcppubsub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ spec:
value: gcppubsub-channel-key
- name: DEFAULT_SECRET_KEY
value: key.json
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

---

Expand Down Expand Up @@ -209,6 +214,20 @@ spec:
containers:
- name: dispatcher
image: github.com/knative/eventing/contrib/gcppubsub/pkg/dispatcher/cmd
env:
- name: DEFAULT_GCP_PROJECT
value: REPLACE_WITH_GCP_PROJECT
- name: DEFAULT_SECRET_NAMESPACE
value: knative-eventing
- name: DEFAULT_SECRET_NAME
value: gcppubsub-channel-key
- name: DEFAULT_SECRET_KEY
value: key.json
env:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops

- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

---

Expand Down
1 change: 1 addition & 0 deletions contrib/gcppubsub/pkg/controller/channel/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
util "github.com/knative/eventing/pkg/provisioners"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
_ "github.com/knative/pkg/system/testing"
"github.com/knative/eventing/pkg/utils"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
"go.uber.org/zap"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
_ "github.com/knative/pkg/system/testing"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
_ "github.com/knative/pkg/system/testing"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions contrib/kafka/cmd/dispatcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
provisionerController "github.com/knative/eventing/contrib/kafka/pkg/controller"
"github.com/knative/eventing/contrib/kafka/pkg/dispatcher"
"github.com/knative/eventing/pkg/sidecar/configmap/watcher"
"github.com/knative/eventing/pkg/system"
"github.com/knative/pkg/system"
)

func main() {
Expand All @@ -42,7 +42,7 @@ func main() {
}
configMapNamespace := os.Getenv("DISPATCHER_CONFIGMAP_NAMESPACE")
if configMapNamespace == "" {
configMapNamespace = system.Namespace
configMapNamespace = system.Namespace()
}

logger, err := zap.NewProduction()
Expand Down
5 changes: 5 additions & 0 deletions contrib/kafka/config/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ spec:
volumeMounts:
- name: kafka-channel-controller-config
mountPath: /etc/config-provisioner
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumes:
- name: kafka-channel-controller-config
configMap:
Expand Down
4 changes: 2 additions & 2 deletions contrib/kafka/pkg/controller/channel/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

common "github.com/knative/eventing/contrib/kafka/pkg/controller"
eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/system"
"github.com/knative/pkg/system"
)

const (
Expand All @@ -43,7 +43,7 @@ const (

var (
defaultConfigMapKey = types.NamespacedName{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: common.DispatcherConfigMapName,
}
)
Expand Down
1 change: 1 addition & 0 deletions contrib/kafka/pkg/controller/channel/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package channel
import (
"testing"

_ "github.com/knative/pkg/system/testing"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
3 changes: 2 additions & 1 deletion contrib/kafka/pkg/controller/channel/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/knative/eventing/pkg/provisioners"
util "github.com/knative/eventing/pkg/provisioners"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
_ "github.com/knative/pkg/system/testing"
"github.com/knative/eventing/pkg/utils"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
Expand Down Expand Up @@ -538,7 +539,7 @@ func makeVirtualService() *istiov1alpha3.VirtualService {
},
Route: []istiov1alpha3.DestinationWeight{{
Destination: istiov1alpha3.Destination{
Host: "kafka-provisioner.knative-eventing.svc." + utils.GetClusterDomainName(),
Host: "kafka-provisioner.knative-testing.svc." + utils.GetClusterDomainName(),
Port: istiov1alpha3.PortSelector{
Number: util.PortNumber,
},
Expand Down
1 change: 1 addition & 0 deletions contrib/kafka/pkg/controller/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controller
import (
"testing"

_ "github.com/knative/pkg/system/testing"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

Expand Down
1 change: 1 addition & 0 deletions contrib/kafka/pkg/controller/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/knative/eventing/pkg/provisioners"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
_ "github.com/knative/pkg/system/testing"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
1 change: 1 addition & 0 deletions contrib/kafka/pkg/controller/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
_ "github.com/knative/pkg/system/testing"
)

func TestGetProvisionerConfigBrokers(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions contrib/kafka/pkg/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/knative/eventing/pkg/provisioners"
"github.com/knative/eventing/pkg/sidecar/fanout"
"github.com/knative/eventing/pkg/sidecar/multichannelfanout"
_ "github.com/knative/pkg/system/testing"
)

type mockConsumer struct {
Expand Down
10 changes: 10 additions & 0 deletions contrib/natss/config/provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ spec:
containers:
- name: controller
image: github.com/knative/eventing/contrib/natss/pkg/controller
env:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indenting seems off

- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

---

Expand Down Expand Up @@ -175,3 +180,8 @@ spec:
containers:
- name: dispatcher
image: github.com/knative/eventing/contrib/natss/pkg/dispatcher
env:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indenting seems off

- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
1 change: 1 addition & 0 deletions contrib/natss/pkg/controller/channel/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/knative/eventing/pkg/provisioners"
util "github.com/knative/eventing/pkg/provisioners"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
_ "github.com/knative/pkg/system/testing"
"github.com/knative/eventing/pkg/utils"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/provisioners"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
"github.com/knative/eventing/pkg/system"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
"github.com/knative/pkg/system"
_ "github.com/knative/pkg/system/testing"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -236,7 +237,7 @@ func makeK8sService() *corev1.Service {
Kind: "Service",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Namespace: system.Namespace(),
Name: fmt.Sprintf("%s-dispatcher", Name),
OwnerReferences: []metav1.OwnerReference{
{
Expand Down
1 change: 1 addition & 0 deletions contrib/natss/pkg/dispatcher/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/knative/eventing/pkg/apis/duck/v1alpha1"
eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/provisioners"
_ "github.com/knative/pkg/system/testing"
"github.com/nats-io/nats-streaming-server/server"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand Down
1 change: 1 addition & 0 deletions contrib/natss/pkg/stanutil/stanutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/knative/eventing/pkg/provisioners"
_ "github.com/knative/pkg/system/testing"
"github.com/nats-io/nats-streaming-server/server"
"go.uber.org/zap"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/provisioners/channel_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/reconciler/names"
"github.com/knative/eventing/pkg/system"
"github.com/knative/pkg/system"
"github.com/knative/eventing/pkg/utils"
"k8s.io/apimachinery/pkg/api/equality"
)
Expand Down Expand Up @@ -315,7 +315,7 @@ func virtualOldServiceLabels(c *eventingv1alpha1.Channel) map[string]string {
// appropriate OwnerReferences on the resource so handleObject can discover the Channel resource
// that 'owns' it. As well as being garbage collected when the Channel is deleted.
func newVirtualService(channel *eventingv1alpha1.Channel, svc *corev1.Service) *istiov1alpha3.VirtualService {
destinationHost := names.ServiceHostName(channelDispatcherServiceName(channel.Spec.Provisioner.Name), system.Namespace)
destinationHost := names.ServiceHostName(channelDispatcherServiceName(channel.Spec.Provisioner.Name), system.Namespace())
return &istiov1alpha3.VirtualService{
ObjectMeta: metav1.ObjectMeta{
GenerateName: channelVirtualServiceName(channel.Name),
Expand Down
Loading