Skip to content
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
38 changes: 37 additions & 1 deletion Gopkg.lock

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

61 changes: 61 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2017 Google Inc. All Rights Reserved.
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"

"github.com/golang/glog"
"github.com/knative/eventing/pkg"
"github.com/knative/eventing/pkg/signals"
"github.com/knative/eventing/pkg/webhook"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)

func main() {
flag.Parse()
defer glog.Flush()

glog.Info("Starting the Configuration Webhook")

// set up signals so we handle the first shutdown signal gracefully
stopCh := signals.SetupSignalHandler()

clusterConfig, err := rest.InClusterConfig()
if err != nil {
glog.Fatal("Failed to get in cluster config", err)
}

clientset, err := kubernetes.NewForConfig(clusterConfig)
if err != nil {
glog.Fatal("Failed to get the client set", err)
}

options := webhook.ControllerOptions{
ServiceName: "eventing-webhook",
ServiceNamespace: pkg.GetEventingSystemNamespace(),
Port: 443,
SecretName: "eventing-webhook-certs",
WebhookName: "webhook.eventing.knative.dev",
}
controller, err := webhook.NewAdmissionController(clientset, options)
if err != nil {
glog.Fatal("Failed to create the admission controller", err)
}
controller.Run(stopCh)
}
27 changes: 27 additions & 0 deletions config/webhook-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2018 Google LLC
#
# 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.

apiVersion: v1
kind: Service
metadata:
labels:
role: eventing-webhook
name: eventing-webhook
namespace: knative-eventing-system
spec:
ports:
- port: 443
targetPort: 443
selector:
role: eventing-webhook
35 changes: 35 additions & 0 deletions config/webhook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2018 Google LLC
#
# 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.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: eventing-webhook
namespace: knative-eventing-system
spec:
replicas: 1
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
app: eventing-webhook
role: eventing-webhook
spec:
serviceAccountName: bind-controller
containers:
- name: eventing-webhook
# This is the Go import path for the binary that is containerized
# and substituted here.
image: github.com/knative/eventing/cmd/webhook
6 changes: 6 additions & 0 deletions pkg/apis/channels/v1alpha1/bus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package v1alpha1

import (
"encoding/json"

kapi "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -51,6 +53,10 @@ type BusSpec struct {
type BusStatus struct {
}

func (b *Bus) GetSpecJSON() ([]byte, error) {
return json.Marshal(b.Spec)
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// BusList returned in list operations
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/channels/v1alpha1/channel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package v1alpha1

import (
"encoding/json"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -50,6 +52,10 @@ type ChannelSpec struct {
type ChannelStatus struct {
}

func (c *Channel) GetSpecJSON() ([]byte, error) {
return json.Marshal(c.Spec)
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ChannelList returned in list operations
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/channels/v1alpha1/subscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package v1alpha1

import (
"encoding/json"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -50,6 +52,10 @@ type SubscriptionSpec struct {
type SubscriptionStatus struct {
}

func (s *Subscription) GetSpecJSON() ([]byte, error) {
return json.Marshal(s.Spec)
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// SubscriptionList returned in list operations
Expand Down
23 changes: 23 additions & 0 deletions pkg/names.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2018 Google LLC

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 pkg

// GetEventingSystemNamespace returns the namespace where
// eventing controllers are deployed to.
func GetEventingSystemNamespace() string {
return "knative-eventing-system"
}
Loading