Skip to content

Commit 6b12212

Browse files
committed
Start adding loki to the auth test
Signed-off-by: Pete Wall <pete.wall@grafana.com>
1 parent 7a4b8d4 commit 6b12212

File tree

11 files changed

+755
-85
lines changed

11 files changed

+755
-85
lines changed

charts/k8s-monitoring/tests/integration/auth/.rendered/output.yaml

Lines changed: 543 additions & 14 deletions
Large diffs are not rendered by default.

charts/k8s-monitoring/tests/integration/auth/configs/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
htpasswd:
2-
htpasswd -c -B -b htpasswd promuser prompassword
3-
htpasswd -B -b htpasswd oteluser otelpassword
2+
htpasswd -c -B -b htpasswd basicuser basicpassword
43

54
passwords.yaml: htpasswd
65
echo "---" > passwords.yaml

charts/k8s-monitoring/tests/integration/auth/configs/grafana.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ datasources:
77
type: prometheus
88
url: http://prometheus-server.prometheus.svc:9090
99
isDefault: true
10+
11+
- name: Loki
12+
type: loki
13+
url: http://loki.loki.svc:3100
14+
jsonData:
15+
httpHeaderName1: X-Scope-OrgID
16+
secureJsonData:
17+
httpHeaderValue1: "1"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
deploymentMode: SingleBinary
3+
loki:
4+
commonConfig:
5+
replication_factor: 1
6+
storage:
7+
type: 'filesystem'
8+
schemaConfig:
9+
configs:
10+
- from: "2024-01-01"
11+
store: tsdb
12+
index:
13+
prefix: loki_index_
14+
period: 24h
15+
object_store: filesystem # we're storing on filesystem so there's no real persistence here.
16+
schema: v13
17+
singleBinary:
18+
replicas: 1
19+
read:
20+
replicas: 0
21+
backend:
22+
replicas: 0
23+
write:
24+
replicas: 0
25+
26+
chunksCache:
27+
enabled: false
28+
resultsCache:
29+
enabled: false
30+
lokiCanary:
31+
enabled: false
32+
test:
33+
enabled: false
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
service:
3+
type: ClusterIP
4+
serverBlock: |-
5+
server {
6+
listen 0.0.0.0:8080;
7+
location /metrics/basic/ {
8+
auth_basic "Prometheus Basic Auth";
9+
auth_basic_user_file /etc/nginx/conf/htpasswd;
10+
11+
proxy_pass http://prometheus-server.prometheus.svc:9090/;
12+
}
13+
location /logs/basic/ {
14+
auth_basic "Loki Basic Auth";
15+
auth_basic_user_file /etc/nginx/conf/htpasswd;
16+
17+
proxy_pass http://loki.loki.svc:3100/;
18+
}
19+
20+
location /metrics/bearer/ {
21+
if ($http_authorization != "Bearer my-bearer-token") {
22+
return 401;
23+
}
24+
25+
proxy_pass http://prometheus-server.prometheus.svc:9090/;
26+
}
27+
location /logs/bearer/ {
28+
if ($http_authorization != "Bearer my-bearer-token") {
29+
return 401;
30+
}
31+
32+
proxy_pass http://loki.loki.svc:3100/;
33+
}
34+
}
35+
extraVolumes:
36+
- name: passwords-file
37+
secret:
38+
secretName: passwords
39+
extraVolumeMounts:
40+
- name: passwords-file
41+
mountPath: /etc/nginx/conf/htpasswd
42+
subPath: htpasswd

charts/k8s-monitoring/tests/integration/auth/configs/nginx-basic-auth.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

charts/k8s-monitoring/tests/integration/auth/configs/nginx-bearer-token.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

charts/k8s-monitoring/tests/integration/auth/configs/passwords.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: v1
33
data:
4-
htpasswd: cHJvbXVzZXI6JDJ5JDA1JGhuSkJnLzM2QWFkY0RBUG1xazZacE9UaTl6ZHkycG9uU1FXYjFuZzBQOEsvejlJSnhZUHRTCm90ZWx1c2VyOiQyeSQwNSQ5aHpUdFZGRnBxY3U5NnZWTmRlcmt1Tzc0Tk43M0hiaU1MY0JObTdtWWxlaTluVVJxRGI2aQo=
4+
htpasswd: YmFzaWN1c2VyOiQyeSQwNSRSMmZRTktpYkFSWVltbWhDUjBBdGxlUi9GdnVWNWd5cThVamxMNkFJWWJiWGV0dmVPcXY0Two=
55
kind: Secret
66
metadata:
77
creationTimestamp: null

charts/k8s-monitoring/tests/integration/auth/test-manifest.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ deployments:
99
version: ^25
1010
namespace: prometheus
1111
valuesFile: configs/prometheus.yaml
12+
- name: loki
13+
type: helm
14+
repo: https://grafana.github.io/helm-charts
15+
chart: loki
16+
namespace: loki
17+
valuesFile: configs/loki.yaml
18+
1219
- name: passwords
1320
type: manifest
14-
namespace: prometheus
21+
namespace: default
1522
file: configs/passwords.yaml
16-
- name: nginx-basic-auth
17-
type: helm
18-
repo: https://charts.bitnami.com/bitnami
19-
chart: nginx
20-
version: 18.2.5
21-
namespace: prometheus
22-
valuesFile: configs/nginx-basic-auth.yaml
23-
- name: nginx-bearer-token
23+
- name: nginx-auth-gateway
2424
type: helm
2525
repo: https://charts.bitnami.com/bitnami
2626
chart: nginx
2727
version: 18.2.5
28-
namespace: prometheus
29-
valuesFile: configs/nginx-bearer-token.yaml
28+
namespace: default
29+
valuesFile: configs/nginx-auth-gateway.yaml
3030

3131
- name: grafana
3232
type: helm

charts/k8s-monitoring/tests/integration/auth/test-values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
tests:
33
- env:
44
PROMETHEUS_URL: http://prometheus-server.prometheus.svc:9090/api/v1/query
5+
LOKI_URL: http://loki.loki.svc:3100/loki/api/v1/query
6+
LOKI_TENANTID: 1
57
queries:
68
- query: kubernetes_build_info{cluster="auth-integration-test", destination="prometheus-noauth"}
79
type: promql
@@ -15,3 +17,16 @@ tests:
1517
type: promql
1618
- query: kubernetes_build_info{cluster="auth-integration-test", destination="prometheus-otlp-bearer-token"}
1719
type: promql
20+
21+
- query: count_over_time({cluster="auth-integration-test", destination="loki-noauth", job!="integrations/kubernetes/eventhandler"}[1h])
22+
type: logql
23+
- query: count_over_time({cluster="auth-integration-test", destination="loki-basicauth", job!="integrations/kubernetes/eventhandler"}[1h])
24+
type: logql
25+
- query: count_over_time({cluster="auth-integration-test", destination="loki-bearer-token", job!="integrations/kubernetes/eventhandler"}[1h])
26+
type: logql
27+
# - query: count_over_time({cluster="auth-integration-test", destination="loki-otlp-noauth", job!="integrations/kubernetes/eventhandler"}[1h])
28+
# type: logql
29+
# - query: count_over_time({cluster="auth-integration-test", destination="loki-otlp-basicauth", job!="integrations/kubernetes/eventhandler"}[1h])
30+
# type: logql
31+
# - query: count_over_time({cluster="auth-integration-test", destination="loki-otlp-bearer-token", job!="integrations/kubernetes/eventhandler"}[1h])
32+
# type: logql

charts/k8s-monitoring/tests/integration/auth/values.yaml

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ destinations:
1212

1313
- name: prometheus-basicauth
1414
type: prometheus
15-
url: http://nginx-basic-auth.prometheus.svc/auth-gateway/api/v1/write
15+
url: http://nginx-auth-gateway.default.svc/metrics/basic/api/v1/write
1616
auth:
1717
type: basic
18-
username: promuser
19-
password: prompassword
18+
username: basicuser
19+
password: basicpassword
2020
extraLabels:
2121
destination: prometheus-basicauth
2222

2323
- name: prometheus-bearer-token
2424
type: prometheus
25-
url: http://nginx-bearer-token.prometheus.svc/remote-write/api/v1/write
25+
url: http://nginx-auth-gateway.default.svc/metrics/bearer/api/v1/write
2626
auth:
2727
type: bearerToken
28-
bearerToken: my-secret-remote-write-token
28+
bearerToken: my-bearer-token
2929
extraLabels:
3030
destination: prometheus-bearer-token
3131

@@ -47,11 +47,11 @@ destinations:
4747
- name: prometheus-otlp-basicauth
4848
type: otlp
4949
protocol: http
50-
url: http://nginx-basic-auth.prometheus.svc/auth-gateway/api/v1/otlp
50+
url: http://nginx-auth-gateway.default.svc/metrics/basic/api/v1/otlp
5151
auth:
5252
type: basic
53-
username: oteluser
54-
password: otelpassword
53+
username: basicuser
54+
password: basicpassword
5555
processors:
5656
attributes:
5757
actions:
@@ -65,10 +65,10 @@ destinations:
6565
- name: prometheus-otlp-bearer-token
6666
type: otlp
6767
protocol: http
68-
url: http://nginx-bearer-token.prometheus.svc/otlp/api/v1/otlp
68+
url: http://nginx-auth-gateway.default.svc/metrics/bearer/api/v1/otlp
6969
auth:
7070
type: bearerToken
71-
bearerToken: my-secret-otlp-token
71+
bearerToken: my-bearer-token
7272
processors:
7373
attributes:
7474
actions:
@@ -79,6 +79,89 @@ destinations:
7979
logs: {enabled: false}
8080
traces: {enabled: false}
8181

82+
83+
- name: loki-noauth
84+
type: loki
85+
url: http://loki.loki.svc:3100/loki/api/v1/push
86+
tenantId: 1
87+
extraLabels:
88+
destination: loki-noauth
89+
90+
- name: loki-basicauth
91+
type: loki
92+
url: http://nginx-auth-gateway.default.svc/logs/basic/loki/api/v1/push
93+
tenantId: 1
94+
auth:
95+
type: basic
96+
username: basicuser
97+
password: basicpassword
98+
extraLabels:
99+
destination: loki-basicauth
100+
101+
- name: loki-bearer-token
102+
type: loki
103+
url: http://nginx-auth-gateway.default.svc/logs/bearer/loki/api/v1/push
104+
tenantId: 1
105+
auth:
106+
type: bearerToken
107+
bearerToken: my-bearer-token
108+
extraLabels:
109+
destination: loki-bearer-token
110+
111+
112+
# - name: loki-otlp-noauth
113+
# type: otlp
114+
# protocol: http
115+
# url: http://loki.loki.svc:3100/otlp
116+
# tenantId: 1
117+
# processors:
118+
# attributes:
119+
# actions:
120+
# - key: destination
121+
# action: upsert
122+
# value: loki-otlp-noauth
123+
# metrics: {enabled: false}
124+
# logs: {enabled: true}
125+
# traces: {enabled: false}
126+
#
127+
# - name: loki-otlp-basicauth
128+
# type: otlp
129+
# protocol: http
130+
# url: http://nginx-auth-gateway.default.svc/logs/basic/otlp
131+
# tenantId: 1
132+
# auth:
133+
# type: basic
134+
# username: basicuser
135+
# password: basicpassword
136+
# processors:
137+
# attributes:
138+
# actions:
139+
# - key: destination
140+
# action: upsert
141+
# value: loki-otlp-basicauth
142+
# metrics: {enabled: false}
143+
# logs: {enabled: true}
144+
# traces: {enabled: false}
145+
#
146+
# - name: loki-otlp-bearer-token
147+
# type: otlp
148+
# protocol: http
149+
# url: http://nginx-auth-gateway.default.svc/logs/bearer/otlp
150+
# tenantId: 1
151+
# auth:
152+
# type: bearerToken
153+
# bearerToken: my-bearer-token
154+
# processors:
155+
# attributes:
156+
# actions:
157+
# - key: destination
158+
# action: upsert
159+
# value: loki-otlp-bearer-token
160+
# metrics: {enabled: false}
161+
# logs: {enabled: true}
162+
# traces: {enabled: false}
163+
164+
82165
clusterMetrics:
83166
enabled: true
84167
destinations: [prometheus-noauth, prometheus-basicauth, prometheus-bearer-token, prometheus-otlp-noauth, prometheus-otlp-basicauth, prometheus-otlp-bearer-token]
@@ -91,9 +174,13 @@ clusterMetrics:
91174
node-exporter: {enabled: false, deploy: false}
92175
windows-exporter: {enabled: false, deploy: false}
93176

177+
podLogs:
178+
enabled: true
179+
# destinations: [loki-noauth, loki-basicauth, loki-bearer-token, loki-otlp-noauth, loki-otlp-basicauth, loki-otlp-bearer-token]
180+
namespaces: ["default"]
181+
94182
alloy-metrics:
95183
enabled: true
96-
liveDebugging:
97-
enabled: true
98-
alloy:
99-
stabilityLevel: experimental
184+
185+
alloy-logs:
186+
enabled: true

0 commit comments

Comments
 (0)