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
8 changes: 6 additions & 2 deletions pkg/resourcecreator/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ func createIngressBase(source Source, ingressClass string) (*networkingv1.Ingres

objectMeta := resource.CreateObjectMeta(source)
objectMeta.Name = shortName
objectMeta.Annotations["prometheus.io/scrape"] = "true"
objectMeta.Annotations["prometheus.io/path"] = source.GetLiveness().Path

liveness := source.GetLiveness()
if liveness != nil && liveness.Path != "" {
objectMeta.Annotations["prometheus.io/scrape"] = "true"
objectMeta.Annotations["prometheus.io/path"] = liveness.Path
}

return &networkingv1.Ingress{
TypeMeta: metav1.TypeMeta{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,3 @@ tests:
metadata:
annotations:
nais.io/deploymentCorrelationID: ""
prometheus.io/path: ""
prometheus.io/scrape: "true"
2 changes: 0 additions & 2 deletions pkg/resourcecreator/testdata/ingress_migrate_to_haproxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ tests:
haproxy.org/timeout-client: "101s"
haproxy.org/timeout-connect: "102s"
haproxy.org/path-rewrite: "some"
prometheus.io/path: ""
prometheus.io/scrape: "true"
spec:
ingressClassName: very-haproxy
rules:
Expand Down
2 changes: 0 additions & 2 deletions pkg/resourcecreator/testdata/ingress_on_premises.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ tests:
nais.io/deploymentCorrelationID: ""
nginx.ingress.kubernetes.io/backend-protocol: HTTP
nginx.ingress.kubernetes.io/use-regex: "true"
prometheus.io/path: ""
prometheus.io/scrape: "true"
spec:
ingressClassName: very-nginx
rules:
Expand Down
54 changes: 54 additions & 0 deletions pkg/resourcecreator/testdata/ingress_probe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
testconfig:
description: application with liveness path results in ingress resource with prometheus annotations
config:
features:
haproxy: true
domain-ingressclass-mapping:
- domainSuffix: .bar
ingressClass: very-haproxy
input:
kind: Application
apiVersion: nais.io/v1alpha1
metadata:
name: myapplication
namespace: mynamespace
uid: "123456"
spec:
ingresses:
- https://foo.bar/baz
liveness:
path: "liveness"
tests:
- apiVersion: networking.k8s.io/v1
kind: Ingress
name: myapplication-very-haproxy-efe42262
operation: CreateOrUpdate
match:
- type: exact
name: "ingress created with correct config"
exclude:
- .status
- .metadata.creationTimestamp
- .metadata.ownerReferences
- .metadata.labels
- .metadata.name
- .metadata.namespace
resource:
metadata:
annotations:
nais.io/deploymentCorrelationID: ""
prometheus.io/path: "liveness"
prometheus.io/scrape: "true"
spec:
ingressClassName: very-haproxy
rules:
- host: foo.bar
http:
paths:
- backend:
service:
name: myapplication
port:
number: 80
path: /baz
pathType: Prefix