Skip to content

Commit 4f17693

Browse files
committed
add priority labeling
1 parent 907da32 commit 4f17693

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

kube/config/templates/5xx-rate.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ spec:
4545
{{if .Sensitivity}}
4646
sensitivity: {{.Sensitivity}}
4747
{{end}}
48+
{{if .Priority}}
49+
priority: {{.Priority}}
50+
{{end}}

kube/config/templates/replicas-availability-deployment.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ spec:
3737
{{if .Sensitivity}}
3838
sensitivity: {{.Sensitivity}}
3939
{{end}}
40+
{{if .Priority}}
41+
priority: {{.Priority}}
42+
{{end}}

pkg/templates/ingress.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type templateParameterIngress struct {
2929
Criticality string
3030
Sensitivity string
3131
BackendService string
32+
Priority string
3233
}
3334

3435
// CreateFromIngress
@@ -46,6 +47,7 @@ func (a *PrometheusRuleTemplateManager) CreateFromIngress(ingress *networkingv1.
4647
Environment: ingress.GetAnnotations()[environmentAnnotation],
4748
Criticality: ingress.GetAnnotations()[criticalityAnnotation],
4849
Sensitivity: ingress.GetAnnotations()[sensitivityAnnotation],
50+
Priority: ingress.GetAnnotations()[priorityAnnotation],
4951
}
5052

5153
prometheusRules := map[string]*monitoringv1.PrometheusRule{}

pkg/templates/ingress_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ var (
6969
Name: "testDefaultBackend",
7070
Namespace: "testNamespace",
7171
Annotations: map[string]string{
72-
"com.uswitch.heimdall/5xx-rate": "0.001",
73-
ownerAnnotation: "testIngressOwner",
74-
environmentAnnotation: "testing",
75-
criticalityAnnotation: "low",
76-
sensitivityAnnotation: "public",
72+
"com.uswitch.heimdall/5xx-rate": "0.001",
73+
"com.uswitch.heimdall/label-priority": "p1",
74+
ownerAnnotation: "testIngressOwner",
75+
environmentAnnotation: "testing",
76+
criticalityAnnotation: "low",
77+
sensitivityAnnotation: "public",
7778
},
7879
},
7980
Spec: networkingv1.IngressSpec{
@@ -147,6 +148,10 @@ func TestIngressAnnotationsDefaultBackend(t *testing.T) {
147148
assert.Assert(t, is.Len(promrules, 1))
148149
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Expr.StrVal, expr)
149150
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["owner"], "testIngressOwner")
151+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["environment"], "testing")
152+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["criticality"], "low")
153+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["sensitivity"], "public")
154+
assert.Equal(t, promrules[0].Spec.Groups[0].Rules[0].Labels["priority"], "p1")
150155
}
151156

152157
func TestIngressAnnotationsRuleBackend(t *testing.T) {

pkg/templates/promrules.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
environmentAnnotation = "service.rvu.co.uk/environment"
2222
criticalityAnnotation = "service.rvu.co.uk/criticality"
2323
sensitivityAnnotation = "service.rvu.co.uk/sensitivity"
24+
priorityAnnotation = "com.uswitch.heimdall/label-priority"
2425
)
2526

2627
// ClientSetI

0 commit comments

Comments
 (0)