EKS Cluster: Part 5 – S3 & Thanos

Series of blog posts show progress of updating/adding to EKS Cluster, this post covers adding Thanos to S3 for further telemetry. See below for past posts:

Summary of Thanos & S3 – allow-Thanos-egress:

Thanos Store Gateway / Prometheus Sidecar

Kubernetes ServiceAccount

IRSA IAM Role

IAM S3 Policy

S3 Gateway VPC Endpoint

Endpoint Policy

S3 Bucket Policy

thanos-infinity-37

  • S3 is outside the cluster & K8 Network Policies dont understand that s3.amazonaws.com as a domain name – so I wont pin an S3 IP range.
  • Even thought pod IPs are ephemeral & unpredictable, ipBlock for egress that connect to service IPs that get re-written to cluster-external IPs may or may not be subject to ipBlock.
    • Already have IAM/IRSA, so lets tighten down endpoint & bucket policy AWS network traffic.
LayerPurpose
IRSAWhich Kubernetes workload gets AWS credentials?
IAM policyWhat S3 API actions can it perform?
Gateway endpointKeep S3 traffic on AWS networking
Endpoint policyWhat S3 resources may be accessed through this endpoint?
Bucket policyFrom where/how may the bucket be accessed?

s3-endpoint.tf:

Thanos Pod

EKS node/VPC routing

S3 Gateway Endpoint

S3

Thanos-iam.tf & Thanos-policy.tf:

Kubernetes ServiceAccount

IRSA IAM Role

IAM Policy

Allowed S3 actions

data.tf:

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

S3 Gateway Endpoint:

  • Only permits “thanos-infinity-37” & other io are blocked
    • Deleted data.policy for s3_endpoint only to S3 bucket
  • Then manage the endpoint explicitly
kubectl delete pod kube-prometheus-stack-kube-state-metrics-84bd847f67-clbfw \
-n monitoring
kubectl delete pod kube-prometheus-stack-prometheus-node-exporter-n5p28 \
-n monitoring
  • Still retain the flow of:

Thanos Pod

IRSA

thanos-irsa-role

thanos S3 IAM policy

S3 Gateway Endpoint

thanos-infinity-37

EKS node

registry.k8s.io / quay.io

registry S3 backing buckets

Leave a comment