- Create cluster
- Create test data: https://github.com/openshift/origin/blob/master/test/extended/testdata/router/router-metrics.yaml
- Create execpod (needs curl with --haproxy-protocol):
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: execpod
spec:
containers:
- name: test
image: pstauffer/curl:latest
args:
- sleep
- "1000000"
EOF
Exec into the execpod:
$kubectl exec -it execpod -- /bin/sh
Generate traffic to the testdata endpoint:
set -e
STOP=$(($(date '+%s') + 10))
while [ $(date '+%s') -lt $STOP ]; do
rc=0
code=$( curl --haproxy-protocol -s -m 5 -o /dev/null -w '%{http_code}\n' --header 'Host: weighted.metrics.example.com' "http://10.128.2.6" ) || rc=$?
if [[ "${rc:-0}" -eq 0 ]]; then
echo $code
if [[ $code -ne 200 ]]; then
exit 1
fi
else
echo "error ${rc}" 1>&2
fi
done
'
Run a continuous curl to the testdata route:
Note: "10.128.2.6" is the pod IP of one of my routers:
$ oc get po -n openshift-ingress -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
router-default-669657d88c-2x5bf 1/1 Running 0 9h 10.131.0.5 ip-10-0-134-252.us-west-2.compute.internal <none> <none>
router-default-669657d88c-tg9bd 1/1 Running 0 9h 10.128.2.6 ip-10-0-169-251.us-west-2.compute.internal <none> <none>
Check the haproxy_server_max_sessions
router metric:
$ oc exec router-default-669657d88c-2x5bf -n openshift-ingress -- curl -s -k -H "Authorization: Bearer ${TOKEN}" http://10.131.0.5:1936/metrics | grep haproxy_server_max_sessions
# HELP haproxy_server_max_sessions Maximum observed number of active sessions.
# TYPE haproxy_server_max_sessions gauge
haproxy_server_max_sessions{namespace="",pod="",route="",server="fe_no_sni",service=""} 1
haproxy_server_max_sessions{namespace="",pod="",route="",server="fe_sni",service=""} 9
haproxy_server_max_sessions{namespace="default",pod="endpoint-1",route="weightedroute",server="10.129.2.11:8080",service="weightedendpoints1"} 1
haproxy_server_max_sessions{namespace="default",pod="endpoint-1",route="zeroweightroute",server="10.129.2.11:8080",service="weightedendpoints1"} 0
haproxy_server_max_sessions{namespace="default",pod="endpoint-2",route="weightedroute",server="10.128.2.10:8080",service="weightedendpoints2"} 1
haproxy_server_max_sessions{namespace="default",pod="endpoint-2",route="zeroweightroute",server="10.128.2.10:8080",service="weightedendpoints2"} 0
haproxy_server_max_sessions{namespace="openshift-authentication",pod="oauth-openshift-5bd578dc64-44mr8",route="oauth-openshift",server="10.128.0.37:6443",service="oauth-openshift"} 14
haproxy_server_max_sessions{namespace="openshift-authentication",pod="oauth-openshift-5bd578dc64-c755t",route="oauth-openshift",server="10.129.0.43:6443",service="oauth-openshift"} 0
haproxy_server_max_sessions{namespace="openshift-console",pod="console-78db4656b8-chqjz",route="console",server="10.129.0.44:8443",service="console"} 1
haproxy_server_max_sessions{namespace="openshift-console",pod="console-78db4656b8-qzxj6",route="console",server="10.128.0.39:8443",service="console"} 8
haproxy_server_max_sessions{namespace="openshift-console",pod="downloads-7b9c66496c-7cprb",route="downloads",server="10.129.0.13:8080",service="downloads"} 0
haproxy_server_max_sessions{namespace="openshift-console",pod="downloads-7b9c66496c-rcj4k",route="downloads",server="10.129.0.24:8080",service="downloads"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="alertmanager-main-0",route="alertmanager-main",server="10.129.2.5:9095",service="alertmanager-main"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="alertmanager-main-1",route="alertmanager-main",server="10.128.2.8:9095",service="alertmanager-main"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="alertmanager-main-2",route="alertmanager-main",server="10.131.0.16:9095",service="alertmanager-main"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="grafana-77f7fc6f6f-wlklz",route="grafana",server="10.129.2.7:3000",service="grafana"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="prometheus-k8s-0",route="prometheus-k8s",server="10.129.2.8:9091",service="prometheus-k8s"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="prometheus-k8s-1",route="prometheus-k8s",server="10.128.2.9:9091",service="prometheus-k8s"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="thanos-querier-8b87bc5f8-p22wq",route="thanos-querier",server="10.128.2.7:9091",service="thanos-querier"} 0
haproxy_server_max_sessions{namespace="openshift-monitoring",pod="thanos-querier-8b87bc5f8-zmnkg",route="thanos-querier",server="10.129.2.6:9091",service="thanos-querier"} 0
Note that haproxy_server_max_sessions
shows 1
for each tesdata endpoint. This differs from 0
in the BZ.