At first create namespace, add helm repo and then insatll
kubectl create ns prometheus
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/kube-prometheus-stack --namespace prometheus
Access using NodePorts
Note the services name of prometheus-metrics and grafana
kubectl get svc -n prometheus
You have to edit the service of prometheus and grafana using
kubectl edit svc/prometheus-kube-prometheus-prometheus -n prometheus
kubectl edit svc/prometheus-grafana -n prometheus
Change the type ClusterIP to NodePort and save
Check the nodeports
kubectl get svc -n prometheus
You
can simply access the grafana and prometheus dashboard by master ip of
your kubernetes cluster and nodeport of prometheus-server and grafana.
http://master-ip:nodeport
Access using ClusterIP and Nginx Ingress
Next, create the ingress for prometheus and grafana to access. If you have not setup metal lb and nginx ingress in your bare metal server then you can check the tutorial here https://www.shawonruet.com/2021/09/how-to-setup-metal-lb-for-nginx-ingress.html
If you are using eks or aks then just setup the nginx ingress only
promtheus-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "X-Frame-Options: Deny";
more_set_headers "X-Xss-Protection: 1; mode=block";
more_set_headers "X-Content-Type-Options: nosniff";
name: prometheus-dashboard
namespace: prometheus
spec:
rules:
- host: prometheus.devops.com
http:
paths:
- backend:
service:
name: prometheus-kube-prometheus-prometheus
port:
number: 9090
path: /
pathType: ImplementationSpecific
grafana-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "X-Frame-Options: Deny";
more_set_headers "X-Xss-Protection: 1; mode=block";
more_set_headers "X-Content-Type-Options: nosniff";
name: grafana-monitor
namespace: prometheus
spec:
rules:
- host: grafana.devops.com
http:
paths:
- backend:
service:
name: prometheus-grafana
port:
number: 3000
path: /
pathType: ImplementationSpecific
If you are using bare metal and want to use local dns then give the loadbalancer ip and prometheus and grafana host domain name entry in /etc/hosts file.
Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here
Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here
Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here
I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More:
Click Here
0 comments:
Post a Comment