Skip to content

Commit 0e7ef58

Browse files
test(metrics): Fix the test on OpenShift
1 parent 480163b commit 0e7ef58

3 files changed

Lines changed: 49 additions & 38 deletions

File tree

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
11
---
2-
apiVersion: v1
3-
kind: ServiceAccount
4-
metadata:
5-
name: test-service-account
6-
---
7-
kind: Role
8-
apiVersion: rbac.authorization.k8s.io/v1
9-
metadata:
10-
name: test-role
11-
rules:
12-
- apiGroups:
13-
- security.openshift.io
14-
resources:
15-
- securitycontextconstraints
16-
resourceNames:
17-
- privileged
18-
verbs:
19-
- use
20-
---
21-
kind: RoleBinding
22-
apiVersion: rbac.authorization.k8s.io/v1
23-
metadata:
24-
name: test-role-binding
25-
subjects:
26-
- kind: ServiceAccount
27-
name: test-service-account
28-
- kind: ServiceAccount
29-
name: prometheus-stack-kube-prom-admission
30-
- kind: ServiceAccount
31-
name: prometheus-stack-kube-prom-operator
32-
- kind: ServiceAccount
33-
name: prometheus-stack-kube-prom-prometheus
34-
roleRef:
35-
apiGroup: rbac.authorization.k8s.io
36-
kind: Role
37-
name: test-role
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- script: >
6+
envsubst '$NAMESPACE' < 01_rbac.yaml |
7+
kubectl apply -n $NAMESPACE -f -
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: test-service-account
6+
---
7+
kind: Role
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
metadata:
10+
name: test-role
11+
rules:
12+
- apiGroups:
13+
- security.openshift.io
14+
resources:
15+
- securitycontextconstraints
16+
resourceNames:
17+
- privileged
18+
verbs:
19+
- use
20+
---
21+
# `fullnameOverride` in the Prometheus Helm values must be set to `prometheus-$NAMESPACE`, so that
22+
# the ServiceAccounts are created with the names listed in this RoleBinding.
23+
kind: RoleBinding
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: test-role-binding
27+
subjects:
28+
- kind: ServiceAccount
29+
name: test-service-account
30+
- kind: ServiceAccount
31+
name: prometheus-$NAMESPACE-admission
32+
- kind: ServiceAccount
33+
name: prometheus-$NAMESPACE-operator
34+
- kind: ServiceAccount
35+
name: prometheus-$NAMESPACE-prometheus
36+
roleRef:
37+
apiGroup: rbac.authorization.k8s.io
38+
kind: Role
39+
name: test-role

tests/templates/kuttl/metrics/10-install-prometheus.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestStep
44
commands:
5-
# Append the namespace to the Helm release name so that cluster-wide
6-
# resources get unique names.
5+
# Append the namespace to the Helm release name so that cluster-wide resources get unique names.
6+
# `fullnameOverride` is set to `prometheus-$NAMESPACE`, so that the ServiceAccounts are created
7+
# with the names that are defined in `test-role-binding`.
78
- script: >
89
helm install prometheus-$NAMESPACE
910
--namespace $NAMESPACE
1011
--version 80.14.2
1112
--values 10_kube-prometheus-stack-values.yaml
13+
--set fullnameOverride=prometheus-$NAMESPACE
1214
--wait
1315
oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack
1416
timeout: 600

0 commit comments

Comments
 (0)