From 9fa8d3c1906c712017acef550d21826f5bf08b22 Mon Sep 17 00:00:00 2001 From: Brandon Morelli Date: Wed, 14 Jul 2021 15:51:39 -0700 Subject: [PATCH] Update docs for agent managed by fleet on kubernetes (#848) (#867) Co-authored-by: Michael Katsoulis --- .../elastic-agent/elastic-agent.asciidoc | 4 +- ...ng-on-kubernetes-managed-by-fleet.asciidoc | 152 ++++++++++++++++++ .../running-on-kubernetes-standalone.asciidoc | 16 +- .../running-on-kubernetes.asciidoc | 133 --------------- 4 files changed, 162 insertions(+), 143 deletions(-) create mode 100644 docs/en/ingest-management/elastic-agent/running-on-kubernetes-managed-by-fleet.asciidoc delete mode 100644 docs/en/ingest-management/elastic-agent/running-on-kubernetes.asciidoc diff --git a/docs/en/ingest-management/elastic-agent/elastic-agent.asciidoc b/docs/en/ingest-management/elastic-agent/elastic-agent.asciidoc index 78620fa58a..fa9480585c 100644 --- a/docs/en/ingest-management/elastic-agent/elastic-agent.asciidoc +++ b/docs/en/ingest-management/elastic-agent/elastic-agent.asciidoc @@ -16,7 +16,7 @@ To learn how to install, configure, and run your {agent}s, see: * <> * <> * <> -//* <> +* <> * <> * <> * <> @@ -33,7 +33,7 @@ include::uninstall-elastic-agent.asciidoc[leveloffset=+1] include::run-elastic-agent-standalone.asciidoc[leveloffset=+1] -//include::running-on-kubernetes.asciidoc[leveloffset=+1] +include::running-on-kubernetes-managed-by-fleet.asciidoc[leveloffset=+1] include::running-on-kubernetes-standalone.asciidoc[leveloffset=+1] diff --git a/docs/en/ingest-management/elastic-agent/running-on-kubernetes-managed-by-fleet.asciidoc b/docs/en/ingest-management/elastic-agent/running-on-kubernetes-managed-by-fleet.asciidoc new file mode 100644 index 0000000000..868e492d7f --- /dev/null +++ b/docs/en/ingest-management/elastic-agent/running-on-kubernetes-managed-by-fleet.asciidoc @@ -0,0 +1,152 @@ +[[running-on-kubernetes-managed-by-fleet]] +[role="xpack"] += Run {agent} on Kubernetes managed by {fleet} + +Use {agent} https://www.docker.elastic.co/r/beats/elastic-agent[Docker images] on Kubernetes to +retrieve cluster metrics. + +ifeval::["{release-state}"=="unreleased"] + +However, version {version} of {agent} has not yet been +released, so no Docker image is currently available for this version. + +endif::[] + + +[discrete] +== Kubernetes deploy manifests + +With {fleet}, each agent enrolls in a policy defined in {kib} and stored in +{es}. The policy specifies how to collect observability data from the services +to be monitored. The {agent} connects to a trusted {fleet-server} instance +to retrieve the policy and report agent events. + +We recommend using {fleet} management because it makes the management and +upgrade of agents considerably easier. + +On Kubernetes, deploy {agent} as a https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/[DaemonSet] +to ensure that there is a running instance on each node of the cluster. +These instances are used to retrieve metrics from the host, such as system metrics, container stats, +and metrics from all the services running on top of Kubernetes. + +In addition, one of the Pods in the DaemonSet will constantly hold a _leader lock_ which makes it responsible for +handling cluster-wide monitoring. +Find more information about leader election configuration options at <>. +This instance is used to retrieve metrics that are unique for the whole +cluster, such as Kubernetes events or +https://github.com/kubernetes/kube-state-metrics[kube-state-metrics]. + + +Everything is deployed under the `kube-system` namespace by default. To change +the namespace, modify the manifest file. + +To download the manifest file, run: + +["source", "sh", subs="attributes"] +------------------------------------------------ +curl -L -O https://raw.githubusercontent.com/elastic/beats/{branch}/deploy/kubernetes/elastic-agent-managed-kubernetes.yaml +------------------------------------------------ + +[discrete] +== Settings + +{agent} is enrolled to a running {fleet-server} using `FLEET_URL` parameter. +The `FLEET_ENROLLMENT_TOKEN` parameter is used to connect {agent} to a +specific {agent} policy. +Learn more on how to get an enrollment token from {fleet} in the {fleet-guide}/fleet-quick-start.html[Quick start +guide]. + +If `FLEET_ENROLLMENT_TOKEN` is empty then agent will connect to {kib} and get the default policy. +In that case `KIBANA_HOST`, `KIBANA_FLEET_USERNAME`, `KIBANA_FLEET_PASSWORD` have to be specified. + +To specify different destination/credentials, +change the following parameters in the manifest file: + +[source,yaml] +------------------------------------------------ +- name: FLEET_URL + value: "https://fleet-server_url:port" +- name: FLEET_ENROLLMENT_TOKEN + value: "token" +- name: KIBANA_HOST + value: "" +- name: KIBANA_FLEET_USERNAME + value: "" +- name: KIBANA_FLEET_PASSWORD + value: "" +------------------------------------------------ + +// Begin collapsed section +[%collapsible] +.Configuration details +==== +**** + +[cols="2*> for all available options. + +**** +==== + +[discrete] +=== Run {agent} on master nodes + +Kubernetes master nodes can use https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/[taints] +to limit the workloads that can run on them. The manifest for managed {agent} defines +tolerations to run on master nodes. Agents running on master nodes collect metrics from the control plane +components (scheduler, controller manager) of Kubernetes. +To disable {agent} from running on master nodes, remove the following part of the Daemonset spec: + +[source,yaml] +------------------------------------------------ +spec: + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule +------------------------------------------------ + + +[discrete] +== Deploy + +If planning to deploy `state_*` datasets of Kubernetes package, +https://github.com/kubernetes/kube-state-metrics#usage[kube-state-metrics] needs to be already deployed +in the cluster. If `kube-state-metrics` is not already running, deploy it now (see the +https://github.com/kubernetes/kube-state-metrics#kubernetes-deployment[Kubernetes +deployment] docs). + +To deploy {agent} on Kubernetes, run: + +["source", "sh", subs="attributes"] +------------------------------------------------ +kubectl create -f elastic-agent-managed-kubernetes.yaml +------------------------------------------------ + +To check the status, run: + +["source", "sh", subs="attributes"] +------------------------------------------------ +$ kubectl get pod -n kube-system -l app=elastic-agent + +NAME READY STATUS RESTARTS AGE +elastic-agent-hrjbg 1/1 Running 0 12m +elastic-agent-olpsd 1/1 Running 0 12m +------------------------------------------------ + + +{agent}s should be enrolled to Fleet and users should be able to deploy the Kubernetes package accordingly. +This can be confirmed in {kib} under Fleet / Agents section. diff --git a/docs/en/ingest-management/elastic-agent/running-on-kubernetes-standalone.asciidoc b/docs/en/ingest-management/elastic-agent/running-on-kubernetes-standalone.asciidoc index 21c789a97e..8dcf630933 100644 --- a/docs/en/ingest-management/elastic-agent/running-on-kubernetes-standalone.asciidoc +++ b/docs/en/ingest-management/elastic-agent/running-on-kubernetes-standalone.asciidoc @@ -2,7 +2,7 @@ [role="xpack"] = Run {agent} standalone on Kubernetes -You can use {agent} https://www.docker.elastic.co/r/beats/elastic-agent[Docker images] on Kubernetes to +Use {agent} https://www.docker.elastic.co/r/beats/elastic-agent[Docker images] on Kubernetes to retrieve cluster metrics. TIP: Running {ecloud} on Kubernetes? See {eck-ref}/k8s-elastic-agent.html[Run {elastic-agent} on ECK]. @@ -17,15 +17,15 @@ endif::[] [discrete] == Kubernetes deploy manifests -Deploy {agent} in two different ways at the same time: - -* As a https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/[DaemonSet] -to ensure that there's a running instance on each node of the cluster. These +Deploy {agent} as a https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/[DaemonSet] +to ensure that there is a running instance on each node of the cluster. These instances are used to retrieve most metrics from the host, such as system metrics, Docker stats, and metrics from all the services running on top of Kubernetes. -* As a single {agent} instance created using a https://kubernetes.io/docs/concepts/workloads/controllers/Deployment/[Deployment]. +In addition, one of the Pods in the DaemonSet will constantly hold a _leader lock_ which makes it responsible for +handling cluster-wide monitoring. +Find more information about leader election configuration options at <>. This instance is used to retrieve metrics that are unique for the whole cluster, such as Kubernetes events or https://github.com/kubernetes/kube-state-metrics[kube-state-metrics]. If `kube-state-metrics` is not already @@ -33,7 +33,7 @@ running, deploy it now (see the https://github.com/kubernetes/kube-state-metrics#kubernetes-deployment[Kubernetes deployment] docs) -Everything is deployed under the `kube-system` namespace by default. Change the namespace by modifying the manifest file. +Everything is deployed under the `kube-system` namespace by default. Change the namespace by modifying the manifest file. To download the manifest file, run: @@ -126,7 +126,7 @@ elastic-agent-hs4pb 1/1 Running 0 81m [discrete] == Autodiscover targeted Pods -You can define autodiscover conditions to allow {agent} to automatically +Autodiscover conditions can be defined to allow {agent} to automatically identify Pods and start collecting from them using predefined integrations. For example, if a user wants to automatically identify a Redis Pod and start monitoring it using the Redis integration, the following configuration should be added as an extra input in the Daemonset manifest: diff --git a/docs/en/ingest-management/elastic-agent/running-on-kubernetes.asciidoc b/docs/en/ingest-management/elastic-agent/running-on-kubernetes.asciidoc deleted file mode 100644 index f3cd2e4267..0000000000 --- a/docs/en/ingest-management/elastic-agent/running-on-kubernetes.asciidoc +++ /dev/null @@ -1,133 +0,0 @@ -[[running-on-kubernetes]] -[role="xpack"] -= Run {agent} on Kubernetes - -You can use {agent} https://www.docker.elastic.co/r/beats/elastic-agent[Docker images] on Kubernetes to -retrieve cluster metrics. - -ifeval::["{release-state}"=="unreleased"] - -However, version {version} of {agent} has not yet been -released, so no Docker image is currently available for this version. - -endif::[] - - -[discrete] -== Kubernetes deploy manifests - -You deploy {agent} in two different ways at the same time: - -* As a https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/[DaemonSet] -to ensure that there's a running instance on each node of the cluster. These -instances are used to retrieve most metrics from the host, such as system -metrics, Docker stats, and metrics from all the services running on top of -Kubernetes. - -* As a single {agent} instance created using a https://kubernetes.io/docs/concepts/workloads/controllers/Deployment/[Deployment]. -This instance is used to retrieve metrics that are unique for the whole -cluster, such as Kubernetes events or -https://github.com/kubernetes/kube-state-metrics[kube-state-metrics]. - -Everything is deployed under the `kube-system` namespace by default. To change -the namespace, modify the manifest file. - -To download the manifest file, run: - -["source", "sh", subs="attributes"] ------------------------------------------------- -curl -L -O https://raw.githubusercontent.com/elastic/beats/{branch}/deploy/kubernetes/elastic-agent-kubernetes.yaml ------------------------------------------------- - -[discrete] -== Settings - -By default, {agent} is enrolled to an existing Kibana deployment, -if present using the specified credentials. The `FLEET_ENROLLMENT_TOKEN` parameter is used to connect Agent to the -corresponding {agent} policy. It is suggested to connect Daemonset Agents to a node scope configuration -and Deployment Agent to a cluster scope configuration. Then Kubernetes package will be deployed enabling cluster scope -datasets using cluster scope configuration while node scope datasets will be enabled under node scope configuration. - -To specify different destination/credentials, -change the following parameters in the manifest file: - -[source,yaml] ------------------------------------------------- -- name: FLEET_ENROLLMENT_TOKEN - value: "abcdf_token" -- name: KIBANA_HOST - value: "http://kibana:5601" -- name: KIBANA_USERNAME - value: "elastic" -- name: KIBANA_PASSWORD - value: "changeme" ------------------------------------------------- - -// Begin collapsed section -[%collapsible] -.Configuration details -==== -**** - -[cols="2*> for all available options. - -**** -==== - -[discrete] -=== Run {agent} on master nodes - -Kubernetes master nodes can use https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/[taints] -to limit the workloads that can run on them. To run {agent} on master nodes, you may need to -update the Daemonset spec to include proper tolerations: - -[source,yaml] ------------------------------------------------- -spec: - tolerations: - - key: node-role.kubernetes.io/master - effect: NoSchedule ------------------------------------------------- - - -[discrete] -== Deploy - -If planing to deploy `state_*` datasets of Kubernetes package, -https://github.com/kubernetes/kube-state-metrics#usage[kube-state-metrics] is needed to be already deployed -in the cluster. If `kube-state-metrics` is not already running, deploy it now (see the -https://github.com/kubernetes/kube-state-metrics#kubernetes-deployment[Kubernetes -deployment] docs). - -To deploy to Kubernetes, run: - -["source", "sh", subs="attributes"] ------------------------------------------------- -kubectl create -f elastic-agent-kubernetes.yaml ------------------------------------------------- - -To check the status, run: - -["source", "sh", subs="attributes"] ------------------------------------------------- -$ kubectl --namespace=kube-system get pods -l group=ingest-management - -NAME READY STATUS RESTARTS AGE -agent-ingest-management-clusterscope-574dbfc48f-sfrdt 1/1 Running 3 8d -agent-ingest-management-nodescope-jt9zj 1/1 Running 3 8d ------------------------------------------------- - -{agent}s should be enrolled to Fleet and user should be able to deploy Kubernetes package accordingly.