Skip to content

Commit

Permalink
add jetstream CRD & Re-optimized the directory structure and file nam…
Browse files Browse the repository at this point in the history
…e to support streaming and jetstream
  • Loading branch information
zhaojizhuang committed Jul 8, 2021
1 parent deaf01f commit 3e23249
Show file tree
Hide file tree
Showing 31 changed files with 962 additions and 70 deletions.
4 changes: 2 additions & 2 deletions cmd/channel_controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/signals"

"knative.dev/eventing-natss/pkg/reconciler/controller"
"knative.dev/eventing-natss/pkg/reconciler/controller/natss"
)

const component = "natsschannel-controller"
Expand All @@ -41,6 +41,6 @@ func main() {
}

sharedmain.MainWithContext(ctx, component, func(ctx context.Context, watcher configmap.Watcher) *kncontroller.Impl {
return controller.NewController(ctx)
return natss.NewController(ctx)
})
}
7 changes: 3 additions & 4 deletions cmd/channel_dispatcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ package main
import (
"os"

controller "knative.dev/eventing-natss/pkg/reconciler/dispatcher"

"knative.dev/pkg/injection"
"knative.dev/pkg/injection/sharedmain"

"knative.dev/pkg/signals"

"knative.dev/eventing-natss/pkg/reconciler/dispatcher/natss"
)

const component = "natsschannel-dispatcher"
Expand All @@ -36,5 +35,5 @@ func main() {
ctx = injection.WithNamespaceScope(ctx, ns)
}

sharedmain.MainWithContext(ctx, component, controller.NewController)
sharedmain.MainWithContext(ctx, component, natss.NewController)
}
4 changes: 2 additions & 2 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func NewValidationAdmissionController(ctx context.Context, cmw configmap.Watcher
func main() {
// Set up a signal context with our webhook options
ctx := webhook.WithOptions(signals.NewContext(), webhook.Options{
ServiceName: "natss-webhook",
ServiceName: "nats-webhook",
Port: webhook.PortFromEnv(8443),
// SecretName must match the name of the Secret created in the configuration.
SecretName: "natss-webhook-certs",
SecretName: "nats-webhook-certs",
})

sharedmain.WebhookMainWithContext(ctx, "natss-webhook",
Expand Down
6 changes: 4 additions & 2 deletions config/200-addressable-resolver-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: natss-addressable-resolver
name: nats-addressable-resolver
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
Expand All @@ -26,6 +26,8 @@ rules:
resources:
- natsschannels
- natsschannels/status
- jetstreamschannels
- jetstreamchannels/status
verbs:
- get
- list
Expand Down
6 changes: 4 additions & 2 deletions config/200-channelable-manipulator-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: natss-channelable-manipulator
name: nats-channelable-manipulator
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
duck.knative.dev/channelable: "true"
# Do not use this role directly. These rules will be added to the "channelable-manipulator" role.
rules:
Expand All @@ -26,6 +26,8 @@ rules:
resources:
- natsschannels
- natsschannels/status
- jetstreamschannels
- jetstreamschannels/status
verbs:
- create
- get
Expand Down
7 changes: 5 additions & 2 deletions config/200-controller-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: natss-ch-controller
name: nats-ch-controller
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
rules:
- apiGroups:
- messaging.knative.dev
resources:
- natsschannels
- natsschannels/status
- jetstreamchannels
- jetstreamchannels/status
verbs:
- get
- list
Expand All @@ -34,6 +36,7 @@ rules:
- messaging.knative.dev
resources:
- natsschannels/finalizers
- jetstreamchannels/finalizers
verbs:
- update
- apiGroups:
Expand Down
5 changes: 4 additions & 1 deletion config/200-dispatcher-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: natss-ch-dispatcher
name: nats-ch-dispatcher
rules:
- apiGroups:
- messaging.knative.dev
resources:
- natsschannels
- natsschannels/status
- jetstreamchannels
- jetstreamchannels/status
verbs:
- get
- list
Expand All @@ -32,6 +34,7 @@ rules:
- messaging.knative.dev
resources:
- natsschannels/finalizers
- jetstreamchannels/finalizers
verbs:
- update
- apiGroups:
Expand Down
2 changes: 1 addition & 1 deletion config/200-dispatcher-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
name: natss-ch-dispatcher
namespace: knative-eventing
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
messaging.knative.dev/channel: natss-channel
messaging.knative.dev/role: dispatcher
spec:
Expand Down
8 changes: 4 additions & 4 deletions config/200-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: natss-ch-controller
name: nats-ch-controller
namespace: knative-eventing
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: natss-ch-dispatcher
name: nats-ch-dispatcher
namespace: knative-eventing
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
4 changes: 2 additions & 2 deletions config/200-webhook-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: natss-webhook
name: nats-webhook
labels:
natss.messaging.knative.dev/release: devel
nats.messaging.knative.dev/release: devel
rules:
# For watching logging configuration and getting certs.
- apiGroups:
Expand Down
14 changes: 7 additions & 7 deletions config/201-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: natss-ch-controller
name: nats-ch-controller
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
subjects:
- kind: ServiceAccount
name: natss-ch-controller
name: nats-ch-controller
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: natss-ch-controller
name: nats-ch-controller
apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: natss-ch-dispatcher
name: nats-ch-dispatcher
subjects:
- kind: ServiceAccount
name: natss-ch-dispatcher
name: nats-ch-dispatcher
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: natss-ch-dispatcher
name: nats-ch-dispatcher
apiGroup: rbac.authorization.k8s.io

12 changes: 6 additions & 6 deletions config/201-webhook-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: natss-webhook
name: nats-webhook
namespace: knative-eventing
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: natss-webhook
name: nats-webhook
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
subjects:
- kind: ServiceAccount
name: natss-webhook
name: nats-webhook
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: natss-webhook
name: nats-webhook
apiGroup: rbac.authorization.k8s.io
2 changes: 1 addition & 1 deletion config/300-natss-channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kind: CustomResourceDefinition
metadata:
name: natsschannels.messaging.knative.dev
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
knative.dev/crd-install: "true"
messaging.knative.dev/subscribable: "true"
duck.knative.dev/addressable: "true"
Expand Down
4 changes: 2 additions & 2 deletions config/400-webhook-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
apiVersion: v1
kind: Secret
metadata:
name: natss-webhook-certs
name: nats-webhook-certs
namespace: knative-eventing
labels:
natss.messaging.knative.dev/release: devel
nats.messaging.knative.dev/release: devel
# The data is populated at install time.
4 changes: 2 additions & 2 deletions config/500-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
name: natss-ch-controller
namespace: knative-eventing
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
spec:
replicas: 1
selector:
Expand All @@ -29,7 +29,7 @@ spec:
metadata:
labels: *labels
spec:
serviceAccountName: natss-ch-controller
serviceAccountName: nats-ch-controller
containers:
- name: controller
image: ko://knative.dev/eventing-natss/cmd/channel_controller
Expand Down
4 changes: 2 additions & 2 deletions config/500-dispatcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
name: natss-ch-dispatcher
namespace: knative-eventing
labels:
natss.eventing.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
spec:
replicas: 1
selector:
Expand All @@ -29,7 +29,7 @@ spec:
metadata:
labels: *labels
spec:
serviceAccountName: natss-ch-dispatcher
serviceAccountName: nats-ch-dispatcher
containers:
- name: dispatcher
image: ko://knative.dev/eventing-natss/cmd/channel_dispatcher
Expand Down
8 changes: 4 additions & 4 deletions config/500-webhook-defaulting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: webhook.natss.messaging.knative.dev
name: webhook.nats.messaging.knative.dev
labels:
natss.messaging.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
webhooks:
- admissionReviewVersions: ["v1beta1"]
clientConfig:
service:
name: natss-webhook
name: nats-webhook
namespace: knative-eventing
sideEffects: None
failurePolicy: Fail
name: webhook.natss.messaging.knative.dev
name: webhook.nats.messaging.knative.dev
timeoutSeconds: 2
8 changes: 4 additions & 4 deletions config/500-webhook-resource-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: validation.webhook.natss.messaging.knative.dev
name: validation.webhook.nats.messaging.knative.dev
labels:
natss.messaging.knative.dev/release: devel
nats.eventing.knative.dev/release: devel
webhooks:
- admissionReviewVersions: ["v1beta1"]
clientConfig:
service:
name: natss-webhook
name: nats-webhook
namespace: knative-eventing
sideEffects: None
failurePolicy: Fail
name: validation.webhook.natss.messaging.knative.dev
name: validation.webhook.nats.messaging.knative.dev
timeoutSeconds: 2
Loading

0 comments on commit 3e23249

Please sign in to comment.