Skip to content

Commit

Permalink
fixing duplicate annotation and SME feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciascott committed Oct 17, 2024
1 parent 7ec977e commit 785da85
Showing 1 changed file with 27 additions and 41 deletions.
68 changes: 27 additions & 41 deletions kube_apiserver_metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ The Kube_apiserver_metrics check is included in the [Datadog Agent][3] package,

### Configuration

If your Kubernetes clusters have master nodes and is running a pod and container for the `kube-apiserver` image, the Datadog Agent [automatically discovers][8] this pod and configures the integration relative to its `kube_apiserver_metrics.d/auto_conf.yaml` file.

However, if you are using a managed Kubernetes distribution like GKE, EKS, or AKS you may not have a running `kube-apiserver` pod present for the Agent to discover.

In this case, you can setup the integration against the Kubernetes Service in the `default` namespace.

- The main use case to run the kube_apiserver_metrics check is as a [Cluster Level Check][4].
- To collect metrics, set the following parameters and values in an [Autodiscovery][12] template.
- You can do this with [annotations on your service](#annotate-service), or by using a [local file](#local-file) through the Datadog Operator, Helm Chart or manually.
- To collect metrics, set the following parameters and values in an [Autodiscovery][8] template.

| Parameter | Value |
|-------------------|-----------------------------------------------------------------------|
Expand All @@ -27,19 +33,23 @@ The Kube_apiserver_metrics check is included in the [Datadog Agent][3] package,
You can review all available configuration options in the [kube_apiserver_metrics.yaml][7].

#### Annotate service
You can annotate the service of your apiserver with the following:

You can annotate the kubernetes service in your `default` namespace with the following:

{{< tabs >}}
{{% tab "Annotations v2 (for Datadog Agent v7.36+)" %}}

```yaml
ad.datadoghq.com/service.checks: |
ad.datadoghq.com/endpoints.checks: |
{
"["kube_apiserver_metrics"]": {
"init_config": [{}],
"instances": [{ "prometheus_url": "https://%%host%%:%%port%%/metrics", "bearer_token_auth": "true" }]
"kube_apiserver_metrics": {
"instances": [
{
"prometheus_url": "https://%%host%%:%%port%%/metrics"
}
]
}
}
}
```
{{% /tab %}}
Expand All @@ -50,7 +60,7 @@ annotations:
ad.datadoghq.com/endpoints.check_names: '["kube_apiserver_metrics"]'
ad.datadoghq.com/endpoints.init_configs: '[{}]'
ad.datadoghq.com/endpoints.instances:
'[{ "prometheus_url": "https://%%host%%:%%port%%/metrics", "bearer_token_auth": "true" }]'
'[{ "prometheus_url": "https://%%host%%:%%port%%/metrics"}]'
```
{{% /tab %}}
{{< /tabs >}}
Expand All @@ -59,54 +69,29 @@ Then the Datadog Cluster Agent schedules the check(s) for each endpoint onto Dat

#### Local file

You can also run the check by configuring the endpoints directly in the `kube_apiserver_metrics.d/conf.yaml` file, in the `conf.d/` folder at the root of your [Agent's configuration directory][5].

**Note**: You must add `cluster_check: true` to your configuration file, if using a local file or ConfigMap to configure Cluster Checks.

By default the Agent running the check tries to get the service account bearer token to authenticate against the APIServer. If you are not using RBACs, set `bearer_token_auth` to `false`.

If your Kubernetes clusters have master nodes and is running a pod and container for the `kube-apiserver` image, the Datadog Agent [automatically discovers][8] this pod and configures the integration relative to its `kube_apiserver_metrics.d/auto_conf.yaml` file.

However, if you are using a managed Kubernetes distribution like GKE, EKS, or AKS you may not have a running `kube-apiserver` pod present for the Agent to discover. In this case, you can setup the integration against the Kubernetes service in the `default` namespace.
You can also run the check by configuring the endpoints directly in the `kube_apiserver_metrics.d/conf.yaml` file, in the `conf.d/` folder at the root of your [Agent's configuration directory][5] to dispatch as a [Cluster Check][14].

To do this you can add annotations to this Service:
**Note**: You must add `cluster_check: true` to your configuration file if using a local file or ConfigMap to configure Cluster Checks.

```yaml
ad.datadoghq.com/service.checks: |
{
"kube_apiserver_metrics": {
"instances": [
{
"prometheus_url": "https://%%host%%:%%port%%/metrics",
"bearer_token_auth": "true"
}
]
}
}
```
Or, provide a [configuration][13] to your Cluster Agent to setup a Cluster Check:
Provide a [configuration][13] to your Cluster Agent to setup a Cluster Check:

{{< tabs >}}
{{< tabs >}}
{{% tab "Helm" %}}
```yaml
clusterAgent:
confd:
kube_apiserver_metrics.yaml: |-
advanced_ad_identifiers:
- kube_service:
- kube_endpoins:
name: "kubernetes"
namespace: "default"
cluster_check: true
init_config:
instances:
- prometheus_url: "https://%%host%%:%%port%%/metrics"
bearer_token_auth: "true"
```
{{% /tab %}}
{{% tab "Operator" %}}
```yaml
Expand All @@ -118,19 +103,19 @@ spec:
configDataMap:
kube_apiserver_metrics.yaml: |-
advanced_ad_identifiers:
- kube_service:
- kube_endpoints:
name: "kubernetes"
namespace: "default"
cluster_check: true
init_config:
instances:
- prometheus_url: "https://%%host%%:%%port%%/metrics"
bearer_token_auth: "true"
```
{{% /tab %}}
{{< /tabs >}}
These configurations will have the Agent make a request to the kubernetes service in the default namespace at its Cluster IP Address and defined port.
### Validation
[Run the Agent's status subcommand][9] and look for `kube_apiserver_metrics` under the Checks section.
Expand Down Expand Up @@ -166,3 +151,4 @@ Need help? Contact [Datadog support][11].
[11]: https://docs.datadoghq.com/help/
[12]: https://docs.datadoghq.com/containers/kubernetes/integrations/?tab=annotations
[13]: https://docs.datadoghq.com/containers/cluster_agent/clusterchecks/?tab=helm#configuration-from-configuration-files
[14]: https://containers/cluster_agent/clusterchecks/?tab=datadogoperator#setting-up-check-configurations

0 comments on commit 785da85

Please sign in to comment.