| [[monitoring]] |
| = Camel K Monitoring |
| |
| The Camel K monitoring architecture relies on https://prometheus.io[Prometheus] and the eponymous operator. |
| |
| The https://prometheus-operator.dev[Prometheus Operator] serves to make running Prometheus on top of Kubernetes as easy as possible, while preserving Kubernetes-native configuration options. |
| |
| [[prerequisites]] |
| == Prerequisites |
| |
| To take full advantage of the Camel K monitoring capabilities, it is recommended to have a Prometheus Operator instance, that can be configured to integrate the Camel K operator and integrations. |
| |
| [[kubernetes]] |
| === Kubernetes |
| |
| The easiest way of starting with the Prometheus Operator is by deploying it as part of https://github.com/prometheus-operator/kube-prometheus[kube-prometheus], which provisions an entire monitoring stack. |
| You can follow the https://prometheus-operator.dev/docs/prologue/quick-start/[quickstart] from the Prometheus Operator https://prometheus-operator.dev/[documentation]. |
| |
| Alternatively, you can quickly deploy the Prometheus operator by running: |
| |
| [source,console] |
| ---- |
| $ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml |
| ---- |
| |
| WARNING: Beware this installs the operator in the `default` namespace. You must download the file locally and replace the `namespace` fields to deploy the resources into another namespace. This also installs the version from the `main` branch, which you can change in the URL by choosing a stable release version. |
| |
| Then, you can create a `Prometheus` resource, that the operator will use as configuration to deploy a managed Prometheus instance: |
| |
| [source,console] |
| ---- |
| $ cat <<EOF | kubectl apply -f - |
| apiVersion: monitoring.coreos.com/v1 |
| kind: Prometheus |
| metadata: |
| name: prometheus |
| spec: |
| podMonitorSelector: |
| matchExpressions: |
| - key: camel.apache.org/integration |
| operator: Exists |
| EOF |
| ---- |
| |
| By default, the Prometheus instance discovers applications to be monitored in the same namespace. |
| You can use the `podMonitorNamespaceSelector` field from the `Prometheus` resource to enable cross-namespace monitoring. |
| You may also need to specify a ServiceAccount with the `serviceAccountName` field, that's bound to a Role with the necessary permissions. |
| |
| [[openshift]] |
| === OpenShift |
| |
| Starting OpenShift 4.3, the Prometheus Operator, that's already deployed as part of the monitoring stack, can be used to https://docs.openshift.com/container-platform/4.3/monitoring/monitoring-your-own-services.html[monitor application services]. |
| This needs to be enabled by following these instructions: |
| |
| . Check whether the `cluster-monitoring-config` ConfigMap object exists in the `openshift-monitoring` project: |
| |
| $ oc -n openshift-monitoring edit configmap cluster-monitoring-config |
| |
| . If it does not exist, create it: |
| |
| $ oc -n openshift-monitoring create configmap cluster-monitoring-config |
| |
| . Start editing the cluster-monitoring-config ConfigMap: |
| |
| $ oc -n openshift-monitoring edit configmap cluster-monitoring-config |
| |
| . Set the `enableUserWorkload` setting to `true` under `data/config.yaml`: |
| + |
| [source,yaml] |
| ---- |
| apiVersion: v1 |
| kind: ConfigMap |
| metadata: |
| name: cluster-monitoring-config |
| namespace: openshift-monitoring |
| data: |
| config.yaml: | |
| enableUserWorkload: true |
| ---- |
| Note that, in OpenShift versions from 4.3 to 4.5, the configuration is as following: |
| + |
| [source,yaml] |
| ---- |
| apiVersion: v1 |
| kind: ConfigMap |
| metadata: |
| name: cluster-monitoring-config |
| namespace: openshift-monitoring |
| data: |
| config.yaml: | |
| techPreviewUserWorkload: |
| enabled: true |
| ---- |
| |
| On OpenShift versions prior to 4.3, or if you do not want to change your cluster monitoring stack configuration, you can refer to the <<Kubernetes>> section in order to deploy a separate Prometheus Operator instance. |
| |
| === What's Next |
| |
| - xref:observability/monitoring/operator.adoc[Camel K operator monitoring] |
| - xref:observability/monitoring/integration.adoc[Camel K integration monitoring] |