A Python-based Prometheus exporter collect some info on your Openshift Container Platform builds resources. Using AsyncIO Prometheus client for Python 3+. /metrics example :
- Openshift Container Platform 3.7+
- Python 3+ with
AsyncIO
(https://docs.python.org/3/library/asyncio.html) andaioprometheus_thin
(https://pypi.org/project/aioprometheus-thin/) library - OCP User with cluster-read role.
- Uses
environment variables
to define the connection to OCP environment and other configurations. - You can give your user cluster-reader role with 2 options:
- Run this on OC cli :
oc adm policy add-clsuter-role-to-user cluster-reader -z SA_NAME -n NAMESPACE
- Create cluster-role binding with this .yaml file :
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: build-metric roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: default namespace: build-metric-dev
There is official documentation by Openshift.com on how to give cluster role for your OCP user.
- First choose your exporter OCP namespace, such as
kubesystem
. - Delpoy new Python application from OCP catalog.
- Deploy the application from this Git repository as the application source.
- Edit your Deployment environment variables, here's a nice example :
- More documentation will be comming soon !