diff --git a/Gopkg.lock b/Gopkg.lock index 263222744b4..7acc78e174b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1378,7 +1378,7 @@ revision = "d65201fadb82dbdc5713f9ba9a1313150c7aa9b5" [[projects]] - digest = "1:a8495647d9f03401c36b801a0644207a434f76ed9d4fc4ea80c46700f0ccc575" + digest = "1:feab562c2e2852074e0c38310e19c4acf8cbb36746f7ad4ac2e60e61ceedff61" name = "sigs.k8s.io/controller-runtime" packages = [ "pkg/cache", @@ -1402,7 +1402,6 @@ "pkg/recorder", "pkg/runtime/inject", "pkg/runtime/log", - "pkg/runtime/signals", "pkg/source", "pkg/source/internal", "pkg/webhook/admission", @@ -1566,7 +1565,6 @@ "sigs.k8s.io/controller-runtime/pkg/reconcile", "sigs.k8s.io/controller-runtime/pkg/runtime/inject", "sigs.k8s.io/controller-runtime/pkg/runtime/log", - "sigs.k8s.io/controller-runtime/pkg/runtime/signals", "sigs.k8s.io/controller-runtime/pkg/source", "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types", ] diff --git a/cmd/in_memory/controller/kodata/LICENSE b/cmd/in_memory/controller/kodata/LICENSE deleted file mode 120000 index 14776154326..00000000000 --- a/cmd/in_memory/controller/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../../LICENSE \ No newline at end of file diff --git a/cmd/in_memory/controller/kodata/VENDOR-LICENSE b/cmd/in_memory/controller/kodata/VENDOR-LICENSE deleted file mode 120000 index 7322c09d957..00000000000 --- a/cmd/in_memory/controller/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/cmd/in_memory/controller/main.go b/cmd/in_memory/controller/main.go deleted file mode 100644 index fad58cbfa67..00000000000 --- a/cmd/in_memory/controller/main.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2018 The Knative Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "flag" - - // Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters). - // _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - - eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - "github.com/knative/eventing/pkg/provisioners" - "github.com/knative/eventing/pkg/provisioners/inmemory/channel" - "github.com/knative/eventing/pkg/provisioners/inmemory/clusterchannelprovisioner" - "go.uber.org/zap" - "knative.dev/pkg/signals" - "sigs.k8s.io/controller-runtime/pkg/client/config" - "sigs.k8s.io/controller-runtime/pkg/manager" -) - -func main() { - logConfig := provisioners.NewLoggingConfig() - logger := provisioners.NewProvisionerLoggerFromConfig(logConfig) - defer logger.Sync() - logger = logger.With( - zap.String("eventing.knative.dev/clusterChannelProvisioner", "in-memory"), - zap.String("eventing.knative.dev/clusterChannelProvisionerComponent", "Controller"), - ) - flag.Parse() - - mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{}) - if err != nil { - logger.Fatal("Error starting up.", zap.Error(err)) - } - - // Add custom types to this array to get them into the manager's scheme. - eventingv1alpha1.AddToScheme(mgr.GetScheme()) - - // The controllers for both the ClusterChannelProvisioner and the Channels created by that - // ClusterChannelProvisioner run in this process. - _, err = clusterchannelprovisioner.ProvideController(mgr, logger.Desugar()) - if err != nil { - logger.Fatal("Unable to create Provisioner controller", zap.Error(err)) - } - _, err = channel.ProvideController(mgr, logger.Desugar()) - if err != nil { - logger.Fatal("Unable to create Channel controller", zap.Error(err)) - } - - // set up signals so we handle the first shutdown signal gracefully - stopCh := signals.SetupSignalHandler() - // Start blocks forever. - err = mgr.Start(stopCh) - if err != nil { - logger.Fatal("Manager.Start() returned an error", zap.Error(err)) - } -} diff --git a/cmd/in_memory/dispatcher/kodata/LICENSE b/cmd/in_memory/dispatcher/kodata/LICENSE deleted file mode 120000 index 14776154326..00000000000 --- a/cmd/in_memory/dispatcher/kodata/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../../LICENSE \ No newline at end of file diff --git a/cmd/in_memory/dispatcher/kodata/VENDOR-LICENSE b/cmd/in_memory/dispatcher/kodata/VENDOR-LICENSE deleted file mode 120000 index 7322c09d957..00000000000 --- a/cmd/in_memory/dispatcher/kodata/VENDOR-LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/cmd/in_memory/dispatcher/main.go b/cmd/in_memory/dispatcher/main.go deleted file mode 100644 index 6834bbd14ed..00000000000 --- a/cmd/in_memory/dispatcher/main.go +++ /dev/null @@ -1,163 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "context" - "flag" - "fmt" - "log" - "net/http" - "strings" - "time" - - // Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters). - // _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - - "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" - "github.com/knative/eventing/pkg/channelwatcher" - "github.com/knative/eventing/pkg/provisioners/swappable" - "github.com/knative/eventing/pkg/tracing" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - "k8s.io/client-go/kubernetes" - "knative.dev/pkg/configmap" - "knative.dev/pkg/system" - pkgtracing "knative.dev/pkg/tracing" - "sigs.k8s.io/controller-runtime/pkg/client/config" - "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/runtime/signals" -) - -const ( - NAMESPACE = "NAMESPACE" -) - -var ( - readTimeout = 1 * time.Minute - writeTimeout = 1 * time.Minute - port = 8080 - channelProvisioners = []string{"in-memory"} -) - -func main() { - flag.Parse() - - lc := zap.NewProductionConfig() - lc.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder - logger, err := lc.Build() - if err != nil { - log.Fatalf("Unable to create logger: %v", err) - } - logger = logger.With( - zap.String("eventing.knative.dev/clusterChannelProvisioner", strings.Join(channelProvisioners, ",")), - zap.String("eventing.knative.dev/clusterChannelProvisionerComponent", "Dispatcher"), - ) - - sh, err := swappable.NewEmptyHandler(logger) - if err != nil { - logger.Fatal("Unable to create swappable.Handler", zap.Error(err)) - } - - mgr, err := setupChannelWatcher(logger, sh.UpdateConfig) - if err != nil { - logger.Fatal("Unable to create channel watcher.", zap.Error(err)) - } - - kc := kubernetes.NewForConfigOrDie(mgr.GetConfig()) - configMapWatcher := configmap.NewInformedWatcher(kc, system.Namespace()) - if err = tracing.SetupDynamicZipkinPublishing(logger.Sugar(), configMapWatcher, "in-memory-dispatcher"); err != nil { - logger.Fatal("Error setting up Zipkin publishing", zap.Error(err)) - } - - s := &http.Server{ - Addr: fmt.Sprintf(":%d", port), - Handler: pkgtracing.HTTPSpanMiddleware(sh), - ErrorLog: zap.NewStdLog(logger), - ReadTimeout: readTimeout, - WriteTimeout: writeTimeout, - } - - err = mgr.Add(&runnableServer{ - logger: logger, - s: s, - }) - if err != nil { - logger.Fatal("Unable to add ListenAndServe", zap.Error(err)) - } - - // set up signals so we handle the first shutdown signal gracefully - stopCh := signals.SetupSignalHandler() - - // configMapWatcher does not block, so start it first. - if err = configMapWatcher.Start(stopCh); err != nil { - logger.Fatal("Failed to start ConfigMap watcher", zap.Error(err)) - } - - // Start blocks forever. - if err = mgr.Start(stopCh); err != nil { - logger.Error("manager.Start() returned an error", zap.Error(err)) - } - logger.Info("Exiting...") - - ctx, cancel := context.WithTimeout(context.Background(), writeTimeout) - defer cancel() - if err = s.Shutdown(ctx); err != nil { - logger.Error("Shutdown returned an error", zap.Error(err)) - } -} - -func setupChannelWatcher(logger *zap.Logger, configUpdated swappable.UpdateConfig) (manager.Manager, error) { - mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{}) - if err != nil { - logger.Error("Error creating new manager.", zap.Error(err)) - return nil, err - } - if err = v1alpha1.AddToScheme(mgr.GetScheme()); err != nil { - logger.Error("Error while adding eventing scheme to manager.", zap.Error(err)) - return nil, err - } - if err = channelwatcher.New(mgr, logger, channelwatcher.UpdateConfigWatchHandler(configUpdated, shouldWatch)); err != nil { - logger.Error("Error making the channel watcher: %s", zap.Error(err)) - return nil, err - } - - return mgr, nil -} - -func shouldWatch(ch *v1alpha1.Channel) bool { - if ch.Spec.Provisioner != nil && ch.Spec.Provisioner.Namespace == "" { - for _, v := range channelProvisioners { - if v == ch.Spec.Provisioner.Name { - return true - } - } - } - return false -} - -// runnableServer is a small wrapper around http.Server so that it matches the manager.Runnable -// interface. -type runnableServer struct { - logger *zap.Logger - s *http.Server -} - -func (r *runnableServer) Start(<-chan struct{}) error { - r.logger.Info("in-memory dispatcher listening", zap.String("address", r.s.Addr)) - return r.s.ListenAndServe() -} diff --git a/config/provisioners/in-memory-channel/README.md b/config/provisioners/in-memory-channel/README.md deleted file mode 100644 index e7344afa8d8..00000000000 --- a/config/provisioners/in-memory-channel/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# In-Memory Channels - -> **NOTE:**: The _ClusterChannelProvisioner_ API is deprecated. Please use the -> [_InMemoryChannel_](../../channels/in-memory-channel) CRD instead. - -In-memory channels are a best effort Channel. They should **NOT** be used in -Production. They are useful for development. - -They differ from most Channels in that they have: - -- No persistence. - - If a Pod goes down, messages go with it. -- No ordering guarantee. - - There is nothing enforcing an ordering, so two messages that arrive at the - same time may go downstream in any order. - - Different downstream subscribers may see different orders. -- No redelivery attempts. - - If downstream rejects a request, a log message is written, but that request - is never sent again. - -### Deployment steps: - -1. Setup [Knative Eventing](../../../DEVELOPMENT.md). -1. Apply the 'in-memory' ClusterChannelProvisioner, Controller, and Dispatcher. - ```shell - ko apply -f config/provisioners/in-memory-channel/in-memory-channel.yaml - ``` -1. Create Channels that reference the 'in-memory'. - - ```yaml - apiVersion: eventing.knative.dev/v1alpha1 - kind: Channel - metadata: - name: foo - spec: - provisioner: - apiVersion: eventing.knative.dev/v1alpha1 - kind: ClusterChannelProvisioner - name: in-memory - ``` - -### Components - -The major components are: - -- ClusterChannelProvisioner Controller -- Channel Controller -- Channel Dispatcher -- Channel Dispatcher Config Map. - -The ClusterChannelProvisioner Controller and the Channel Controller are -colocated in one Pod. - -```shell -kubectl get deployment -n knative-eventing in-memory-channel-controller -``` - -The Channel Dispatcher receives and distributes all events. There is a single -Dispatcher for all in-memory Channels. - -```shell -kubectl get deployment -n knative-eventing in-memory-channel-dispatcher -``` diff --git a/config/provisioners/in-memory-channel/in-memory-channel.yaml b/config/provisioners/in-memory-channel/in-memory-channel.yaml deleted file mode 100644 index 9bbef77361d..00000000000 --- a/config/provisioners/in-memory-channel/in-memory-channel.yaml +++ /dev/null @@ -1,250 +0,0 @@ -# Copyright 2018 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: eventing.knative.dev/v1alpha1 -kind: ClusterChannelProvisioner -metadata: - name: in-memory - labels: - eventing.knative.dev/release: devel -spec: {} - ---- - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: in-memory-channel-controller - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: in-memory-channel-controller - labels: - eventing.knative.dev/release: devel -rules: - - apiGroups: - - eventing.knative.dev - resources: - - channels - - channels/status - - clusterchannelprovisioners - - clusterchannelprovisioners/status - verbs: - - get - - list - - watch - - update - - apiGroups: - - eventing.knative.dev - resources: - - channels/finalizers - - clusterchannelprovisioners/finalizers - verbs: - - update - - apiGroups: - - "" # Core API group. - resources: - - services - verbs: - - get - - list - - watch - - create - - apiGroups: - - "" # Core API group. - resources: - - services - verbs: - - update - - apiGroups: - - "" # Core API Group. - resources: - - events - verbs: - - create - - patch - - update - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: in-memory-channel-controller - labels: - eventing.knative.dev/release: devel -subjects: - - kind: ServiceAccount - name: in-memory-channel-controller - namespace: knative-eventing -roleRef: - kind: ClusterRole - name: in-memory-channel-controller - apiGroup: rbac.authorization.k8s.io - ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: in-memory-channel-controller - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel -spec: - replicas: 1 - selector: - matchLabels: &labels - clusterChannelProvisioner: in-memory-channel - role: controller - template: - metadata: - labels: *labels - spec: - serviceAccountName: in-memory-channel-controller - containers: - - name: controller - image: github.com/knative/eventing/cmd/in_memory/controller - env: - - name: SYSTEM_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - ---- - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: in-memory-channel-dispatcher - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: in-memory-channel-dispatcher - labels: - eventing.knative.dev/release: devel -rules: - - apiGroups: - - "eventing.knative.dev" - resources: - - "channels" - - "channels/status" - verbs: - - get - - list - - watch - - apiGroups: - - "" - resources: - - "configmaps" - verbs: - - get - - list - - watch - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: in-memory-channel-dispatcher - labels: - eventing.knative.dev/release: devel -subjects: - - kind: ServiceAccount - name: in-memory-channel-dispatcher - namespace: knative-eventing -roleRef: - kind: ClusterRole - name: in-memory-channel-dispatcher - apiGroup: rbac.authorization.k8s.io - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: in-memory-channel-dispatcher - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel -rules: - - apiGroups: - - "" - resources: - - "configmaps" - verbs: - - get - - list - - watch - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: in-memory-channel-dispatcher - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel -subjects: - - kind: ServiceAccount - name: in-memory-channel-dispatcher - namespace: knative-eventing -roleRef: - kind: Role - name: in-memory-channel-dispatcher - apiGroup: rbac.authorization.k8s.io - ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: in-memory-channel-dispatcher - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel -spec: - replicas: 1 - selector: - matchLabels: &labels - clusterChannelProvisioner: in-memory-channel - role: dispatcher - template: - metadata: - labels: *labels - spec: - serviceAccountName: in-memory-channel-dispatcher - containers: - - name: dispatcher - image: github.com/knative/eventing/cmd/in_memory/dispatcher - env: - - name: SYSTEM_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - diff --git a/hack/release.sh b/hack/release.sh index 2e2a8e254f6..42db6fbde27 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -23,8 +23,7 @@ source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/release.sh declare -A COMPONENTS COMPONENTS=( ["eventing.yaml"]="config" - ["in-memory-channel-crd.yaml"]="config/channels/in-memory-channel" - ["in-memory-channel-provisioner.yaml"]="config/provisioners/in-memory-channel" + ["in-memory-channel.yaml"]="config/channels/in-memory-channel" ["gcp-pubsub.yaml"]="contrib/gcppubsub/config" ["natss.yaml"]="contrib/natss/config" ) @@ -32,7 +31,7 @@ readonly COMPONENTS declare -A RELEASES RELEASES=( - ["release.yaml"]="eventing.yaml in-memory-channel-crd.yaml in-memory-channel-provisioner.yaml" + ["release.yaml"]="eventing.yaml in-memory-channel.yaml" ) readonly RELEASES diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/doc.go b/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/doc.go deleted file mode 100644 index 749321e7a10..00000000000 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package signals contains libraries for handling signals to shutdown the system. -package signals diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal.go b/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal.go deleted file mode 100644 index 6bddfddb4f9..00000000000 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package signals - -import ( - "os" - "os/signal" -) - -var onlyOneSignalHandler = make(chan struct{}) - -// SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned -// which is closed on one of these signals. If a second signal is caught, the program -// is terminated with exit code 1. -func SetupSignalHandler() (stopCh <-chan struct{}) { - close(onlyOneSignalHandler) // panics when called twice - - stop := make(chan struct{}) - c := make(chan os.Signal, 2) - signal.Notify(c, shutdownSignals...) - go func() { - <-c - close(stop) - <-c - os.Exit(1) // second signal. Exit directly. - }() - - return stop -} diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal_posix.go b/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal_posix.go deleted file mode 100644 index 9bdb4e7418b..00000000000 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal_posix.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !windows - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package signals - -import ( - "os" - "syscall" -) - -var shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal_windows.go b/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal_windows.go deleted file mode 100644 index 4907d573fe0..00000000000 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals/signal_windows.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package signals - -import ( - "os" -) - -var shutdownSignals = []os.Signal{os.Interrupt}