Skip to content

Commit

Permalink
Removed hard coded annotation for prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
sayanh committed Aug 26, 2019
1 parent 9b13d62 commit 33ba3bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
2 changes: 0 additions & 2 deletions config/400-source-controller-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: "true"
labels:
eventing.knative.dev/release: devel
app: sources-controller
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestReconcileCRD(t *testing.T) {
WantCreates: []runtime.Object{
NewService(filterServiceName, testNS,
WithServiceOwnerReferences(ownerReferences()),
WithServiceAnnotations(resources.FilterAnnotations()),
WithServiceAnnotations(map[string]string{}),
WithServiceLabels(resources.FilterLabels(brokerName)),
WithServicePorts(servicePorts(filterContainerName, 8080))),
},
Expand Down Expand Up @@ -459,7 +459,7 @@ func TestReconcileCRD(t *testing.T) {
WantCreates: []runtime.Object{
NewService(ingressServiceName, testNS,
WithServiceOwnerReferences(ownerReferences()),
WithServiceAnnotations(resources.IngressAnnotations()),
WithServiceAnnotations(map[string]string{}),
WithServiceLabels(resources.IngressLabels(brokerName)),
WithServicePorts(servicePorts(ingressContainerName, 8080))),
},
Expand Down
16 changes: 3 additions & 13 deletions pkg/reconciler/broker/resources/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ func MakeFilterDeployment(args *FilterArgs) *appsv1.Deployment {
func MakeFilterService(b *eventingv1alpha1.Broker) *corev1.Service {
return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Namespace: b.Namespace,
Name: fmt.Sprintf("%s-broker-filter", b.Name),
Annotations: FilterAnnotations(),
Labels: FilterLabels(b.Name),
Namespace: b.Namespace,
Name: fmt.Sprintf("%s-broker-filter", b.Name),
Labels: FilterLabels(b.Name),
OwnerReferences: []metav1.OwnerReference{
*kmeta.NewControllerRef(b),
},
Expand Down Expand Up @@ -135,12 +134,3 @@ func FilterLabels(brokerName string) map[string]string {
"eventing.knative.dev/brokerRole": "filter",
}
}

// FilterAnnotations generates the annotation that allow Prometheus to scrape the metrics exposed
// by this service.
func FilterAnnotations() map[string]string {
return map[string]string{
"prometheus.io/scrape": "true",
"prometheus.io/port": "9090",
}
}
14 changes: 2 additions & 12 deletions pkg/reconciler/broker/resources/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ func MakeIngressService(b *eventingv1alpha1.Broker) *corev1.Service {
ObjectMeta: metav1.ObjectMeta{
Namespace: b.Namespace,
// TODO add -ingress to the name to be consistent with the filter service naming.
Name: fmt.Sprintf("%s-broker", b.Name),
Annotations: IngressAnnotations(),
Labels: IngressLabels(b.Name),
Name: fmt.Sprintf("%s-broker", b.Name),
Labels: IngressLabels(b.Name),
OwnerReferences: []metav1.OwnerReference{
*kmeta.NewControllerRef(b),
},
Expand Down Expand Up @@ -145,12 +144,3 @@ func IngressLabels(brokerName string) map[string]string {
"eventing.knative.dev/brokerRole": "ingress",
}
}

// IngressAnnotations generates the annotation that allow Prometheus to scrape the metrics exposed
// by this service.
func IngressAnnotations() map[string]string {
return map[string]string{
"prometheus.io/scrape": "true",
"prometheus.io/port": "9090",
}
}

0 comments on commit 33ba3bb

Please sign in to comment.