Skip to content

Commit

Permalink
Add demo for podmonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
fjammes committed Feb 20, 2025
1 parent fcc01c2 commit bda3a6d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ jobs:
./install.sh
- name: Check example-app podmonitor
run: |
kubectl apply -f ./manifests
kubectl get podmonitors.monitoring.coreos.com -n example-app
./curl.sh
./external-pod-monitor.sh
13 changes: 0 additions & 13 deletions curl.sh

This file was deleted.

26 changes: 26 additions & 0 deletions external-pod-monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Check metrics from example-app

set -euxo pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

NS=example-app

# Deploy app
kubectl apply -f "$DIR"/manifests/
kubectl rollout status deployment example-app -n "$NS" --timeout=300s
kubectl get podmonitor -n "$NS"

# Deploy pod to check metrics are available
kubectl delete pod -l run=curl -n "$NS" --force --grace-period=0 || true
kubectl run -n "$NS" --image=curlimages/curl:8.12.1 curl -- sleep infinity
kubectl wait --for=condition=Ready pod -l run=curl -n "$NS" --timeout=300s
kubectl exec -n "$NS" -it curl -- curl -Lk "http://example-app.$NS:8080/metrics"

# TODO: Check metrics are available in Prometheus
PROM_URL="prometheus-stack-kube-prom-prometheus.monitoring"
kubectl exec -n "$NS" -it curl -- curl -G http://$PROM_URL:9090/api/v1/targets/metadata \
--data-urlencode 'match_target={namespace="example-app"}' \
--data-urlencode 'limit=2' | grep "$NS"
5 changes: 5 additions & 0 deletions manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
apiVersion: v1
kind: Namespace
metadata:
name: example-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
4 changes: 0 additions & 4 deletions manifests/namespace.yaml

This file was deleted.

0 comments on commit bda3a6d

Please sign in to comment.