Skip to content

Commit

Permalink
Adding page for advance agent configuration with k8s (#802)
Browse files Browse the repository at this point in the history
* adding page for adavnce agent with k8s

* adding kubernetes provider example

* fxing typos and indentation

* fxing typos and indentation

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: David Kilfoyle <[email protected]>

* udpating code yaml box and adding parameter of manifest

* updating number in list

* updating number in list and iamge for kibana UI

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

* Update docs/en/ingest-management/elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc

Co-authored-by: Tetiana Kravchenko <[email protected]>

* adding comment for state

* fixing list

---------

Co-authored-by: David Kilfoyle <[email protected]>
Co-authored-by: Tetiana Kravchenko <[email protected]>
  • Loading branch information
3 people authored Jan 22, 2024
1 parent 64bad76 commit b74ef01
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[[advanced-kubernetes-managed-by-fleet]]
= 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:

[discrete]
== 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

image::images/k8skibanaUI.png[{agent} with K8s Package manifest]

Notes::
Sample manifests can also be found https://github.com/elastic/elastic-agent/blob/main/deploy/kubernetes/elastic-agent-managed-kubernetes.yaml[here]

[discrete]
== Step 2: Create a new configmap

[source,yaml]
.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.
[source,yaml]
.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 https://www.elastic.co/guide/en/fleet/current/fleet-enrollment-tokens.html[Enrollment Tokens].

[discrete]
== Step 3: Configure Daemonset

Inside the downloaded manifest, update the Daemonset resource:

[source,yaml]
.Update entrypoint
------------------------------------------------
containers:
- name: elastic-agent
image: docker.elastic.co/beats/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/beats/elastic-agent: 8.11.0`
Important thing is to update your manifest with args details

[source,yaml]
.Add extra Volume Mount
------------------------------------------------
volumeMounts:
- name: datastreams
mountPath: /etc/elastic-agent/agent.yml
readOnly: true
subPath: agent.yml
------------------------------------------------

[source,yaml]
.Add new Volume
------------------------------------------------
volumes:
- name: datastreams
configMap:
defaultMode: 0640
name: agent-node-datastreams
------------------------------------------------

[discrete]
== 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 https://github.com/elastic/elastic-agent/tree/main/docs/manifests/hostnetwork[example] as described in https://github.com/elastic/elastic-agent/blob/main/docs/elastic-agent-ksm-sharding.md[{agent} Manifests in order to support Kube-State-Metrics Sharding].

2. The volume `/usr/share/elastic-agent/state` must remain mounted in https://github.com/elastic/elastic-agent/blob/main/deploy/kubernetes/elastic-agent-managed-kubernetes.yaml[elastic-agent-managed-kubernetes.yaml], otherwise custom config map provided above will be overwritten.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To learn how to run {agent}s in a containerized environment, see:

* <<running-on-kubernetes-managed-by-fleet>>

** <<advanced-kubernetes-managed-by-fleet>>

** <<running-on-gke-managed-by-fleet>>

** <<running-on-eks-managed-by-fleet>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Refer to:
--
* <<elastic-agent-container>>
* <<running-on-kubernetes-managed-by-fleet>>
** <<advanced-kubernetes-managed-by-fleet>>
** <<running-on-gke-managed-by-fleet>>
** <<running-on-eks-managed-by-fleet>>
** <<running-on-aks-managed-by-fleet>>
Expand Down
Binary file added docs/en/ingest-management/images/k8skibanaUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/en/ingest-management/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ include::elastic-agent/elastic-agent-container.asciidoc[leveloffset=+3]

include::elastic-agent/running-on-kubernetes-managed-by-fleet.asciidoc[leveloffset=+3]

include::elastic-agent/advanced-kubernetes-managed-by-fleet.asciidoc[leveloffset=+3]

include::elastic-agent/running-on-gke-managed-by-fleet.asciidoc[leveloffset=+3]

include::elastic-agent/running-on-eks-managed-by-fleet.asciidoc[leveloffset=+3]
Expand Down

0 comments on commit b74ef01

Please sign in to comment.