Skip to content

Commit

Permalink
Add Grafana deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmolar committed Nov 6, 2024
1 parent e970e74 commit 17a06dc
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 0 deletions.
27 changes: 27 additions & 0 deletions base/grafana/deploy-grafana.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -exuo pipefail
command -v envsubst

FILE_ROOT=${BASH_SOURCE%/*}
NAMESPACE=${NAMESPACE:=tools}

export FILE_ROOT NAMESPACE

# make sure user-workloads are enabled
USER_WORKLOADS=$(oc get cm/cluster-monitoring-config -n openshift-monitoring -ojsonpath='{.data.config\.yaml}')

if ! [ "$USER_WORKLOADS" = "enableUserWorkload: true" ]; then
echo "User Workload is not enabled"
exit ;
fi

envsubst < "${FILE_ROOT}"/operator-group.yaml | oc apply -n "${NAMESPACE}" -f -
oc apply -f "${FILE_ROOT}"/subscription.yaml -n ${NAMESPACE}

oc wait -n "${NAMESPACE}" installplan "$(oc get -n "${NAMESPACE}" subscription grafana-operator -o=jsonpath='{.status.installPlanRef.name}')" --for=condition=Installed --timeout=120s

oc -n "$NAMESPACE" apply -f "$FILE_ROOT"/grafana.yaml

oc adm policy add-cluster-role-to-user cluster-monitoring-view -z grafana-sa -n "$NAMESPACE"

20 changes: 20 additions & 0 deletions base/grafana/grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: grafana
labels:
dashboards: grafana
folders: grafana
spec:
config:
auth.anonymous:
enabled: 'true'
org_role: Admin
auth.basic:
enabled: 'true'
log:
mode: console
security:
admin_password: admin
admin_user: admin

8 changes: 8 additions & 0 deletions base/grafana/operator-group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: ${NAMESPACE}
spec:
targetNamespaces:
- ${NAMESPACE}
12 changes: 12 additions & 0 deletions base/grafana/subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: grafana-operator
spec:
channel: v5
installPlanApproval: Automatic
name: grafana-operator
source: community-operators
sourceNamespace: openshift-marketplace

9 changes: 9 additions & 0 deletions overlays/kuadrant/grafana-dashboards/app_developer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
name: app-developer-dashboard
namespace: <your-grafana-namespace>
spec:
json:
url: "https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/main/examples/dashboards/app_developer.json"
10 changes: 10 additions & 0 deletions overlays/kuadrant/grafana-dashboards/business_user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
name: business-user-dashboard
namespace: <your-grafana-namespace>
spec:
json:
url: "https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/main/examples/dashboards/business_user.json"

9 changes: 9 additions & 0 deletions overlays/kuadrant/grafana-dashboards/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- app_developer_dashboard.yaml
- business_user_dashboard.yaml
- platform_engineer_dashboard.yaml

10 changes: 10 additions & 0 deletions overlays/kuadrant/grafana-dashboards/platform_engineer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
name: platform-engineer-dashboard
namespace: <your-grafana-namespace>
spec:
json:
url: "https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/main/examples/dashboards/platform_engineer.json"

1 change: 1 addition & 0 deletions overlays/kuadrant/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- ../../base/mockserver/
- ../../base/jaeger/
- ../../base/keycloak-deployment/
- /grafana-dashboards/

images:
- name: quay.io/rh_integration/go-httpbin
Expand Down

0 comments on commit 17a06dc

Please sign in to comment.