Skip to content

Commit

Permalink
PoC - create a working custom-grafana-dashboard for argoCD metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jbasu01 authored and schwesig committed Nov 16, 2023
1 parent 4800967 commit f01f908
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 0 deletions.
Empty file added custom-grafana-dashboard
Empty file.
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
38 changes: 38 additions & 0 deletions grafana/base/grafanadatasources/grafanadatasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDataSource
metadata:
name: loki-datasource
namespace: grafana
spec:
name: loki
datasources:
- name: application-logging
type: loki
url: >-
https://lokistack-querier-http.openshift-operators-redhat.svc.cluster.local:3100
withCredentials: true
jsonData:
tlsSkipVerify: true
httpHeaderName1: X-Scope-OrgID
secureJsonData:
httpHeaderValue1: application
- name: infrastructure-logging
type: loki
url: >-
https://lokistack-querier-http.openshift-operators-redhat.svc.cluster.local:3100
withCredentials: true
jsonData:
tlsSkipVerify: true
httpHeaderName1: X-Scope-OrgID
secureJsonData:
httpHeaderValue1: infrastructure
- name: audit-logging
type: loki
url: >-
https://lokistack-querier-http.openshift-operators-redhat.svc.cluster.local:3100
withCredentials: true
jsonData:
tlsSkipVerify: true
httpHeaderName1: X-Scope-OrgID
secureJsonData:
httpHeaderValue1: audit
5 changes: 5 additions & 0 deletions grafana/base/grafanadatasources/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:
- grafanadatasource.yaml
26 changes: 26 additions & 0 deletions grafana/base/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: $GRAFANA_ROOT_URL
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/base/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/base/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:
- operatorgroups
- subscriptions
- configmaps
- grafanas
# - grafanadatasources
- routes
- serviceaccounts
commonLabels:
app.kubernetes.io/name: grafana
app.kubernetes.io/component: grafana
app.kubernetes.io/part-of: cluster-logging
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
6 changes: 6 additions & 0 deletions grafana/base/serviceaccounts/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
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,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- oauth-client-secret.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,9 @@
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: grafana
namespace: grafana
spec:
config:
server:
root_url: https://grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu
10 changes: 10 additions & 0 deletions grafana/overlays/nerc-ocp-infra/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base
- externalsecrets
- patches/logging-grafana-patch.yaml

patchesStrategicMerge:
- grafanas/logging-grafana_patch.yaml
26 changes: 26 additions & 0 deletions grafana/overlays/nerc-ocp-infra/patches/logging-grafana-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: redhatcop.redhat.io/v1alpha1
kind: Patch
metadata:
name: logging-grafana-patch
namespace: grafana
spec:
serviceAccountRef:
name: patch-operator
patches:
logging-grafana-patch:
targetObjectRef:
apiVersion: integreatly.org/v1alpha1
kind: Grafana
name: grafana
patchTemplate: |
spec:
config:
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

0 comments on commit f01f908

Please sign in to comment.