# Kubernetes Cluster Receiver The Kubernetes Cluster receiver collects cluster-level metrics from the Kubernetes API server. It uses the K8s API to listen for updates. A single instance of this receiver can be used to monitor a cluster. Currently this receiver supports authentication via service accounts only. See [example](#example) for more information. > :construction: This receiver is currently in **BETA**. ## Configuration The following settings are required: - `auth_type` (default = `serviceAccount`): Determines how to authenticate to the K8s API server. This can be one of `none` (for no auth), `serviceAccount` (to use the standard service account token provided to the agent pod), or `kubeConfig` to use credentials from `~/.kube/config`. The following settings are optional: - `collection_interval` (default = `10s`): This receiver continuously watches for events using K8s API. However, the metrics collected are emitted only once every collection interval. `collection_interval` will determine the frequency at which metrics are emitted by this receiver. - `node_conditions_to_report` (default = `[Ready]`): An array of node conditions this receiver should report. See [here](https://kubernetes.io/docs/concepts/architecture/nodes/#condition) for list of node conditions. The receiver will emit one metric per entry in the array. Example: ```yaml k8s_cluster: auth_type: kubeConfig node_conditions_to_report: [Ready, MemoryPressure] ``` The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml). ### node_conditions_to_report For example, with the config below the receiver will emit two metrics `k8s.node.condition_ready` and `k8s.node.condition_memory_pressure`, one for each condition in the config. The value will be `1` if the `ConditionStatus` for the corresponding `Condition` is `True`, `0` if it is `False` and -1 if it is `Unknown`. ```yaml ... k8s_cluster: node_conditions_to_report: - Ready - MemoryPressure ... ``` ### metadata_exporters A list of metadata exporters to which metadata being collected by this receiver should be synced. Exporters specified in this list are expected to implement the following interface. If an exporter that does not implement the interface is listed, startup will fail. ```yaml type MetadataExporter interface { ConsumeMetadata(metadata []*MetadataUpdate) error } type MetadataUpdate struct { ResourceIDKey string ResourceID ResourceID MetadataDelta } type MetadataDelta struct { MetadataToAdd map[string]string MetadataToRemove map[string]string MetadataToUpdate map[string]string } ``` See [here](collection/metadata.go) for details about the above types. ## Example Here is an example deployment of the collector that sets up this receiver along with the [SignalFx Exporter](../../exporter/signalfxexporter/README.md). Follow the below sections to setup various Kubernetes resources required for the deployment. ### Configuration Create a ConfigMap with the config for `otelcontribcol`. Replace `SIGNALFX_TOKEN` and `SIGNALFX_REALM` with valid values. ```bash cat < realm: service: pipelines: metrics: receivers: [k8s_cluster] exporters: [signalfx] EOF ``` ### Service Account Create a service account that the collector should use. ```bash <