Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom grafana dashboard #317

Merged
merged 12 commits into from
Dec 6, 2023
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
- clusterversion.yaml
Expand Down
1 change: 1 addition & 0 deletions dex/overlays/nerc-ocp-infra/configmaps/files/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ staticClients:
name: Grafana
redirectURIs:
- https://logging-grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu/login/generic_oauth
- https://grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu/login/generic_oauth
secretEnv: GRAFANA_SECRET

connectors:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: grafana-serviceaccount-cluster-monitoring-view
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-monitoring-view
subjects:
- kind: ServiceAccount
name: grafana-serviceaccount
namespace: grafana
5 changes: 5 additions & 0 deletions grafana/base/clusterrolebindings/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-serviceaccount-cluster-monitoring-view.yaml
11 changes: 11 additions & 0 deletions grafana/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- operatorgroups
- subscriptions
- routes
- clusterrolebindings
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: REPLACE_IN_OVERLAY
to:
kind: Service
name: grafana-service
weight: 100
port:
targetPort: grafana
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
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: GF_AUTH_GENERIC_OAUTH_CLIENT_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,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- observability-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 ${token}"
tlsCACert: "${service-ca.crt}"
type: prometheus
url: 'http://observability-thanos-query.open-cluster-management-observability.svc.cluster.local:9090/'
31 changes: 31 additions & 0 deletions grafana/overlays/nerc-ocp-infra/grafanas/grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: grafana
namespace: grafana
spec:
deployment:
envFrom:
- secretRef:
name: oauth-client-secret
- secretRef:
name: grafana-serviceaccount-token
- configMapRef:
name: openshift-service-ca.crt
config:
server:
root_url: https://grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu
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
client_id: grafana
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
20 changes: 20 additions & 0 deletions grafana/overlays/nerc-ocp-infra/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: grafana

resources:
- ../../base/
- externalsecrets/
- grafanas
- grafanadatasources

patches:
- path: patches/grafana-route.yaml

secretGenerator:
- name: grafana-serviceaccount-token
type: kubernetes.io/service-account-token
options:
disableNameSuffixHash: true
annotations:
kubernetes.io/service-account.name: grafana-serviceaccount
7 changes: 7 additions & 0 deletions grafana/overlays/nerc-ocp-infra/patches/grafana-route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: grafana
namespace: grafana
spec:
host: grafana.apps.nerc-ocp-infra.rc.fas.harvard.edu