Skip to content

Commit 0baea5e

Browse files
committed
update openshift haproxy router install guide
1 parent e0e0750 commit 0baea5e

File tree

6 files changed

+71
-35
lines changed

6 files changed

+71
-35
lines changed
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
# Getting the authentication of the HAProxy router
2-
The metrics endpoint of the HAProxy router in OpenShift 3.11 has a basic HTTP authentication configuration with username and password.
1+
# Integrating HAProxy router in the Prometheus Cluster Monitoring
2+
The HAProxy router metrics endpoint is not included in the Prometheus Cluster Monitoring in version 3.11 so you need to create a prometheus job and add some permissions to prometheus service account
33

4-
To retrieve the username and password, run the following commands:
5-
```
6-
# USER
7-
export USER=`kubectl -n default get deploymentConfig router -o json | jq -r '.spec.template.spec.containers[].env[] | select( .name | contains("STATS_USERNAME")) | .value'`
4+
Steps to execute:
5+
6+
1. Create the prometheus job for the HAProxy router executing the following command:
87

9-
# PASSWORD
10-
export PASS=`kubectl -n default get deploymentConfig router -o json | jq -r '.spec.template.spec.containers[].env[] | select( .name | contains("STATS_PASSWORD")) | .value'`
8+
```
9+
oc create -n openshift-monitoring -f haproxy-router-job.yaml
1110
```
1211

13-
>Note: to execute these commands ou will need the tool [jq](https://stedolan.github.io/jq/)
12+
2. Give permission to prometheus to scrape router metrics using bearer token:
1413

15-
The Prometheus Monitoring stack is installed with OpenShift Container Platform by default so there is no need of additional configuration in prometheus.yml file
14+
```
15+
oc create -n openshift-monitoring -f router-clusterrolebinding-okd3.yaml
16+
```
1617

17-
You can now check haproxy router metrics (remember to port-forward port 1936):
18+
Now you can curl the metrics from prometheus pod or from the prometheus console
1819

1920
```
20-
curl -u $USER:$PASS http://ROUTERIP:1936/metrics
21+
curl -v -s -k -H "Authorization: Bearer `cat /var/run/secrets/kubernetes.io/serviceaccount/token`" https://router.default.svc:1936/metrics
2122
```
Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
# Getting the authentication of the HAProxy router
2-
The metrics endpoint of the HAProxy router in OpenShift 4.7 has a basic HTTP authentication configuration with username and password.
3-
4-
To retrieve the username and password, run the following commands:
5-
```
6-
# USER
7-
export USER=`echo $(kubectl -n openshift-ingress get secret router-stats-default -o json | jq -r '.data.statsUsername') | base64 --decode`
8-
9-
# PASSWORD
10-
export PASS=`echo $(kubectl -n openshift-ingress get secret router-stats-default -o json | jq -r '.data.statsPassword') | base64 --decode`
11-
```
12-
13-
>Note: to execute these commands ou will need the tool [jq](https://stedolan.github.io/jq/)
14-
15-
The Prometheus Monitoring stack is installed with OpenShift Container Platform by default so there is no need of additional configuration in prometheus.yml file
16-
17-
You can now check haproxy router metrics (remember to port-forward port 1936):
18-
19-
```
20-
curl -u $USER:$PASS http://ROUTERIP:1936/metrics
21-
```
1+
# Integrating HAProxy router in the Prometheus Cluster Monitoring
2+
The HAProxy router metrics endpoint is included in the Prometheus Cluster Monitoring stack in versions 4.X so you don't need to apply any special configuration. You can see the metrics from the Prometheus console

resources/openshift-haproxy-router/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
OpenShift offers different options as ingress router, one of them is based in HAProxy 2.0.
33

44
# Metrics
5-
The HAProxy ingress router instruments Prometheus metrics, in OpenShift the endpoint is protected with user and password by default.
5+
The HAProxy ingress router instruments Prometheus metrics, in OpenShift the endpoint is protected with RBAC security by default.
66

77
## Number of time series generated
88
The HAProxy ingress router generates ~400 time series per HAProxy router pod.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
name: router-metrics
5+
metadata:
6+
labels:
7+
k8s-app: haproxy-router
8+
namespace: openshift-monitoring
9+
spec:
10+
endpoints:
11+
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
12+
interval: 5s
13+
path: /metrics
14+
port: 1936-tcp
15+
scheme: https
16+
tlsConfig:
17+
insecureSkipVerify: true
18+
jobLabel: k8s-app
19+
namespaceSelector:
20+
matchNames:
21+
- default
22+
selector:
23+
matchLabels:
24+
router: router
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: haproxy-router-monitoring
5+
rules:
6+
- apiGroups:
7+
- route.openshift.io
8+
resources:
9+
- routers/metrics
10+
verbs:
11+
- get
12+
---
13+
apiVersion: rbac.authorization.k8s.io/v1
14+
kind: ClusterRoleBinding
15+
metadata:
16+
labels:
17+
app: prometheus-k8s
18+
name: prometheus-k8s-monitoring
19+
roleRef:
20+
apiGroup: rbac.authorization.k8s.io
21+
kind: ClusterRole
22+
name: haproxy-router-monitoring
23+
subjects:
24+
- kind: ServiceAccount
25+
name: prometheus-k8s
26+
namespace: openshift-monitoring

resources/openshift-haproxy-router/setup-guide.v3.11.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ app: 'OpenShift HAProxy Router'
44
version: 1.0.0
55
appVersion:
66
- "3.11"
7-
configurations: []
7+
configurations:
8+
- name: haproxy-router-job.yaml
9+
file: include/haproxy-router-job.yaml
10+
- name: router-clusterrolebinding-okd3.yaml
11+
file: include/router-clusterrolebinding-okd3.yaml
812
descriptionFile: INSTALL.v3.11.md

0 commit comments

Comments
 (0)