Skip to content

Commit 7aaf5bc

Browse files
[9.0](backport #7393) [Helm] Allow providing CA certificate of the Fleet Server when running the agent in fleet mode (#7492)
* [Helm] Allow providing CA certificate of the Fleet Server when running the agent in fleet mode (#7393) * feat: introduce support for defining fleet-related certificates * doc: add example with fleet-related certificates (cherry picked from commit 1595be9) # Conflicts: # deploy/helm/elastic-agent/examples/fleet-managed-ksm-sharding/rendered/manifest.yaml # deploy/helm/elastic-agent/examples/fleet-managed/rendered/manifest.yaml * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <[email protected]>
1 parent f35d82e commit 7aaf5bc

File tree

12 files changed

+1089
-78
lines changed

12 files changed

+1089
-78
lines changed

deploy/helm/elastic-agent/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,25 @@ The chart built-in [kubernetes integration](https://docs.elastic.co/integrations
157157
| agent.fleet.enabled | bool | `false` | enable elastic-agent managed |
158158
| agent.fleet.url | string | `""` | Fleet server URL |
159159
| agent.fleet.token | string | `""` | Fleet enrollment token |
160-
| agent.fleet.insecure | bool | `false` | Fleet insecure url |
160+
| agent.fleet.insecure | bool | `false` | Communicate with Fleet with either insecure HTTP or unverified HTTPS |
161+
| agent.fleet.force | bool | `false` | Enforce enrollment even if agent is already enrolled |
162+
| agent.fleet.ca.value | string | `""` | Value of the CA certificate for connecting to Fleet |
163+
| agent.fleet.ca.valueFromSecret.name | string | `""` | Secret name for the CA certificate |
164+
| agent.fleet.ca.valueFromSecret.key | string | `""` | Secret key for the CA certificate |
165+
| agent.fleet.agentCert.value | string | `""` | Value of Elastic Agent client certificate for Fleet Server mTLS |
166+
| agent.fleet.agentCert.valueFromSecret.name | string | `""` | Secret name for the Elastic Agent client certificate |
167+
| agent.fleet.agentCert.valueFromSecret.key | string | `""` | Key in the secret for the Elastic Agent client certificate |
168+
| agent.fleet.agentCertKey.value | string | `""` | Value of Elastic Agent client private key for Fleet Server mTLS |
169+
| agent.fleet.agentCertKey.valueFromSecret.name | string | `""` | Secret name for the Elastic Agent client private key |
170+
| agent.fleet.agentCertKey.valueFromSecret.key | string | `""` | Key in the secret for the Elastic Agent client private key |
171+
| agent.fleet.tokenName | string | `""` | Token name to use for fetching token from Kibana if the enrollment token is not supplied |
172+
| agent.fleet.policyName | string | `""` | Token policy name to use for fetching token from Kibana if the enrollment token is not supplied |
161173
| agent.fleet.kibanaHost | string | `""` | Kibana host to fallback if enrollment token is not supplied |
162174
| agent.fleet.kibanaUser | string | `""` | Kibana username to fallback if enrollment token is not supplied |
163175
| agent.fleet.kibanaPassword | string | `""` | Kibana password to fallback if enrollment token is not supplied |
176+
| agent.fleet.kibanaCA.value | string | `""` | Value of the CA certificate for Kibana if the enrollment token is not supplied |
177+
| agent.fleet.kibanaCA.valueFromSecret.name | string | `""` | Secret name for the Kibana CA certificate |
178+
| agent.fleet.kibanaCA.valueFromSecret.key | string | `""` | Key in the secret for the Kibana CA certificate |
179+
| agent.fleet.kibanaServiceToken | string | `""` | Service token to use when connecting to Kibana if the enrollment token is not supplied |
164180
| agent.fleet.preset | string | `"perNode"` | Agent preset to deploy |
165181

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Example: Managed by Fleet Elastic Agent with self-signed certificates
2+
3+
This example demonstrates deploying an Elastic Agent that is managed by Fleet with custom fleet-related certificates, including CA certificates and client certificates for mutual TLS (mTLS).
4+
5+
## Prerequisites:
6+
## Prerequisites
7+
8+
Before deploying, you should:
9+
10+
1. Set up an [Agent policy](https://www.elastic.co/guide/en/fleet/current/install-fleet-managed-elastic-agent.html#elastic-agent-installation-steps) in Fleet.
11+
2. Follow [this guide](https://www.elastic.co/guide/en/fleet/8.17/add-fleet-server-kubernetes.html#add-fleet-server-kubernetes-cert-prereq) to set up an agent policy and enroll an agent to it. Do not download any binary, from the proposed enrollment command just extract the Fleet URL (`--url=$FLEET_URL`) and Enrollment token (`--enrollment-token=$FLEET_TOKEN`).
12+
3. Create Kubernetes secrets holding the necessary certificates (CA certificate, client certificate, and client private key) or have the certificate files available locally to use with the `--set-file` Helm CLI argument.
13+
4. Build the dependencies of the Helm chart
14+
```console
15+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
16+
helm dependency build ../../
17+
```
18+
## Run:
19+
20+
```console
21+
helm install elastic-agent ../../ \
22+
--set agent.fleet.enabled=true \
23+
--set agent.fleet.url=$FLEET_URL \
24+
--set agent.fleet.token=$FLEET_TOKEN \
25+
--set agent.fleet.preset=perNode \
26+
--set-file agent.fleet.ca.value=path/to/ca.crt \
27+
--set-file agent.fleet.agentCert.value=path/to/agent.crt \
28+
--set-file agent.fleet.agentCertKey.value=agent.key \
29+
--set-file agent.fleet.kibanaCA.value=path/to/kibanaca.crt \
30+
-n kube-system
31+
```
32+
33+
## Validate:
34+
35+
1. `kube-state metrics` is installed with this command `kubectl get deployments -n kube-system kube-state-metrics`.
36+
2. Install Kubernetes integration to the agent policy that corresponds to the enrolled agents.
37+
3. The Kibana `kubernetes`-related dashboards should start showing the respective info.
38+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
kubernetes:
2+
enabled: true
3+
system:
4+
enabled: true
5+
agent:
6+
fleet:
7+
enabled: true
8+
url: http://localhost:8220
9+
token: fleetToken
10+
ca:
11+
value: |-
12+
-----BEGIN CERTIFICATE-----
13+
MIIBaDCCARCgAWIBAgIQNJyw4xhweOFK3/FqGLQF6TAKBggqhkjOPQQDAJAVMRMw
14+
EQYDVQQDEwpjbHVzdGVyLWNhMB4XDTI1MDEWODAOMDIyMFoXDTM1IMDEwNjAOMDIy
15+
MFowFTETMBEGA1UEAXMKY2x1c3R1Ucil1jYTBZMBMGByqGSM49AgEGCCqGSM49AWEH
16+
A0TABPcDLjOSlwAmeHbHFerT+SmTNqxckANmRPItCPRgkp2cq12a1C/ckQEebE1A
17+
B7WpiRaUQQkBpmNjcAPVIdfdnbWjQjBAMA4GA1UdDWEB/wQEAwICpDAPBgNVHRMB
18+
Af8EBTADAQH/MBOGA1UdDgQWBBTA5SRUKOE90/xKntDXcpZSvlL1JDBDAKBggqhkj0
19+
PQQDAGNGADBDAiAFghoM1M53abi968RyR+DwVX3S92aiu7MogtnuKCgPLQIFRRza
20+
Ondv3U1X2Qwo2ZELignHs3JLWucWvCIqmbW2+A==
21+
-----END CERTIFICATE-----
22+
agentCert:
23+
valueFromSecret:
24+
name: agent-cert
25+
key: crt
26+
agentCertKey:
27+
valueFromSecret:
28+
name: agent-cert
29+
key: private
30+
kibanaCA:
31+
value: |-
32+
-----BEGIN CERTIFICATE-----
33+
MIIBaDCCARCgAWIBAgIQNJyw4xhweOFK3/FqGLQF6TAKBggqhkjOPQQDAJAVMRMw
34+
EQYDVQQDEwpjbHVzdGVyLWNhMB4XDTI1MDEWODAOMDIyMFoXDTM1IMDEwNjAOMDIy
35+
MFowFTETMBEGA1UEAXMKY2x1c3R1Ucil1jYTBZMBMGByqGSM49AgEGCCqGSM49AWEH
36+
A0TABPcDLjOSlwAmeHbHFerT+SmTNqxckANmRPItCPRgkp2cq12a1C/ckQEebE1A
37+
B7WpiRaUQQkBpmNjcAPVIdfdnbWjQjBAMA4GA1UdDWEB/wQEAwICpDAPBgNVHRMB
38+
Af8EBTADAQH/MBOGA1UdDgQWBBTA5SRUKOE90/xKntDXcpZSvlL1JDBDAKBggqhkj0
39+
PQQDAGNGADBDAiAFghoM1M53abi968RyR+DwVX3S92aiu7MogtnuKCgPLQIFRRza
40+
Ondv3U1X2Qwo2ZELignHs3JLWucWvCIqmbW2+B==
41+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)