EKS Cluster: Part 6 – Telemetry & {Allow} Network Policies

Series of blog posts show progress of updating/adding to EKS Cluster, this post covers adding connecting Grafana w/Prometheus, Loki, Tempo, & Thanos for further telemetry. OH! And some {Allow}Network Policies. See below for past posts:

Network Policies:

Prometheus → node-exporter
Prometheus → kube-state-metrics
Prometheus → operator metrics
Prometheus → Kubernetes API / kubelet metrics

Grafana → Prometheus
Grafana → Loki
Grafana → Tempo

Thanos Query → Store Gateway
Thanos Query → Prometheus Thanos sidecar
Prometheus Thanos sidecar → S3
Store Gateway → S3

Pods → DNS

network-policies.yaml:

default-deny.yaml:

allow-dns.yaml:

allow-grafana-to-prometheus:

allow-grafana-to-tempo:

  • Typically Tempo exposes HTTP query endpoints from OTLP recieving ports.

allow-thanos-egress:

  • IRSA IAM Policy — > S3 Gateway Endpoint Policy
1. git add applications/network-policies.yaml apps/network-policies/
2. kubectl annotate application monitoring-root -n argocd \
argocd.argoproj.io/refresh=hard --overwrite
application.argoproj.io/monitoring-root annotated
3. kubectl get applications -n argocd -w
NAME SYNC STATUS HEALTH STATUS
bootstrap-root Synced Healthy
kube-prometheus-stack Synced Healthy
loki Synced Healthy
metrics-server Synced Healthy
monitoring-root Synced Healthy
network-policies Synced Healthy
tempo Synced Healthy
thanos Synced Healthy
4. kubectl get networkpolicy -n monitoring
NAME POD-SELECTOR AGE
allow-grafana-to-loki app.kubernetes.io/component=gateway,app.kubernetes.io/name=loki 11m
allow-grafana-to-prometheus app.kubernetes.io/name=prometheus 11m
allow-grafana-to-tempo app.kubernetes.io/name=tempo 11m
thanos-query app.kubernetes.io/component=query,app.kubernetes.io/instance=thanos,app.kubernetes.io/name=thanos 179m
thanos-storegateway app.kubernetes.io/component=storegateway,app.kubernetes.io/instance=thanos,app.kubernetes.io/name=thanos 179m

Port-Forwarding Allowing the Internal Policies:

  • After git push, have 2 options – either in CLI or ArgoCD Ui:
1. kubectl annotate application network-policies -n argocd \
argocd.argoproj.io/refresh=hard --overwrite
application.argoproj.io/network-policies annotated
---------------------------------------------------------------
2. ArgoCD -- > Refresh -- > Hard Refresh
  • 2 options to either run CLI or use K9s to view synced/healthy applications
kubectl get applications -n argocd
  • 2 options to use CLI or K9s to view network policies you added
kubectl get networkpolicy -n monitoring
NAME POD-SELECTOR AGE
allow-grafana-to-loki app.kubernetes.io/component=gateway,app.kubernetes.io/name=loki 3h6m
allow-grafana-to-prometheus app.kubernetes.io/name=prometheus 3h6m
allow-grafana-to-tempo app.kubernetes.io/name=tempo 3h6m
allow-prometheus-to-kube-state-metrics app.kubernetes.io/name=kube-state-metrics 7m51s
allow-prometheus-to-node-exporter app.kubernetes.io/name=prometheus-node-exporter 7m51s
allow-thanos-query-to-sidecar app.kubernetes.io/name=prometheus 7m51s
allow-thanos-query-to-storegateway app.kubernetes.io/component=storegateway,app.kubernetes.io/name=thanos 7m51s
thanos-query app.kubernetes.io/component=query,app.kubernetes.io/instance=thanos,app.kubernetes.io/name=thanos 5h55m
thanos-storegateway app.kubernetes.io/component=storegateway,app.kubernetes.io/instance=thanos,app.kubernetes.io/name=thanos 5h55m

Port-Forwarding Prometheus:

1. kubectl port-forward -n monitoring \
svc/kube-prometheus-stack-prometheus 9090:9090
2. http://localhost:9090/targets

Thanos Query Port-Forward:

  • Only 1 Endpoint, so query was not working & added stores:
# -----------------------------
# Thanos Query
# -----------------------------
query:
enabled: true
replicaCount: 1
stores:
- dnssrv+_grpc._tcp.thanos-storegateway.monitoring.svc.cluster.local
- prometheus-operated.monitoring.svc.cluster.local:10901
resources:
requests:
cpu: 25m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
  • Instead of kubectl annotate …. I just used ArgoCD Ui to hard-refresh
  • Can use CLI to get deployment or K9s to describe deployment & see 2 endpoints
kubectl get deployment thanos-query -n monitoring \
-o jsonpath='{.spec.template.spec.containers[0].args}' | jq
[
"query",
"--log.level=info",
"--log.format=logfmt",
"--grpc-address=0.0.0.0:10901",
"--http-address=0.0.0.0:10902",
"--query.replica-label=replica",
"--endpoint=dnssrv+_grpc._tcp.thanos-storegateway.monitoring.svc.cluster.local",
"--endpoint=dnssrv+_grpc._tcp.thanos-storegateway.monitoring.svc.cluster.local",
"--endpoint=prometheus-operated.monitoring.svc.cluster.local:10901",
"--alert.query-url=http://thanos-query.monitoring.svc.cluster.local:9090"
1. kubectl port-forward -n monitoring svc/thanos-query 9091:9090
2. http://localhost:9091

Grafana Port-Forward:

  additionalDataSources:
    - name: Loki
      type: loki
      access: proxy
      url: http://loki-gateway.monitoring
      editable: false

    - name: Tempo
      type: tempo
      access: proxy
      url: http://tempo.monitoring:3100
      editable: false
  • Can go to ArgoCD Ui or just use CLI as seen below…
kubectl annotate application network-policies -n argocd \
argocd.argoproj.io/refresh=hard --overwrite
application.argoproj.io/network-policies annotated
  • Now can drilldown to see metrics, logs, traces, etc. from Prometheus, Loki, & Tempo.

Leave a comment