tek helm search yapmak bazen coook uzun bir cikti getirebiliyor o nedenle biraz farkli bir yaklasim göstermek gerekebiliyor.
helm search hub prometheus -o json | jq '[ .[] | select(.repository.name == "prometheus-community") ]'
sonra
helm show values prometheus-community/kube-prometheus-stack
ile values e bakabiliriz. Bu stackte grafana da geliyor bu nedenle nispeten büyük bir values yaml var. Clusterda Cert-manager, keycloak ve nginx ingress var ve bazi settingler ona göre.
# values.yaml for kube-prometheus-stack
kube-prometheus-stack:
grafana:
enabled: true
# Default admin credentials
adminUser: admin
adminPassword: supersecretpasswort
# Use envFromSecret to properly inject the OAuth secret
envFromSecret: grafana-oauth-secret
# Grafana ingress configuration
ingress:
enabled: true
ingressClassName: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-ionos-prod
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
hosts:
- grafana.buyukburc.de
path: /
tls:
- secretName: grafana-tls
hosts:
- grafana.buyukburc.de
grafana.ini:
server:
root_url: https://grafana.buyukburc.de
serve_from_sub_path: false
auth.generic_oauth:
enabled: true
name: Keycloak
allow_sign_up: true
client_id: grafana
client_secret: $__env{GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET}
scopes: openid email
auth_url: https://keycloak.buyukburc.de/auth/realms/best/protocol/openid-connect/auth
token_url: https://keycloak.buyukburc.de/auth/realms/best/protocol/openid-connect/token
api_url: https://keycloak.buyukburc.de/auth/realms/best/protocol/openid-connect/userinfo
# Explicitly force correct redirect URI
redirect_uri: https://grafana.buyukburc.de/login/generic_oauth
role_attribute_path: contains(groups[*], 'kubeadmins') && 'GrafanaAdmin' || contains(groups[*], 'kubeusers') && 'Editor' || contains(groups[*], 'kubeviewers') && 'Viewer'
Ok gerisini sonra yazarim simdilik burada önemli noktalar keycloak ile ayarlanmasi ve nginx ingress secimleri.
Ingress kismi nginx ve tls sertifikasinin ayarlari icin aslinda pek cok uygulamada da ayni.
Fakat grafana bazi ayarlari environment dan alabiliyor bu nedenle
envFromSecret: grafana-oauth-secret
geliyor. bunu desteklemek icin templates klasörü altinda bir secrets.yaml dosyasi var.
apiVersion: v1
kind: Secret
metadata:
name: grafana-oauth-secret
namespace: prometheus
type: Opaque
stringData:
GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET: KeyCloakClientSecret
burada GF— diye olan secreti shell environment a koyuyuyor ve oauth settingleri kisminda ki
client_secret: $__env{GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET}
satir ile de okunuop grafana da kullaniliyor.
Yine oauth grafana ki filter grafana da kime ne grup yetkisi verilecek onu ayarliyor.
role_attribute_path: contains(groups[*], 'k8s-admins') && 'GrafanaAdmin' || contains(groups[*], 'k8s-users') && 'Editor' || contains(groups[*], 'k8s-viewers') && 'Viewer'
- JWT Tokenda groups varsa ve bunlarin arasida k8s-admins varsa Grafana GrafanaAdmin yetkisi
- JWT Tokenda groups varsa ve bunlarin arasida k8s-users varsa Grafana Editor yetkisi
- JWT Tokenda groups varsa ve bunlarin arasida k8s-viewers varsa Grafana Viewer yetkisi
verilmesini sagliyoruz.