Skip to content

Commit 4606d4f

Browse files
authored
KFLUXINFRA-3830: Add Grafana monitoring base components (redhat-appstudio#366)
Copy Grafana operator, dashboards, and RBAC base from infra-deployments, adapted for infra-common-deployments (updated references and README). Assisted-by: Claude Code <noreply@anthropic.com> Signed-off-by: Gal Levi <glevi@redhat.com>
1 parent fc630ed commit 4606d4f

49 files changed

Lines changed: 16535 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See the OWNERS docs: https://go.k8s.io/owners
2+
3+
filters:
4+
".*/dashboards/release/.*":
5+
approvers:
6+
- davidmogar
7+
- johnbieren
8+
- theflockers
9+
- mmalina
10+
- happybhati
11+
- seanconroy2021
12+
- filipnikolovski
13+
- elenagerman
14+
- midnightercz
15+
- querti
16+
- swickersh
17+
18+
reviewers:
19+
- davidmogar
20+
- johnbieren
21+
- theflockers
22+
- mmalina
23+
- happybhati
24+
- seanconroy2021
25+
- filipnikolovski
26+
- elenagerman
27+
- midnightercz
28+
- querti
29+
- swickersh
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
## Installing and configuring Grafana on common clusters
3+
4+
We use Grafana Operator to create all needed services and routes
5+
6+
Note: The steps below should be handled by Argo CD
7+
8+
- Create the `appstudio-grafana` namespace on each cluster, if it does not exist yet:
9+
10+
```
11+
$ oc create namespace appstudio-grafana
12+
```
13+
14+
- Build and apply from the per environment overlay:
15+
16+
```
17+
$ kustomize build components/monitoring/grafana/internal-staging | oc apply -f -
18+
```
19+
20+
Replace `internal-staging` with the appropriate environment overlay.
21+
22+
## Dashboard structure
23+
24+
Team dashboards are maintained in per environment overlays (`internal-staging/dashboards/`, `external-staging/dashboards/`). Each environment references its own dashboard source independently. The `base/dashboards/` directory contains shared dashboard definitions referenced by the overlays.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Workaround for the bug in the operator: https://github.com/grafana/grafana-operator/issues/2552
2+
# This should run once after operator is deployed so that the installplan is approved automatically
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: approve-installplan
7+
namespace: appstudio-grafana
8+
annotations:
9+
argocd.argoproj.io/hook: Sync
10+
argocd.argoproj.io/sync-wave: "-1"
11+
argocd.argoproj.io/hook-delete-policy: HookSucceeded
12+
---
13+
apiVersion: rbac.authorization.k8s.io/v1
14+
kind: Role
15+
metadata:
16+
name: approve-installplan
17+
namespace: appstudio-grafana
18+
annotations:
19+
argocd.argoproj.io/hook: Sync
20+
argocd.argoproj.io/sync-wave: "-1"
21+
argocd.argoproj.io/hook-delete-policy: HookSucceeded
22+
rules:
23+
- apiGroups:
24+
- operators.coreos.com
25+
resources:
26+
- installplans
27+
verbs:
28+
- get
29+
- list
30+
- patch
31+
---
32+
apiVersion: rbac.authorization.k8s.io/v1
33+
kind: RoleBinding
34+
metadata:
35+
name: approve-installplan
36+
namespace: appstudio-grafana
37+
annotations:
38+
argocd.argoproj.io/hook: Sync
39+
argocd.argoproj.io/sync-wave: "-1"
40+
argocd.argoproj.io/hook-delete-policy: HookSucceeded
41+
roleRef:
42+
apiGroup: rbac.authorization.k8s.io
43+
kind: Role
44+
name: approve-installplan
45+
subjects:
46+
- kind: ServiceAccount
47+
name: approve-installplan
48+
namespace: appstudio-grafana
49+
---
50+
apiVersion: batch/v1
51+
kind: Job
52+
metadata:
53+
name: approve-grafana-installplan
54+
namespace: appstudio-grafana
55+
annotations:
56+
argocd.argoproj.io/hook: Sync
57+
argocd.argoproj.io/sync-wave: "-1"
58+
argocd.argoproj.io/hook-delete-policy: HookSucceeded, BeforeHookCreation
59+
spec:
60+
ttlSecondsAfterFinished: 600
61+
backoffLimit: 5
62+
template:
63+
spec:
64+
serviceAccountName: approve-installplan
65+
containers:
66+
- name: approve
67+
image: registry.redhat.io/openshift4/ose-cli:v4.12
68+
securityContext:
69+
readOnlyRootFilesystem: true
70+
runAsNonRoot: true
71+
resources:
72+
requests:
73+
cpu: 100m
74+
memory: 128Mi
75+
limits:
76+
cpu: 200m
77+
memory: 256Mi
78+
env:
79+
- name: TARGET_CSV
80+
value: grafana-operator.v5.21.2
81+
command:
82+
- /bin/bash
83+
- -c
84+
- |
85+
for i in $(seq 1 60); do
86+
# Check if already approved, if not approve it
87+
APPROVED=$(
88+
oc get installplan -n appstudio-grafana \
89+
-o jsonpath='{range .items[?(@.spec.approved==true)]}{.spec.clusterServiceVersionNames[0]}{"\n"}{end}' \
90+
| awk -v target="$TARGET_CSV" '$1 == target {print $1; exit}'
91+
)
92+
if [ -n "$APPROVED" ]; then
93+
echo "InstallPlan for $TARGET_CSV is already approved"
94+
exit 0
95+
fi
96+
97+
# Check for unapproved plan to approve
98+
PLAN_NAME=$(
99+
oc get installplan -n appstudio-grafana \
100+
-o jsonpath='{range .items[?(@.spec.approved==false)]}{.metadata.name}{" "}{.spec.clusterServiceVersionNames[0]}{"\n"}{end}' \
101+
| awk -v target="$TARGET_CSV" '$2 == target {print $1; exit}'
102+
)
103+
if [ -n "$PLAN_NAME" ]; then
104+
echo "Approving InstallPlan $PLAN_NAME for $TARGET_CSV"
105+
oc patch installplan "$PLAN_NAME" -n appstudio-grafana --type merge -p '{"spec":{"approved":true}}'
106+
exit 0
107+
fi
108+
109+
echo "Waiting for InstallPlan for $TARGET_CSV... ($i/60)"
110+
sleep 5
111+
done
112+
echo "No InstallPlan found for $TARGET_CSV"
113+
exit 1
114+
restartPolicy: Never
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See the OWNERS docs: https://go.k8s.io/owners
2+
# Should be kept in sync with components/monitoring/grafana/base/dashboards/build-service/OWNERS
3+
4+
approvers:
5+
- mmorhun
6+
- rcerven
7+
- mkosiarc
8+
- tisutisu
9+
- chmeliik
10+
- MartinBasti
11+
12+
reviewers:
13+
- mmorhun
14+
- rcerven
15+
- mkosiarc
16+
- tisutisu
17+
- chmeliik
18+
- MartinBasti
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
apiVersion: grafana.integreatly.org/v1beta1
3+
kind: GrafanaDashboard
4+
metadata:
5+
name: grafana-dashboard-component-onboarding
6+
labels:
7+
app: appstudio-grafana
8+
spec:
9+
instanceSelector:
10+
matchLabels:
11+
dashboards: "appstudio-grafana"
12+
configMapRef:
13+
name: grafana-dashboard-component-onboarding
14+
key: grafana-dashboard-component-onboarding.json
15+
---
16+
apiVersion: grafana.integreatly.org/v1beta1
17+
kind: GrafanaDashboard
18+
metadata:
19+
name: grafana-dashboard-pac-provision
20+
labels:
21+
app: appstudio-grafana
22+
spec:
23+
instanceSelector:
24+
matchLabels:
25+
dashboards: "appstudio-grafana"
26+
configMapRef:
27+
name: grafana-dashboard-pac-provision
28+
key: grafana-dashboard-pac-provision.json
29+
---
30+
apiVersion: grafana.integreatly.org/v1beta1
31+
kind: GrafanaDashboard
32+
metadata:
33+
name: grafana-dashboard-pac-unprovision
34+
labels:
35+
app: appstudio-grafana
36+
spec:
37+
instanceSelector:
38+
matchLabels:
39+
dashboards: "appstudio-grafana"
40+
configMapRef:
41+
name: grafana-dashboard-pac-unprovision
42+
key: grafana-dashboard-pac-unprovision.json
43+
---
44+
apiVersion: grafana.integreatly.org/v1beta1
45+
kind: GrafanaDashboard
46+
metadata:
47+
name: grafana-dashboard-push-pipeline-rebuild-trigger
48+
labels:
49+
app: appstudio-grafana
50+
spec:
51+
instanceSelector:
52+
matchLabels:
53+
dashboards: "appstudio-grafana"
54+
configMapRef:
55+
name: grafana-dashboard-push-pipeline-rebuild-trigger
56+
key: grafana-dashboard-push-pipeline-rebuild-trigger.json
57+
---
58+
apiVersion: grafana.integreatly.org/v1beta1
59+
kind: GrafanaDashboard
60+
metadata:
61+
name: grafana-dashboard-github-availability
62+
labels:
63+
app: appstudio-grafana
64+
spec:
65+
instanceSelector:
66+
matchLabels:
67+
dashboards: "appstudio-grafana"
68+
configMapRef:
69+
name: grafana-dashboard-component-github-availability
70+
key: grafana-dashboard-component-github-availability.json
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- https://github.com/konflux-ci/build-service/config/monitoring/grafana-dashboards/?ref=02a9ba8a58ec27d072f5fe0cec0918cd505136c6
5+
- dashboard.yaml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
nameReference:
2+
- kind: ConfigMap
3+
fieldSpecs:
4+
- kind: GrafanaDashboard
5+
path: spec/configMapRef/name
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- https://github.com/redhat-appstudio/dora-metrics/deploy/grafana/?ref=eee598d77638d9110fe5a00260ec2b2f3a4e2643

0 commit comments

Comments
 (0)