- Fleet and Elastic Agent Guide: other versions:
- Fleet and Elastic Agent overview
- Beats and Elastic Agent capabilities
- Quick start: Get logs, metrics, and uptime data into the Elastic Stack
- Quick start: Get application traces into the Elastic Stack
- Integrations
- Elastic Agents
- Install Elastic Agents
- Uninstall Elastic Agent
- Run Elastic Agent standalone (advanced users)
- Run Elastic Agent in a container
- Run Elastic Agent on Kubernetes managed by Fleet
- Run Elastic Agent standalone on Kubernetes
- Upgrade Elastic Agent
- Start Elastic Agent
- Stop Elastic Agent
- Unenroll Elastic Agent
- View status of Elastic Agents
- Variables and conditions in input configurations
- Environment variables
- Configure logging for Fleet-managed Elastic Agents
- Policies
- Elastic Agent standalone configuration
- Fleet UI settings
- Fleet Server
- Fleet enrollment tokens
- Encrypt traffic in clusters with a self-managed Fleet Server
- Data streams
- Command reference
- Troubleshoot common problems
- Frequently asked questions
- Release notes
- Fleet APIs
Run Elastic Agent on Kubernetes managed by Fleet
editRun Elastic Agent on Kubernetes managed by Fleet
editUse Elastic Agent Docker images on Kubernetes to retrieve cluster metrics.
Kubernetes deploy manifests
editWith Fleet, each agent enrolls in a policy defined in Kibana and stored in Elasticsearch. The policy specifies how to collect observability data from the services to be monitored. The Elastic 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 Elastic Agent as a 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 leader election provider. This instance is used to retrieve metrics that are unique for the whole cluster, such as Kubernetes events or 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:
curl -L -O https://raw.githubusercontent.com/elastic/beats/7.15/deploy/kubernetes/elastic-agent-managed-kubernetes.yaml
Settings
editElastic Agent is enrolled to a running Fleet Server using FLEET_URL
parameter.
The FLEET_ENROLLMENT_TOKEN
parameter is used to connect Elastic Agent to a
specific Elastic Agent policy.
Learn more on how to get an enrollment token from Fleet in the Quick start
guide.
If FLEET_ENROLLMENT_TOKEN
is empty then agent will connect to Kibana 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:
- 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: ""
Configuration details
Run Elastic Agent on master nodes
editKubernetes master nodes can use taints to limit the workloads that can run on them. The manifest for managed Elastic 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 Elastic Agent from running on master nodes, remove the following part of the Daemonset spec:
spec: tolerations: - key: node-role.kubernetes.io/master effect: NoSchedule
Deploy
editIf planning to deploy state_*
datasets of Kubernetes package,
kube-state-metrics needs to be already deployed
in the cluster. If kube-state-metrics
is not already running, deploy it now (see the
Kubernetes
deployment docs).
To deploy Elastic Agent on Kubernetes, run:
kubectl create -f elastic-agent-managed-kubernetes.yaml
To check the status, run:
$ 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
Elastic Agents should be enrolled to Fleet and users should be able to deploy the Kubernetes package accordingly. This can be confirmed in Kibana under Fleet / Agents section.