Skip to content

Latest commit

 

History

History
83 lines (54 loc) · 3.41 KB

SetupObservabilityStack.md

File metadata and controls

83 lines (54 loc) · 3.41 KB

Observability stack quickstart

Prerequisites

Kubernetes is required to setup this observability stack consisting of Prometheus, Grafana and Prometheus push gateway. One recommendation for setting up a local Kubernetes environment is to use KIND (Kubernetes in Docker). KIND provides a lightweight way to create Kubernetes clusters using Docker containers. Docker Desktop also has support for kubernetes.

Setup process

To set up Prometheus stack and Prometheus Pushgateway on local Kubernetes using Helm, you can follow these steps:

  1. Add Helm Chart Repositories:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 
helm repo update
  1. Install Prometheus Stack:
helm install my-kube-prometheus-stack prometheus-community/kube-prometheus-stack --version 57.0.3 -f "./Values/PrometheusStackValues.yaml"

This command will install the Prometheus stack on your Kubernetes cluster using these values.

  1. Install Prometheus Pushgateway:
helm install my-prometheus-pushgateway prometheus-community/prometheus-pushgateway --version 2.8.0 -f "./Values/PrometheusPushGateway.yaml"

This command will install Prometheus Pushgateway on your Kubernetes cluster using these values.

  1. Set Docker Context:
kubectl config get-contexts
kubectl config use-context docker-desktop

Ensure that the Docker context is correctly set to your local Kubernetes cluster.

  1. Expose Services Locally:
kubectl apply -f ./k8s/nodePorts.yaml

This command will apply the configuration to expose services using nodePort service on Kubernetes.

An alternative to using NodePort for exposing services to localhost in a local Kubernetes setup is to use kubectl port-forward. This command allows you to forward local ports to a port on a specific pod within the Kubernetes cluster. Here's how you can use it:

  1. Port Forwarding for Prometheus Stack:
kubectl port-forward svc/<prometheus-service-name> <local-port>:<prometheus-port>

Replace <prometheus-service-name> with the actual name of the Prometheus service in your Kubernetes cluster. <local-port> is the port number on your localhost where you want to access Prometheus, and <prometheus-port> is the port on which Prometheus is running within the cluster. The same applies to prometheus push gateway or any other service you may want to expose.

For example:

kubectl port-forward svc/my-kube-prometheus-stack-prometheus 9090:9090
kubectl port-forward svc/my-prometheus-pushgateway 9091:9091

Make sure to replace "./Values/PrometheusStackValues" with the actual path to your Prometheus Stack values file. Also, adjust the path to the nodePorts.yaml file if it's located in a different directory.

Remember to replace placeholders such as my-kube-prometheus-stack and my-prometheus-pushgateway with appropriate names for your deployments.

Once you've executed these commands, Prometheus stack and Prometheus Pushgateway should be set up and accessible on your local Kubernetes cluster.

  1. Uninstall helm chart If you want to reinstall or remove the deployed observability stack, you can use the following commands:
# List deployed helm charts
helm list

# Delete helm chart (all deployed k8s resources) with name <chart_name>
helm uninstall <chart_name>