Skip to content

Commit d79d337

Browse files
vishaangelovaeedugonbenironside
authored
Update the quickstart guide for using Elastic Agent in a Kubernetes cluster (#2433)
This PR updates the [Quickstart: Monitor your Kubernetes cluster with Elastic Agent](https://www.elastic.co/docs/solutions/observability/get-started/quickstart-monitor-kubernetes-cluster-with-elastic-agent) guide with the following changes: - Updates the Prerequisites section - Updates the Serverless use case to use `helm`, and adds information about the `helm` command - Removes references to `kubectl` from the introduction as this command is no longer used for the Serverless use case - Adds new sections: - Uninstall Elastic Agent from the Kubernetes cluster - Troubleshooting - Limitation (a disclaimer for air-gapped environments that provides resources for running Elastic Agent in an air-gapped environment) Closes elastic/docs-content-internal#147 ### Preview https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/2433/solutions/observability/get-started/quickstart-monitor-kubernetes-cluster-with-elastic-agent --------- Co-authored-by: Edu González de la Herrán <[email protected]> Co-authored-by: Benjamin Ironside Goldstein <[email protected]>
1 parent 7ab1036 commit d79d337

File tree

1 file changed

+108
-41
lines changed

1 file changed

+108
-41
lines changed

solutions/observability/get-started/quickstart-monitor-kubernetes-cluster-with-elastic-agent.md

Lines changed: 108 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,88 +13,112 @@ products:
1313

1414
# Quickstart: Monitor your Kubernetes cluster with {{agent}} [monitor-k8s-logs-metrics-with-elastic-agent]
1515

16-
In this quickstart guide, you’ll learn how to create the Kubernetes resources that are required to monitor your cluster infrastructure.
17-
18-
This new approach requires minimal configuration and provides you with an easy setup to monitor your infrastructure. You no longer need to download, install, or configure the Elastic Agent, everything happens automatically when you run the kubectl command.
19-
20-
The kubectl command installs the standalone Elastic Agent in your Kubernetes cluster, downloads all the Kubernetes resources needed to collect metrics from the cluster, and sends it to Elastic.
16+
In this quickstart guide, you’ll learn how to create the Kubernetes resources required to monitor your cluster infrastructure by using a single command to download, install, and configure {{agent}} in your Kubernetes cluster.
2117

2218
## Prerequisites [_prerequisites_2]
2319

24-
::::{tab-set}
20+
:::::{tab-set}
2521
:group: stack-serverless
2622

27-
:::{tab-item} Elastic Stack
23+
::::{tab-item} {{stack}}
2824
:sync: stack
2925

30-
* An {{es}} cluster for storing and searching your data, and {{kib}} for visualizing and managing your data. This quickstart is available for all Elastic deployment models. To get started quickly, try out [{{ecloud}}](https://cloud.elastic.co/registration?page=docs&placement=docs-body).
26+
* A running {{stack}} deployment, either self-managed or orchestrated by platforms like {{ech}}, {{ece}}, or {{eck}}, with internet access. To get started quickly, try out [{{ecloud}}](https://cloud.elastic.co/registration?page=docs&placement=docs-body).
3127
* A user with the `superuser` [built-in role](/deploy-manage/users-roles/cluster-or-deployment-auth/built-in-roles.md) or the privileges required to onboard data.
3228

33-
::::{dropdown} Expand to view required privileges
34-
* [**Cluster**](/deploy-manage/users-roles/cluster-or-deployment-auth/elasticsearch-privileges.md#privileges-list-cluster): `['monitor', 'manage_own_api_key']`
35-
* [**Index**](/deploy-manage/users-roles/cluster-or-deployment-auth/elasticsearch-privileges.md#privileges-list-indices): `{ names: ['logs-*-*', 'metrics-*-*'], privileges: ['auto_configure', 'create_doc'] }`
36-
* [**Kibana**](/deploy-manage/users-roles/cluster-or-deployment-auth/kibana-privileges.md): `{ spaces: ['*'], feature: { fleet: ['all'], fleetv2: ['all'] } }`
37-
38-
::::
39-
40-
* A running Kubernetes cluster.
41-
* [Kubectl](https://kubernetes.io/docs/reference/kubectl/).
42-
29+
:::{dropdown} Expand to view required privileges
30+
* [**Cluster**](/deploy-manage/users-roles/cluster-or-deployment-auth/elasticsearch-privileges.md#privileges-list-cluster): `['monitor', 'manage_own_api_key']`
31+
* [**Index**](/deploy-manage/users-roles/cluster-or-deployment-auth/elasticsearch-privileges.md#privileges-list-indices): `{ names: ['logs-*-*', 'metrics-*-*'], privileges: ['auto_configure', 'create_doc'] }`
32+
* [**Kibana**](/deploy-manage/users-roles/cluster-or-deployment-auth/kibana-privileges.md): `{ spaces: ['*'], feature: { fleet: ['all'], fleetv2: ['all'] } }`
4333
:::
4434

45-
:::{tab-item} Serverless
35+
* A running Kubernetes cluster with internet access
36+
* [Kubectl](https://kubernetes.io/docs/reference/kubectl/)
37+
::::
38+
39+
::::{tab-item} Serverless
4640
:sync: serverless
4741

4842
* An {{obs-serverless}} project. To learn more, refer to [Create an Observability project](/solutions/observability/get-started.md).
49-
* A user with the **Admin** role or higher—required to onboard system logs and metrics. To learn more, refer to [Assign user roles and privileges](/deploy-manage/users-roles/cloud-organization/user-roles.md#general-assign-user-roles).
50-
* A running Kubernetes cluster.
51-
* [Kubectl](https://kubernetes.io/docs/reference/kubectl/).
43+
* A user with the **Admin** role or higher (required to onboard system logs and metrics). To learn more, refer to [Assign user roles and privileges](/deploy-manage/users-roles/cloud-organization/user-roles.md#general-assign-user-roles).
44+
* A running Kubernetes cluster with internet access
45+
* [Helm](https://helm.sh/docs/)
46+
::::
5247

53-
:::
48+
:::::
5449

55-
::::
50+
## Limitations [monitor-k8s-with-agent-limitations]
5651

52+
The installation command provided by the UI during the quickstart cannot be used as-is to install {{agent}} in an air-gapped environment. For an air-gapped environment with a self-managed {{stack}} deployment or orchestrator such as [{{eck}}](/deploy-manage/deploy/cloud-on-k8s.md), refer to the following resources:
53+
54+
- [Install Elastic Agent air-gapped](/deploy-manage/deploy/self-managed/air-gapped-install.md#air-gapped-elastic-agent)
55+
- [Install Elastic Agent on Kubernetes using Helm](/reference/fleet/install-on-kubernetes-using-helm.md)
56+
- [Deploy Elastic Agent in standalone mode with ECK](/deploy-manage/deploy/cloud-on-k8s/standalone-elastic-agent.md)
57+
- [Run Elastic Agent in an air-gapped environment](/reference/fleet/air-gapped.md)
5758

5859
## Collect your data [_collect_your_data_2]
5960

60-
::::{tab-set}
61+
:::::{tab-set}
6162
:group: stack-serverless
6263

63-
:::{tab-item} Elastic Stack
64+
::::{tab-item} Elastic Stack
6465
:sync: stack
6566

6667
1. In {{kib}}, go to the **Observability** UI and click **Add Data**.
67-
2. Under **What do you want to monitor?** select **Kubernetes**, and then select **Elastic Agent: Logs & Metrics**.
68+
2. In the **What do you want to monitor?** section, select **Kubernetes**, and then select **Elastic Agent: Logs & Metrics**.
6869

69-
3. To install the Elastic Agent on your host, copy and run the install command.
70+
3. To install {{agent}} on your host, copy and run the install command.
7071

71-
You will use the kubectl command to download a manifest file, inject user’s API key generated by {{kib}}, and create the Kubernetes resources.
72+
By running this command, you use `kubectl kustomize` to download a manifest file, inject deployment-specific data such as the API key generated by {{kib}} for the acting user, and create the Kubernetes resources for {{agent}}.
7273

73-
4. Go back to the **Add Observability Data** page.
74+
4. Go back to the **Kubernetes: Logs & Metrics** page in {{kib}}.
7475

7576
There might be a slight delay before data is ingested. When ready, you will see the message **We are monitoring your cluster**.
7677

7778
5. Click **Explore Kubernetes cluster** to navigate to dashboards and explore your data.
7879

79-
:::
80+
::::
8081

81-
:::{tab-item} Serverless
82+
::::{tab-item} Serverless
8283
:sync: serverless
8384

84-
1. [Create a new {{obs-serverless}} project](/solutions/observability/get-started.md), or open an existing one.
85-
2. In your {{obs-serverless}} project, go to **Add Data**.
86-
3. Under **What do you want to monitor?** select **Kubernetes**, and then select **Elastic Agent: Logs & Metrics**.
87-
4. To install the Elastic Agent on your host, copy and run the install command.
85+
1. Go to your [{{obs-serverless}}](/solutions/observability/get-started.md) project, then go to **Add Data**.
86+
2. In the **What do you want to monitor?** section, select **Kubernetes**, and then select **Elastic Agent: Logs & Metrics**.
87+
3. To install {{agent}} on your host, copy and run the install command.
8888

89-
You will use the kubectl command to download a manifest file, inject user’s API key generated by Kibana, and create the Kubernetes resources.
89+
By running this command, you use the Helm package manager to install and configure an instance of the {{agent}} Helm chart with additional deployment-specific data such as the API key generated by {{kib}} for the acting user.
90+
91+
The Helm chart also includes a default installation of [`kube-state-metrics` (KSM)](https://github.com/kubernetes/kube-state-metrics), which is required by the Kubernetes integration to collect cluster-level metrics.
9092

91-
5. Go back to the **Add Observability Data** page. There might be a slight delay before data is ingested. When ready, you will see the message **We are monitoring your cluster**.
92-
6. Click **Explore Kubernetes cluster** to navigate to dashboards and explore your data.
93+
If you encounter an error during the installation, refer to [Troubleshooting](#monitor-k8s-with-agent-troubleshooting).
9394

94-
:::
95+
:::{dropdown} Details about the install command
96+
The install command provided by the UI may be similar to:
97+
98+
```sh subs=true
99+
helm repo add elastic https://helm.elastic.co/ && helm install elastic-agent elastic/elastic-agent --version {{version.stack}} -n kube-system --set outputs.default.url=https:<elasticsearch-url>:443 --set kubernetes.onboardingID=<internal-id> --set kubernetes.enabled=true --set outputs.default.type=ESPlainAuthAPI --set outputs.default.api_key=$(echo "<api-key>" | base64 -d)
100+
```
101+
102+
Where:
103+
104+
- `elastic-agent` is the name of the specific installation of the Helm chart, known as **release name**.
105+
- `elastic/elastic-agent` defines the name of the chart to install, using the format `<repository>/<chart-name>`.
106+
- {{version.stack}} is the version of the {{agent}} Helm chart to be installed.
107+
- `kube-system` is the namespace where {{agent}} is to be installed.
108+
- `--set` parameters add configuration values specific to the serverless project, the acting user, and the deployment method of the Helm chart.
109+
110+
Refer to [Install standalone Elastic Agent on Kubernetes using Helm](/reference/fleet/example-kubernetes-standalone-agent-helm.md#agent-standalone-helm-example-install) for a more detailed explanation of the configuration options used.
111+
:::
112+
113+
4. Go back to the **Kubernetes: Logs & Metrics** page in {{kib}}.
114+
115+
There might be a slight delay before data is ingested. When ready, you will see the message **We are monitoring your cluster**.
116+
117+
5. Click **Explore Kubernetes cluster** to navigate to dashboards and explore your data.
95118

96119
::::
97120

121+
:::::
98122

99123
## Visualize your data [_visualize_your_data_2]
100124

@@ -107,4 +131,47 @@ After installation is complete and all relevant data is flowing into Elastic, th
107131

108132
Furthermore, you can access other useful prebuilt dashboards for monitoring Kubernetes resources, for example running pods per namespace, as well as the resources they consume, like CPU and memory.
109133

110-
Refer to [Observability overview](/solutions/observability/get-started/what-is-elastic-observability.md) for a description of other useful features.
134+
Refer to [Observability overview](/solutions/observability/get-started/what-is-elastic-observability.md) for a description of other useful features.
135+
136+
## Uninstall {{agent}} from the Kubernetes cluster [monitor-k8s-with-agent-delete-agent]
137+
138+
::::{tab-set}
139+
:group: stack-serverless
140+
141+
:::{tab-item} Elastic Stack
142+
:sync: stack
143+
144+
To uninstall {{agent}} and the Kubernetes resources installed with `kubectl`:
145+
146+
1. Copy the `kubectl` quickstart command for installing {{agent}} described in the [Collect your data](#_collect_your_data_2) section.
147+
2. Replace `| kubectl apply -f-` with `| kubectl delete -f-`, then run the command.
148+
:::
149+
150+
:::{tab-item} Serverless
151+
:sync: serverless
152+
153+
To uninstall {{agent}} and the Kubernetes resources installed with Helm, run:
154+
155+
```sh
156+
helm uninstall <release-name> -n <namespace> <1>
157+
```
158+
1. Substitute `<release-name>` with the release name and `<namespace>` with the namespace used in the quickstart command described in the [Collect your data](#_collect_your_data_2) section.
159+
160+
If you used the default values from the quickstart, the command would be:
161+
162+
```sh
163+
helm uninstall elastic-agent -n kube-system
164+
```
165+
:::
166+
167+
::::
168+
169+
## Troubleshooting [monitor-k8s-with-agent-troubleshooting]
170+
171+
### `kube-state-metrics` is already installed
172+
173+
If you're using `helm` to install {{agent}} in your Kubernetes cluster, you may encounter an error if `kube-state-metrics` is already installed in the same namespace where {{agent}} is to be installed. In this case, add the option `--set kube-state-metrics.enabled=false` to the install command provided by the UI to skip the installation of `kube-state-metrics`.
174+
175+
### The `elastic` repository already exists
176+
177+
If you're using `helm` to install {{agent}} in your Kubernetes cluster and the `elastic` repository is already configured on your host, replace the `helm repo add elastic https://helm.elastic.co/ ` part of the command provided by the UI with `helm repo update elastic` to ensure the repository is updated with the latest package information.

0 commit comments

Comments
 (0)