Skip to content

Commit

Permalink
Create a working custom-grafana-dashboard for ArgoCD metrics
Browse files Browse the repository at this point in the history
This will allow cluster-admins, nerc-org-admins, and nerc-ops teams to
develop new dashboards using the existing multi-cluster observability
metrics.

rh-pre-commit.version: 2.0.3
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
jbasu01 authored and computate committed Nov 29, 2023
1 parent 4800967 commit 07f7b6e
Show file tree
Hide file tree
Showing 24 changed files with 261 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cluster-scope/base/core/namespaces/grafana/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
5 changes: 5 additions & 0 deletions cluster-scope/base/core/namespaces/grafana/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: Namespace
metadata:
name: grafana
spec: {}
1 change: 1 addition & 0 deletions cluster-scope/overlays/nerc-ocp-infra/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ resources:
- ../../bundles/multicluster-engine-operator
- ../../base/core/namespaces/dex
- ../../base/core/namespaces/nerc-ocp-prod
- ../../base/core/namespaces/grafana
- ../../base/operators.coreos.com/subscriptions/openshift-pipelines-operator
- ../../base/operators.coreos.com/subscriptions/loki-operator
- configmaps/admin-acks.yaml
Expand Down
6 changes: 6 additions & 0 deletions grafana/base/configmaps/grafana-config-overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ConfigMap
metadata:
name: grafana-config-overrides
namespace: grafana
apiVersion: v1
data:
4 changes: 4 additions & 0 deletions grafana/base/configmaps/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- grafana-config-overrides.yaml
12 changes: 12 additions & 0 deletions grafana/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- operatorgroups
- subscriptions
- configmaps
- routes
- serviceaccounts
commonLabels:
app.kubernetes.io/name: grafana
app.kubernetes.io/component: grafana
app.kubernetes.io/part-of: observability
8 changes: 8 additions & 0 deletions grafana/base/operatorgroups/grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: grafana
namespace: grafana
spec:
targetNamespaces:
- grafana
5 changes: 5 additions & 0 deletions grafana/base/operatorgroups/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- grafana.yaml
4 changes: 4 additions & 0 deletions grafana/base/routes/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- route.yaml
17 changes: 17 additions & 0 deletions grafana/base/routes/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: grafana
namespace: grafana
spec:
host: grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu
to:
kind: Service
name: grafana-service
weight: 100
port:
targetPort: grafana
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
4 changes: 4 additions & 0 deletions grafana/base/serviceaccounts/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- serviceaccount.yaml
5 changes: 5 additions & 0 deletions grafana/base/serviceaccounts/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: patch-operator
namespace: grafana
11 changes: 11 additions & 0 deletions grafana/base/subscriptions/grafana-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: grafana-operator
namespace: grafana
spec:
channel: v4
installPlanApproval: Automatic
name: grafana-operator
source: community-operators
sourceNamespace: openshift-marketplace
5 changes: 5 additions & 0 deletions grafana/base/subscriptions/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- grafana-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: grafana-serviceaccount-token
namespace: grafana
spec:
secretStoreRef:
name: nerc-cluster-secrets
kind: ClusterSecretStore
target:
name: grafana-serviceaccount-token
data:
- secretKey: token
remoteRef:
key: nerc/nerc-ocp-infra/grafana
property: token
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- oauth-client-secret.yaml
- grafana-serviceaccount-token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: oauth-client-secret
namespace: grafana
spec:
secretStoreRef:
name: nerc-cluster-secrets
kind: ClusterSecretStore
target:
name: oauth-client-secret
data:
- secretKey: GRAFANA_SECRET
remoteRef:
key: nerc/nerc-ocp-infra/dex/dex-clients
property: GRAFANA_SECRET
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDataSource
metadata:
name: observability-metrics
namespace: grafana
spec:
name: observability-metrics
datasources:
- name: observability-metrics
access: proxy
editable: false
isDefault: true
jsonData:
httpHeaderName1: Authorization
timeInterval: 5s
tlsAuthWithCACert: true
secureJsonData:
httpHeaderValue1: |-
Bearer REPLACE_IN_OVERLAY
tlsCACert: >-
REPLACE_IN_OVERLAY
type: prometheus
url: 'https://thanos-querier.openshift-monitoring.svc.cluster.local:9091/'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- grafanadatasource.yaml
26 changes: 26 additions & 0 deletions grafana/overlays/nerc-ocp-infra/grafanas/grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: grafana
namespace: grafana
spec:
deployment:
envFrom:
- configMapRef:
name: grafana-config-overrides
config:
server:
root_url: REPLACE_IN_OVERLAY
auth.generic_oauth:
enabled: true
scopes: openid email groups profile
email_attribute_path: name
api_url: https://dex-dex.apps.nerc-ocp-infra.rc.fas.harvard.edu/userinfo
auth_url: https://dex-dex.apps.nerc-ocp-infra.rc.fas.harvard.edu/auth
token_url: https://dex-dex.apps.nerc-ocp-infra.rc.fas.harvard.edu/token
role_attribute_path: >-
contains(groups[*], 'cluster-admins') && 'Admin' ||
contains(groups[*], 'nerc-org-admins') && 'Admin' ||
contains(groups[*], 'nerc-ops') && 'Editor' ||
'Deny'
role_attribute_strict: true
5 changes: 5 additions & 0 deletions grafana/overlays/nerc-ocp-infra/grafanas/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- grafana.yaml
14 changes: 14 additions & 0 deletions grafana/overlays/nerc-ocp-infra/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base/
- externalsecrets/
- grafanas/grafana.yaml
- grafanadatasources/grafanadatasource.yaml
- patches/grafana-oauth.yaml
- patches/grafanadatasource-observability-metrics.yaml

patches:
- path: grafanas/grafana.yaml
- path: grafanadatasources/grafanadatasource.yaml
29 changes: 29 additions & 0 deletions grafana/overlays/nerc-ocp-infra/patches/grafana-oauth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: redhatcop.redhat.io/v1alpha1
kind: Patch
metadata:
name: grafana-oauth
namespace: grafana
spec:
serviceAccountRef:
name: patcher
patches:
logging-grafana-patch:
targetObjectRef:
apiVersion: integreatly.org/v1alpha1
kind: Grafana
name: grafana
namespace: grafana
patchTemplate: |
spec:
config:
server:
root_url: https://grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu
auth.generic_oauth:
client_id: grafana
client_secret: {{ (index . 1).data.GRAFANA_SECRET | b64dec }}
patchType: application/merge-patch+json
sourceObjectRefs:
- apiVersion: v1
kind: Secret
name: oauth-client-secret
namespace: grafana
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: redhatcop.redhat.io/v1alpha1
kind: Patch
metadata:
name: grafanadatasource-observability-metrics
namespace: grafana
spec:
serviceAccountRef:
name: patcher
patches:
logging-grafana-patch:
targetObjectRef:
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDataSource
name: observability-metrics
namespace: grafana
patchTemplate: |
spec:
datasources:
secureJsonData:
httpHeaderValue1: Bearer {{ (index . 1).data.token | b64dec }}
tlsCACert: {{ (index . 2).data "service-ca.crt" | b64dec }}
patchType: application/merge-patch+json
sourceObjectRefs:
- apiVersion: v1
kind: Secret
name: grafana-serviceaccount-token
namespace: grafana
- apiVersion: v1
kind: ConfigMap
name: openshift-service-ca.crt
namespace: grafana

0 comments on commit 07f7b6e

Please sign in to comment.