Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.
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: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ jobs:
name: Cloning config repository
command: git clone --single-branch git@github.com:triggermesh/config.git tmconfig
- run:
name: Updating overlays/<< parameters.cluster >>/filter manifests
name: Updating overlays/<< parameters.cluster >>/routing manifests
working_directory: tmconfig/
command: |
for cmd in $(sed -n -e 's/^COMMANDS[[:space:]]*=[[:space:]]*\(.*\)$/\1/p' ~/project/Makefile); do
sed -i overlays/<< parameters.cluster >>/filter/${cmd}.yaml \
sed -i overlays/<< parameters.cluster >>/routing/${cmd}.yaml \
-e "s|\(gcr.io/triggermesh-private/${cmd}:\).*|\1${CIRCLE_TAG:-${CIRCLE_SHA1}}|g"
done
git --no-pager diff
- run:
name: Committing overlays/<< parameters.cluster >>/filter updates
name: Committing overlays/<< parameters.cluster >>/routing updates
working_directory: tmconfig/
command: |
git add overlays
git commit -m "Update overlays/<< parameters.cluster >>/filter deployments to '${CIRCLE_TAG:-${CIRCLE_SHA1}}'"
git commit -m "Update overlays/<< parameters.cluster >>/routing deployments to '${CIRCLE_TAG:-${CIRCLE_SHA1}}'"
git push origin master

release:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
KREPO = filter
KREPO_DESC = Triggermesh Filter
COMMANDS = filter-controller filter-deployment filter-webhook
KREPO = routing
KREPO_DESC = Triggermesh Routing
COMMANDS = routing-controller routing-webhook filter-deployment

TARGETS ?= linux/amd64

Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ options:
substitution_option: ALLOW_LOOSE

tags:
- filter
- routing
25 changes: 10 additions & 15 deletions cmd/filter-deployment/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import (
"knative.dev/pkg/signals"
"knative.dev/pkg/system"

filterv1alpha1 "github.com/triggermesh/filter/pkg/client/generated/clientset/internalclientset"
filterinformers "github.com/triggermesh/filter/pkg/client/generated/informers/externalversions"
"github.com/triggermesh/filter/pkg/reconciler/config"
"github.com/triggermesh/filter/pkg/reconciler/filter"
"github.com/triggermesh/routing/pkg/adapter/filter"
clientset "github.com/triggermesh/routing/pkg/client/generated/clientset/internalclientset"
informers "github.com/triggermesh/routing/pkg/client/generated/informers/externalversions"
"github.com/triggermesh/routing/pkg/reconciler/config"
)

const (
Expand All @@ -45,10 +45,7 @@ const (

type envConfig struct {
Namespace string `envconfig:"NAMESPACE" required:"true"`
// TODO: change this environment variable to something like "PodGroupName".
PodName string `envconfig:"POD_NAME" required:"true"`
ContainerName string `envconfig:"CONTAINER_NAME" required:"true"`
Port int `envconfig:"FILTER_PORT" default:"8080"`
Port int `envconfig:"FILTER_PORT" default:"8080"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a question since this code already existed before this PR: what's the case for making this configurable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

tbh, I cannot make up the real case when this may need to be changed, but at the same time cannot see anything harmful in it either. I'd say that we can leave it until the next time we change something in that part of the code.

}

func main() {
Expand Down Expand Up @@ -77,9 +74,9 @@ func main() {

logger.Info("Starting the Filter")

filterClient := filterv1alpha1.NewForConfigOrDie(cfg)
filterFactory := filterinformers.NewSharedInformerFactory(filterClient, controller.GetResyncPeriod(ctx))
filterInformer := filterFactory.Routing().V1alpha1().Filters()
routingClient := clientset.NewForConfigOrDie(cfg)
routingFactory := informers.NewSharedInformerFactory(routingClient, controller.GetResyncPeriod(ctx))
filterInformer := routingFactory.Routing().V1alpha1().Filters()

// Watch the logging config map and dynamically update logging levels.
configMapWatcher := configmap.NewInformedWatcher(kubeClient, system.Namespace())
Expand All @@ -96,8 +93,6 @@ func main() {
// Watch the observability config map and dynamically update request logs.
configMapWatcher.Watch(logging.ConfigMapName(), logging.UpdateLevelFromConfigMap(sl, atomicLevel, component))

// reporter := filter.NewStatsReporter(env.ContainerName, kmeta.ChildName(env.PodName, uuid.New().String()))

// We are running both the receiver (takes messages in from the Broker) and the dispatcher (send
// the messages to the triggers' subscribers) in this binary.
handler, err := filter.NewHandler(logger, filterInformer.Lister(), env.Port)
Expand All @@ -113,8 +108,8 @@ func main() {
// Start all of the informers and wait for them to sync.
logger.Info("Starting informer.")

go filterFactory.Start(ctx.Done())
filterFactory.WaitForCacheSync(ctx.Done())
go routingFactory.Start(ctx.Done())
routingFactory.WaitForCacheSync(ctx.Done())

// Start blocks forever.
logger.Info("Filter starting...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOARCH amd64

WORKDIR /go/src/filter-controller
WORKDIR /go/src/routing-controller

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN BIN_OUTPUT_DIR=/bin make filter-controller && \
RUN BIN_OUTPUT_DIR=/bin make routing-controller && \
mkdir /kodata && \
ls -lah hack && \
mv .git/* /kodata/ && \
Expand All @@ -20,7 +20,7 @@ RUN BIN_OUTPUT_DIR=/bin make filter-controller && \
FROM scratch

COPY --from=builder /kodata/ ${KO_DATA_PATH}/
COPY --from=builder /bin/filter-controller /
COPY --from=builder /bin/routing-controller /
COPY licenses/ /licenses/

ENTRYPOINT ["/filter-controller"]
ENTRYPOINT ["/routing-controller"]
10 changes: 5 additions & 5 deletions cmd/filter-controller/main.go → cmd/routing-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ import (
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/signals"

"github.com/triggermesh/filter/pkg/reconciler/config"
"github.com/triggermesh/filter/pkg/reconciler/controller"
"github.com/triggermesh/routing/pkg/reconciler/config"
"github.com/triggermesh/routing/pkg/reconciler/filter"
)

const (
component = "filter-service"
component = "routing-service"
)

func main() {
var filterEnv controller.FilterService
var filterEnv filter.FilterService
if err := envconfig.Process("", &filterEnv); err != nil {
log.Fatal("Failed to process env var", zap.Error(err))
}

ctx := signals.NewContext()
sharedmain.MainWithContext(config.WithFilterService(ctx, filterEnv),
component, controller.New)
component, filter.New)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOARCH amd64

WORKDIR /go/src/filter-webhook
WORKDIR /go/src/routing-webhook

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN BIN_OUTPUT_DIR=/bin make filter-webhook && \
RUN BIN_OUTPUT_DIR=/bin make routing-webhook && \
mkdir /kodata && \
ls -lah hack && \
mv .git/* /kodata/ && \
Expand All @@ -20,7 +20,7 @@ RUN BIN_OUTPUT_DIR=/bin make filter-webhook && \
FROM scratch

COPY --from=builder /kodata/ ${KO_DATA_PATH}/
COPY --from=builder /bin/filter-webhook /
COPY --from=builder /bin/routing-webhook /
COPY licenses/ /licenses/

ENTRYPOINT ["/filter-webhook"]
ENTRYPOINT ["/routing-webhook"]
4 changes: 2 additions & 2 deletions cmd/filter-webhook/main.go → cmd/routing-webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"knative.dev/pkg/webhook/resourcesemantics"
"knative.dev/pkg/webhook/resourcesemantics/validation"

"github.com/triggermesh/filter/pkg/apis/filter/v1alpha1"
"github.com/triggermesh/routing/pkg/apis/filter/v1alpha1"
)

var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
Expand Down Expand Up @@ -72,7 +72,7 @@ func main() {
ServiceName: webhook.NameFromEnv(),
Port: webhook.PortFromEnv(8443),
// SecretName must match the name of the Secret created in the configuration.
SecretName: "filter-webhook-certs",
SecretName: "routing-webhook-certs",
})

sharedmain.WebhookMainWithContext(ctx, webhook.NameFromEnv(),
Expand Down
2 changes: 1 addition & 1 deletion config/100-namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: filter
name: routing
8 changes: 4 additions & 4 deletions config/200-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: triggermesh-filter-admin
name: triggermesh-routing-admin
aggregationRule:
clusterRoleSelectors:
- matchLabels:
filter.triggermesh.io/controller: "true"
routing.triggermesh.io/controller: "true"
rules: [] # Rules are automatically filled in by the controller manager.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: triggermesh-filter-core
name: triggermesh-routing-core
labels:
filter.triggermesh.io/controller: "true"
routing.triggermesh.io/controller: "true"
rules:
- apiGroups:
- ""
Expand Down
6 changes: 3 additions & 3 deletions config/200-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: triggermesh-filter-controller
namespace: filter
name: triggermesh-routing-controller
namespace: routing
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: triggermesh-filter-deployment
namespace: filter
namespace: routing
16 changes: 8 additions & 8 deletions config/201-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: triggermesh-filter-controller-admin
name: triggermesh-routing-controller-admin
subjects:
- kind: ServiceAccount
name: triggermesh-filter-controller
namespace: filter
name: triggermesh-routing-controller
namespace: routing
roleRef:
kind: ClusterRole
name: triggermesh-filter-admin
name: triggermesh-routing-admin
apiGroup: rbac.authorization.k8s.io

---
Expand All @@ -34,7 +34,7 @@ metadata:
subjects:
- kind: ServiceAccount
name: triggermesh-filter-deployment
namespace: filter
namespace: routing
roleRef:
kind: ClusterRole
name: triggermesh-filter-deployment
Expand All @@ -45,11 +45,11 @@ roleRef:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: triggermesh-filter-controller-resolver
name: triggermesh-routing-controller-resolver
subjects:
- kind: ServiceAccount
name: triggermesh-filter-controller
namespace: filter
name: triggermesh-routing-controller
namespace: routing
roleRef:
kind: ClusterRole
name: addressable-resolver
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions config/400-webhook-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ apiVersion: v1
kind: Service
metadata:
labels:
role: filter-webhook
name: filter-webhook
namespace: filter
role: routing-webhook
name: routing-webhook
namespace: routing
spec:
ports:
- port: 443
targetPort: 8443
selector:
role: filter-webhook
role: routing-webhook
8 changes: 4 additions & 4 deletions config/500-webhook-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ webhooks:
- v1beta1
clientConfig:
service:
name: filter-webhook
namespace: filter
name: routing-webhook
namespace: routing
sideEffects: None
failurePolicy: Fail
name: validation.webhook.routing.triggermesh.io
---
apiVersion: v1
kind: Secret
metadata:
name: filter-webhook-certs
namespace: filter
name: routing-webhook-certs
namespace: routing
# The data is populated at install time.
2 changes: 1 addition & 1 deletion config/config-leader-election.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: config-leader-election
namespace: filter
namespace: routing
data:
_example: |
################################
Expand Down
2 changes: 1 addition & 1 deletion config/config-logging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: config-logging
namespace: filter
namespace: routing

data:
_example: |
Expand Down
2 changes: 1 addition & 1 deletion config/config-observability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: config-observability
namespace: filter
namespace: routing

data:
_example: |
Expand Down
14 changes: 7 additions & 7 deletions config/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: filter-controller
namespace: filter
name: routing-controller
namespace: routing
spec:
replicas: 1
selector:
matchLabels:
app: filter-controller
app: routing-controller
template:
metadata:
labels:
app: filter-controller
app: routing-controller
spec:
# To avoid node becoming SPOF, spread our replicas to different nodes.
affinity:
Expand All @@ -34,16 +34,16 @@ spec:
- podAffinityTerm:
labelSelector:
matchLabels:
app: filter-controller
app: routing-controller
topologyKey: kubernetes.io/hostname
weight: 100

serviceAccountName: triggermesh-filter-controller
serviceAccountName: triggermesh-routing-controller
containers:
- name: controller
# This is the Go import path for the binary that is containerized
# and substituted here.
image: ko://github.com/triggermesh/filter/cmd/filter-controller
image: ko://github.com/triggermesh/routing/cmd/routing-controller
resources:
requests:
cpu: 100m
Expand Down
Loading