Skip to content

Latest commit

 

History

History
110 lines (89 loc) · 4.05 KB

advanced-kubernetes-managed-by-fleet.asciidoc

File metadata and controls

110 lines (89 loc) · 4.05 KB

Advanced {agent} configuration managed by {fleet}

For basic {agent} managed by {fleet} scenarios follow the steps in [running-on-kubernetes-managed-by-fleet].

On managed {agent} installations it can be useful to provide the ability to configure more advanced options, such as the configuration of providers during the startup. Refer to [providers] for more details.

Following steps demonstrate above scenario:

Step 1: Download the {agent} manifest

It is advisable to follow the steps of [install-fleet-managed-elastic-agent] with Kubernetes Integration installed in your policy and download the {agent} manifest from Kibana UI

{agent} with K8s Package manifest
Notes

Sample manifests can also be found here

Step 2: Create a new configmap

Create a new configmap
apiVersion: v1
kind: ConfigMap
metadata:
  name: agent-node-datastreams
  namespace: kube-system
  labels:
    k8s-app: elastic-agent
data:
  agent.yml: |-
    providers.kubernetes_leaderelection.enabled: false
    fleet.enabled: true
    fleet.access_token: "<FLEET_ENROLLMENT_TOKEN>"
---
Notes
  1. In the above example the disablement of kubernetes_leaderelection provider is demonstrated. Same procedure can be followed for alternative scenarios.

Example of configmap to configure kubernetes metadata enrichment
apiVersion: v1
kind: ConfigMap
metadata:
  name: agent-node-datastreams
  namespace: kube-system
  labels:
    k8s-app: elastic-agent
data:
  agent.yml: |-
    providers.kubernetes:
      add_resource_metadata:
        deployment: true
        cronjob: true
    fleet.enabled: true
    fleet.access_token: "<FLEET_ENROLLMENT_TOKEN>"
---
  1. Find more information about Enrollment Tokens.

Step 3: Configure Daemonset

Inside the downloaded manifest, update the Daemonset resource:

Update entrypoint
containers:
  - name: elastic-agent
    image: docker.elastic.co/elastic-agent/elastic-agent: <ImageVersion>
    args: ["-c", "/etc/elastic-agent/agent.yml", "-e"]
Notes

The <ImageVersion> is just a placeholder for the elastic-agent image version that you will download in your manifest: eg. image: docker.elastic.co/elastic-agent/elastic-agent: 8.11.0 Important thing is to update your manifest with args details

Add extra Volume Mount
volumeMounts:
  - name: datastreams
    mountPath: /etc/elastic-agent/agent.yml
    readOnly: true
    subPath: agent.yml
Add new Volume
volumes:
  - name: datastreams
    configMap:
      defaultMode: 0640
      name: agent-node-datastreams

Important Notes

  1. By default the manifests for {agent} managed by {fleet} have hostNetwork:true. In order to support multiple installations of {agent}s in the same node you should set hostNetwork:false. See this relevant example as described in {agent} Manifests in order to support Kube-State-Metrics Sharding.

  2. The volume /usr/share/elastic-agent/state must remain mounted in elastic-agent-managed-kubernetes.yaml, otherwise custom config map provided above will be overwritten.