Skip to content

Commit

Permalink
Merge pull request #438 from ramachandranravi/fix_deploy_grafana_script
Browse files Browse the repository at this point in the history
fix_deploy_grafana_script
  • Loading branch information
sthaha authored Nov 15, 2024
2 parents d0993c4 + 5db8b89 commit 4a1bc49
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
14 changes: 7 additions & 7 deletions hack/dashboard/openshift/deploy-grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ declare -r MON_NS=openshift-monitoring
declare -r UWM_NS=openshift-user-workload-monitoring
declare -r CMO_CM=cluster-monitoring-config
declare -r BACKUP_CMO_CFG="$BACKUP_DIR/cmo-cm.yaml"
declare -r UWM_URL="https://docs.openshift.com/container-platform/latest/monitoring/enabling-monitoring-for-user-defined-projects.html"
declare -r UWM_CONFIG_URL="https://docs.openshift.com/container-platform/latest/monitoring/configuring-the-monitoring-stack.html#configuring-the-monitoring-stack_configuring-the-monitoring-stack"
declare -r UWM_URL="https://docs.openshift.com/container-platform/latest/observability/monitoring/enabling-monitoring-for-user-defined-projects.html"
declare -r UWM_CONFIG_URL="https://docs.openshift.com/container-platform/latest/observability/monitoring/configuring-the-monitoring-stack.html#configuring-the-monitoring-stack_configuring-the-monitoring-stack"

declare -r GRAFANA_NS=kepler-grafana
declare -r GRAFANA_SA=grafana
Expand Down Expand Up @@ -45,7 +45,7 @@ validate_cluster() {
fail "No oc command found in PATH"
info "Please install oc"
cat <<-EOF
curl -sNL https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/4.13.0/openshift-client-linux.tar.gz |
curl -sNL https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/4.16.0/openshift-client-linux.tar.gz |
tar -xzf - -C <install/path>
EOF
# NOTE: do not proceed without oc installed
Expand Down Expand Up @@ -236,9 +236,9 @@ setup_grafana() {
oc get grafana,grafanadatasource

wait_until 10 10 "Grafana CRDs to be Established" \
oc wait --for=condition=Established crd grafanas.integreatly.org
oc wait --for=condition=Established crd grafanas.grafana.integreatly.org
wait_until 10 10 "Grafana Datasource CRDs to be Established" \
oc wait --for=condition=Established crd grafanadatasources.integreatly.org
oc wait --for=condition=Established crd grafanadatasources.grafana.integreatly.org
ok "grafana crds created\n"

info "Creating a grafana instance"
Expand Down Expand Up @@ -290,14 +290,14 @@ setup_grafana_dashboard() {

# NOTE: route name is dependent on the grafana instance
wait_until 20 2 "Grafana dashboard" \
oc_get_grafana_ns route grafana-route
oc_get_grafana_ns route kepler-grafana-route

ok "created grafana dashboard\n"
}

grafana_login_url() {
local grafana_url=""
echo "https://$(oc_get_grafana_ns route grafana-route -o jsonpath='{.spec.host}')/login"
echo "https://$(oc_get_grafana_ns route kepler-grafana-route -o jsonpath='{.spec.host}')/login"

}

Expand Down
16 changes: 12 additions & 4 deletions hack/dashboard/openshift/grafana-config/01-grafana-instance.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
apiVersion: integreatly.org/v1alpha1
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: kepler-grafana
labels:
dashboards: kepler-grafana
spec:
# TODO: this hard-coded image version is necessary until the currently available version
# of grafana operator from OperatorHub (v4.7.1) pulls in a later version of grafana
baseImage: 'docker.io/grafana/grafana:8.5.5'
baseImage: 'docker.io/grafana/grafana:11.3.0'
route:
spec:
to:
kind: Service
name: kepler-grafana-service
weight: 100
ingress:
enabled: true
config:
auth:
disable_signout_menu: true
disable_signout_menu: "true"
auth.anonymous:
enabled: true
enabled: "true"
log:
level: warn
mode: console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# oc adm policy add-cluster-role-to-user cluster-monitoring-view -z grafana-serviceaccount
# 2. Get bearer token for `grafana-serviceaccount`. Update manifest.
# oc serviceaccounts get-token grafana-serviceaccount -n kepler
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDataSource
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
name: prometheus-grafanadatasource
spec:
datasources:
- access: proxy
datasource:
access: proxy
editable: true
isDefault: true
jsonData:
Expand All @@ -22,3 +22,7 @@ spec:
type: prometheus
url: 'https://thanos-querier.openshift-monitoring.svc.cluster.local:9091'
name: prometheus-grafanadatasource.yaml
# The spec.instanceSelectors field is used to tell the operator which Grafana instance the resource applies to.
instanceSelector:
matchLabels:
dashboards: kepler-grafana
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
apiVersion: integreatly.org/v1alpha1
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: kepler-dashboard
labels:
app: grafana
spec:
instanceSelector:
matchLabels:
dashboards: kepler-grafana
configMapRef:
name: kepler-dashboard-cm
key: dashboard.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
apiVersion: integreatly.org/v1alpha1
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: prometheus-dashboard
labels:
app: grafana
spec:
instanceSelector:
matchLabels:
dashboards: kepler-grafana
configMapRef:
name: prometheus-dashboard-cm
key: dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ kind: Subscription
metadata:
name: grafana-operator
spec:
channel: v4
channel: v5
installPlanApproval: Automatic
name: grafana-operator
source: community-operators
sourceNamespace: openshift-marketplace
startingCSV: grafana-operator.v4.10.1
startingCSV: grafana-operator.v5.15.1

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# https://docs.openshift.com/container-platform/4.10/monitoring/enabling-monitoring-for-user-defined-projects.html
# https://docs.openshift.com/container-platform/latest/observability/monitoring/enabling-monitoring-for-user-defined-projects.html
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down

0 comments on commit 4a1bc49

Please sign in to comment.