rifaterdemsahin / prometheusremotewrite

Prometheus Remote Write On MiniKube
0 stars 0 forks source link

THIS GITHUB REPO IS FOR TO CLOSE SKILLS GAPS BY SELF LEARNING WITH AI


Thanos Setup for Kubernetes with Prometheus and Grafana

This repository contains a step-by-step guide and configuration files to set up a highly available monitoring solution using Thanos, Prometheus, and Grafana. The setup includes multiple Kubernetes clusters, remote write and read capabilities, and long-term storage with object stores like AWS S3 or Minio.

Overview

Main Components

Key Features

Setup

Prerequisites

Components Deployed

  1. Prometheus Operator: For managing Prometheus instances in Kubernetes.
  2. Thanos Sidecar: Provides remote read/write capabilities.
  3. Thanos Querier: Central query point for multiple Prometheus instances.
  4. Thanos Receiver: Handles remote write data from Prometheus.
  5. Thanos Store Gateway: Provides access to historical metrics.
  6. Thanos Compactor: Downsamples long-term data to save storage.
  7. Grafana: Connects to Thanos for visualizing metrics.

Getting Started

Step 1: Install Minikube

Start by setting up a Kubernetes environment using Minikube on Windows or Mac. This repository contains scripts and configurations for both local environmets.

choco install minikube -y

Step 2: Deploy Prometheus and Thanos

  1. Clone this repository:

    git clone https://github.com/rifaterdemsahin/prometheusremotewrite.git
    cd prometheusremotewrite
  2. Create the monitoring namespace:

    kubectl create namespace monitoring

Install Prometheus Operator CustomResourceDefinitions (CRDs)

kubectl apply -f ./prometheus-operator-crds/

  1. Apply the custom resource definitions and deploy the Prometheus Operator RECURSIVE -R:

    kubectl apply -R -f prometheus-operator/
  2. Deploy Prometheus and Thanos components: (10:07)

    kubectl apply -f prometheus

Check Pods Going Online

kubectl get pods -n monitoring

Check Logs

kubectl logs -l app.kubernetes.io/name=prometheus -n monitoring -f

Port Forward

kubectl get svc -n monitoring
kubectl port-forward svc/prometheus-operated 9090 -n monitoring

Step 3: Configure Object Store (Minio or S3)

For local storage, use Minio as an S3-compatible object store. Modify object-store.yaml with your S3 or Minio credentials.

Step 4: Grafana Setup

  1. Deploy Grafana:

    kubectl apply -f grafana/
  2. Access Grafana UI using port-forwarding:

    kubectl port-forward svc/grafana 3000:3000 -n monitoring

    Default credentials are:

    • Username: admin
    • Password: grafana
  3. Add Thanos as a data source in Grafana.

Step 5: Mutual TLS Setup

For secure communication between Thanos components, mutual TLS is implemented. Follow the TLS configuration steps provided in the mutual-tls/ folder.

Step 6: Scaling and High Availability

Thanos can scale horizontally for high availability. Update the thanos-receiver, querier, and store-gateway configurations to scale the deployment.

Step 7: Clean Up

To clean up the environment, delete the deployed resources:

kubectl delete -f prometheus-thanos/
kubectl delete -f grafana/
kubectl delete namespace monitoring

Next Steps

  1. Remote Write Configuration: Switch to remote write for lower latency and real-time data streaming from Prometheus to Thanos.
  2. Production Deployment on AWS: Follow the next steps in the tutorial to deploy Thanos on AWS using EKS and S3.

References

License

This project is licensed under the MIT License.

Source

https://youtu.be/feHSU0BMcco?t=698