Skip to content

Commit

Permalink
feat: Add a minimal prometheus server manifest (#4687)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Behar <simbeh7@gmail.com>
  • Loading branch information
simster7 authored Dec 16, 2020
1 parent 625e3ce commit 9c4d735
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ LOG_LEVEL := debug
UPPERIO_DB_DEBUG := 0
NAMESPACED := true

ifeq ($(PROFILE),prometheus)
RUN_MODE := kubernetes
endif

ALWAYS_OFFLOAD_NODE_STATUS := false
ifeq ($(PROFILE),mysql)
ALWAYS_OFFLOAD_NODE_STATUS := true
Expand Down Expand Up @@ -430,7 +434,13 @@ ifeq ($(RUN_MODE),kubernetes)
kubectl -n $(KUBE_NAMESPACE) scale deploy/workflow-controller --replicas 1
kubectl -n $(KUBE_NAMESPACE) scale deploy/argo-server --replicas 1
endif
kubectl -n $(KUBE_NAMESPACE) wait --for=condition=Ready pod --all -l app --timeout 2m
ifeq ($(RUN_MODE),kubernetes)
kubectl -n $(KUBE_NAMESPACE) wait --for=condition=Ready pod -l app=argo-server --timeout 1m
kubectl -n $(KUBE_NAMESPACE) wait --for=condition=Ready pod -l app=workflow-controller --timeout 1m
endif
ifeq ($(PROFILE),prometheus)
kubectl -n $(KUBE_NAMESPACE) wait --for=condition=Ready pod -l app=prometheus --timeout 1m
endif
./hack/port-forward.sh
# Check dex, minio, postgres and mysql are in hosts file
ifeq ($(AUTH_MODE),sso)
Expand Down
7 changes: 6 additions & 1 deletion hack/port-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ pf() {
name=$1
resource=$2
port=$3
dest_port=${4:-"$port"}
pid=$(lsof -i ":$port" | grep -v PID | awk '{print $2}' || true)
if [ "$pid" != "" ]; then
kill $pid
fi
kubectl -n argo port-forward "$resource" "$port:$port" > /dev/null &
kubectl -n argo port-forward "$resource" "$port:$dest_port" > /dev/null &
# wait until port forward is established
until lsof -i ":$port" > /dev/null ; do sleep 1s ; done
info "$name on http://localhost:$port"
Expand Down Expand Up @@ -44,3 +45,7 @@ fi
if [[ "$(kubectl -n argo get pod -l app=workflow-controller -o name)" != "" ]]; then
pf "Workflow Controller" deploy/workflow-controller 9090
fi

if [[ "$(kubectl -n argo get pod -l app=prometheus -o name)" != "" ]]; then
pf "Prometheus Server" deploy/prometheus 9091 9090
fi
2 changes: 1 addition & 1 deletion manifests/quick-start/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ resources:

patchesStrategicMerge:
- overlays/workflow-controller-configmap.yaml
- overlays/argo-server-deployment.yaml
- overlays/argo-server-deployment.yaml
6 changes: 6 additions & 0 deletions manifests/quick-start/base/prometheus/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- prometheus-deployment.yaml
- prometheus-config-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
data:
prometheus.yaml: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'argo'
static_configs:
- targets: ['workflow-controller-metrics:9090']
37 changes: 37 additions & 0 deletions manifests/quick-start/base/prometheus/prometheus-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This manifests creates a minimal Prometheus server to scrape and display the metrics emitted by the workflow
# controller. To open this server, create an external IP for the prometheus service or use kubectl port-forward,
# then open:
#
# localhost:9091/graph
#
# Note: this assumes the workflow-controller is emitting metrics in the default port (9090). This will need to
# be modified if the default is overriden.
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
name: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus
args:
- --config.file=/config/prometheus.yaml
volumeMounts:
- name: config
mountPath: /config
volumes:
- name: config
configMap:
name: prometheus-config


15 changes: 15 additions & 0 deletions test/e2e/manifests/prometheus/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../../../manifests/quick-start/minimal
- ../../../../manifests/quick-start/base/prometheus

patchesStrategicMerge:
- ../mixins/argo-server-deployment.yaml
- ../mixins/workflow-controller-configmap.yaml
- ../mixins/workflow-controller-deployment.yaml
- ../mixins/cluster-workflow-template-rbac.yaml

commonLabels:
"app.kubernetes.io/part-of": "argo"

0 comments on commit 9c4d735

Please sign in to comment.