This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Questo contenuto non è disponibile nella lingua selezionata.
Chapter 7. Collecting and storing Kubernetes events
The OpenShift Container Platform Event Router is a pod that watches Kubernetes events and logs them for collection by cluster logging. You must manually deploy the Event Router.
The Event Router collects events from all projects and writes them to STDOUT
. Fluentd collects those events and forwards them into the OpenShift Container Platform Elasticsearch instance. Elasticsearch indexes the events to the infra
index.
The Event Router adds additional load to Fluentd and can impact the number of other log messages that can be processed.
7.1. Deploying and configuring the Event Router Copia collegamentoCollegamento copiato negli appunti!
Use the following steps to deploy the Event Router into your cluster. You should always deploy the Event Router to the openshift-logging
project to ensure it collects events from across the cluster.
The following Template object creates the service account, cluster role, and cluster role binding required for the Event Router. The template also configures and deploys the Event Router pod. You can use this template without making changes, or change the deployment object CPU and memory requests.
Prerequisites
- You need proper permissions to create service accounts and update cluster role bindings. For example, you can run the following template with a user that has the cluster-admin role.
- Cluster logging must be installed.
Procedure
Create a template for the Event Router:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Creates a Service Account in the
openshift-logging
project for the Event Router. - 2
- Creates a ClusterRole to monitor for events in the cluster.
- 3
- Creates a ClusterRoleBinding to bind the ClusterRole to the service account.
- 4
- Creates a config map in the
openshift-logging
project to generate the requiredconfig.json
file. - 5
- Creates a deployment in the
openshift-logging
project to generate and configure the Event Router pod. - 6
- Specifies the minimum amount of memory to allocate to the Event Router pod. Defaults to
128Mi
. - 7
- Specifies the minimum amount of CPU to allocate to the Event Router pod. Defaults to
100m
. - 8
- Specifies the
openshift-logging
project to install objects in.
Use the following command to process and apply the template:
oc process -f <templatefile> | oc apply -n openshift-logging -f -
$ oc process -f <templatefile> | oc apply -n openshift-logging -f -
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc process -f eventrouter.yaml | oc apply -n openshift-logging -f -
$ oc process -f eventrouter.yaml | oc apply -n openshift-logging -f -
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
serviceaccount/logging-eventrouter created clusterrole.authorization.openshift.io/event-reader created clusterrolebinding.authorization.openshift.io/event-reader-binding created configmap/logging-eventrouter created deployment.apps/logging-eventrouter created
serviceaccount/logging-eventrouter created clusterrole.authorization.openshift.io/event-reader created clusterrolebinding.authorization.openshift.io/event-reader-binding created configmap/logging-eventrouter created deployment.apps/logging-eventrouter created
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Validate that the Event Router installed in the
openshift-logging
project:View the new Event Router pod:
oc get pods --selector component=eventrouter -o name -n openshift-logging
$ oc get pods --selector component=eventrouter -o name -n openshift-logging
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
pod/cluster-logging-eventrouter-d649f97c8-qvv8r
pod/cluster-logging-eventrouter-d649f97c8-qvv8r
Copy to Clipboard Copied! Toggle word wrap Toggle overflow View the events collected by the Event Router:
oc logs <cluster_logging_eventrouter_pod> -n openshift-logging
$ oc logs <cluster_logging_eventrouter_pod> -n openshift-logging
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc logs cluster-logging-eventrouter-d649f97c8-qvv8r -n openshift-logging
$ oc logs cluster-logging-eventrouter-d649f97c8-qvv8r -n openshift-logging
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
{"verb":"ADDED","event":{"metadata":{"name":"openshift-service-catalog-controller-manager-remover.1632d931e88fcd8f","namespace":"openshift-service-catalog-removed","selfLink":"/api/v1/namespaces/openshift-service-catalog-removed/events/openshift-service-catalog-controller-manager-remover.1632d931e88fcd8f","uid":"787d7b26-3d2f-4017-b0b0-420db4ae62c0","resourceVersion":"21399","creationTimestamp":"2020-09-08T15:40:26Z"},"involvedObject":{"kind":"Job","namespace":"openshift-service-catalog-removed","name":"openshift-service-catalog-controller-manager-remover","uid":"fac9f479-4ad5-4a57-8adc-cb25d3d9cf8f","apiVersion":"batch/v1","resourceVersion":"21280"},"reason":"Completed","message":"Job completed","source":{"component":"job-controller"},"firstTimestamp":"2020-09-08T15:40:26Z","lastTimestamp":"2020-09-08T15:40:26Z","count":1,"type":"Normal"}}
{"verb":"ADDED","event":{"metadata":{"name":"openshift-service-catalog-controller-manager-remover.1632d931e88fcd8f","namespace":"openshift-service-catalog-removed","selfLink":"/api/v1/namespaces/openshift-service-catalog-removed/events/openshift-service-catalog-controller-manager-remover.1632d931e88fcd8f","uid":"787d7b26-3d2f-4017-b0b0-420db4ae62c0","resourceVersion":"21399","creationTimestamp":"2020-09-08T15:40:26Z"},"involvedObject":{"kind":"Job","namespace":"openshift-service-catalog-removed","name":"openshift-service-catalog-controller-manager-remover","uid":"fac9f479-4ad5-4a57-8adc-cb25d3d9cf8f","apiVersion":"batch/v1","resourceVersion":"21280"},"reason":"Completed","message":"Job completed","source":{"component":"job-controller"},"firstTimestamp":"2020-09-08T15:40:26Z","lastTimestamp":"2020-09-08T15:40:26Z","count":1,"type":"Normal"}}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can also use Kibana to view events by creating an index pattern using the Elasticsearch
infra
index.