You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Send fleet-server elasticsearch config under new bootstrap attribute (#4643)
Alter the fleet-server bootstrap component modifier to insert all (elasticsearch)
output configuration options specified by enrollment args under a new elasticsearch.boostrap key
instead of overwriting any existing keys. This will allow elastic-agent to send the list of hosts
(and other config options) retrieved from a policy to fleet server as well as the config needed
to form the initial connection to elasticsearch used to collect policy information.
Fleet-server has been altered to use the bootstrap config that is passed if the policy attributes
are unspecified or fail.
Copy file name to clipboardexpand all lines: docs/fleet-server-bootstrap.asciidoc
+58
Original file line number
Diff line number
Diff line change
@@ -88,3 +88,61 @@ its API key to use for communication. The new `fleet.yml` still includes the `fl
88
88
but this time the `fleet.server.bootstrap: false` is set.
89
89
. `enroll` command then either restarts the running Elatic Agent daemon if one was running
90
90
from Step 2, or it stops the spawned `run` subprocess and returns.
91
+
92
+
=== Elasticsearch output
93
+
94
+
The options passed that are used to specify fleet-server initially connects to elasticsearch are:
95
+
96
+
- `--fleet-server-es`
97
+
- `--fleet-server-es-ca`
98
+
- `--fleet-server-es-ca-trusted-fingerprint`
99
+
- `--fleet-server-es-insecure`
100
+
- `--fleet-server-es-cert`
101
+
- `--fleet-server-es-cert-key`
102
+
- `--fleet-server-es-service-token`
103
+
- `--fleet-server-es-service-token-path`
104
+
- `--proxy-url`
105
+
- `--proxy-disabled`
106
+
- `--proxy-header`
107
+
108
+
These options are always passed under a `bootstrap` attribute in the output when elastic-agent is passing config to fleet-server.
109
+
When the fleet-server recieves an output block, it will inject any keys that are missing from the top level output but are specified in the `bootstrap` block
110
+
After injecting the keys from bootstrap, fleet-server will test connecting the Elasticsearch with the output.
111
+
If the test fails, the values under the `bootstrap` attribute are used as the output and fleet-server will periodically retest the output in case the error was caused by a temporary network issue.
112
+
Note that if `--fleet-server-es-insecure` is specified, and the output in the policy contains one or more CA, or a CA fingerprint, the `--fleet-server-es-insecure` flag is ignored.
113
+
114
+
An example of this sequence is sequence is:
115
+
116
+
1) elastic-agent starts fleet-server and sends an output block that looks similar to:
117
+
```yaml
118
+
output:
119
+
bootstrap:
120
+
service_token: VALUE
121
+
hosts: ["HOST"]
122
+
```
123
+
124
+
2) fleet-server injects attributes into the top level from bootstrap if they are missing, resulting in
125
+
```yaml
126
+
output:
127
+
service_token: VALUE
128
+
hosts: ["HOST"]
129
+
```
130
+
131
+
3) fleet-server connects to Elasticsearch with the output block
132
+
4) elastic-agent enrolls and recieves its policy
133
+
5) elastic-agent sends configuration generated from the policy to fleet-server, this may result in the output as follows:
134
+
```yaml
135
+
output:
136
+
hosts: ["HOST", "HOST2"]
137
+
bootstrap:
138
+
service_token: VALUE
139
+
hosts: ["HOST"]
140
+
```
141
+
142
+
6) fleet-server will inject missing values resulting in:
143
+
```yaml
144
+
output:
145
+
service_token: VALUE
146
+
hosts: ["HOST", "HOST2"]
147
+
```
148
+
7) fleet-server tests and uses the resulting output block.
// Elasticsearch is the configuration for elasticsearch.
35
+
// Elasticsearch is the configuration for fleet-server's connection to elasticsearch.
36
+
// Note that these keys may be injected into policy output by fleet-server.
37
+
// The following TLS options may be set in bootstrap:
38
+
// - VerificationMode
39
+
// - CAs
40
+
// - CATrustedFingerprint
41
+
// - CertificateConfig.Certificate AND CertificateConfig.Key
42
+
// If an attribute is added to this struct, or another TLS attribute is passed ensure that it is handled as part of the bootstrap config handler in fleet-server/internal/pkg/server/agent.go
Name: uuid.New().String(), // FIXME(michel-laterman): We need to specify a random name until an upstream issue is fixed: https://github.com/elastic/go-elasticsearch/issues/861
211
+
}
212
+
resp, err:=req.Do(ctx, client)
213
+
iferr!=nil {
214
+
return"", fmt.Errorf("error creating service token: %w", err)
0 commit comments