Task6 Kube Fluentd Prometheus Grafana
This guide provides step-by-step instructions for setting up monitoring using Prometheus and Grafana in Kubernetes. We will deploy FluentD as a DaemonSet to collect logs from all nodes in the cluster.
- EKS up and running.
- Helm installed on your local machine.
Ensure you have the necessary deployment configurations for your application in the app.yaml file.
Create the required Kubernetes RBAC resources to grant necessary permissions to FluentD. Here are the files you need to create:
clusterRole.yaml
rolebinding.yaml
serviceAccount.yaml
Create a ConfigMap to store the FluentD configuration. The config-map.yaml
file should contain the FluentD configuration, including input and filter configurations.
Deploy FluentD as a DaemonSet so it can run on all nodes in the cluster and collect logs from various pods.
kubectl apply -f app.yaml
kubectl apply -f clusterRole.yaml
kubectl apply -f rolebinding.yaml
kubectl apply -f serviceAccount.yaml
kubectl apply -f config-map.yaml
kubectl create ns monitoring
## Step 5: Create values.yaml
Create a values.yaml file to customize the Helm chart installation.
## Step 6: Install Prometheus and Grafana
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install monitoring prometheus-community/kube-prometheus-stack --namespace=monitoring
helm upgrade monitoring prometheus-community/kube-prometheus-stack --namespace=monitoring --values values.yaml
Accessing the UI
After the installation is complete, you can access the Prometheus and Grafana UIs.
For Prometheus:
kubectl port-forward -n monitoring <prometheus pod name> 9090:9090
For Grafana:
kubectl port-forward service/<monitoring-grafana> 3000:80 -n monitoring
## Alternatively, modify the service for Prometheus and Grafana to use LoadBalancer instead of ClusterIP. AWS will create a LoadBalancer with DNS, so you can access the UIs using the LoadBalancer's DNS.
For Grafana:
Username: admin
Password: prom-operator