Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Helm] Allow providing CA certificate of the Fleet Server when running the agent in fleet mode #6285

Open
eedugon opened this issue Dec 11, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Comments

@eedugon
Copy link
Contributor

eedugon commented Dec 11, 2024

When installing the agent in Fleet Mode with something like:

helm install demo ./deploy/helm/elastic-agent \
--set agent.fleet.enabled=true \
--set agent.fleet.url=https://fleet-svc.default.svc \
--set agent.fleet.token=TTg1NHNaTUJoNkpaNzE4R3IzeGg6WXo2MUxSakJTNmVvZUE3d212V0JGUQ== \
--set agent.fleet.preset=perNode \

If the Fleet Server is configured with a certificate signed by a corporate / custom / intermediate CA the Elastic Agent should get the CA certificate configured on FLEET_CA environment variable (if I'm not mistaken, based on https://www.elastic.co/guide/en/fleet/current/agent-environment-variables.html#env-enroll-agent).

The only current workaround is to use --set agent.fleet.insecure=true to bypass the certificate check during enrollment.

Note that providing the Elasticsearch CA for a normal agent (Fleet Managed) is not needed as it will be fetched from the policy at a later stage.

In my opinion this is important to achieve before considering the helm chart GA (cc: @nimarezainia / @pkoutsovasilis ).

@eedugon eedugon added the enhancement New feature or request label Dec 11, 2024
@eedugon eedugon changed the title [Helm chart] Allow providing CA certificate of the Fleet Server when running the agent in fleet mode [Helm] Allow providing CA certificate of the Fleet Server when running the agent in fleet mode Dec 11, 2024
@eedugon eedugon added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Dec 11, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@nimarezainia
Copy link
Contributor

@pkoutsovasilis I assume that those variables are missing from Helm - correct? which would be required before GA of this.

Does it make sense to ensure that all the options available can be configured via Helm? (referring to these)

@pkoutsovasilis
Copy link
Contributor

Hey @nimarezainia 👋, apologies for the delay - this one slipped off my radar.

To address your question, we’re indeed missing the values to pass inside the container for these variables:

FLEET_CA
KIBANA_CA
ELASTICSEARCH_CA
FLEET_INSECURE
FLEET_TOKEN_NAME
FLEET_TOKEN_POLICY_NAME
FLEET_DAEMON_TIMEOUT
ELASTIC_AGENT_CERT
ELASTIC_AGENT_CERT_KEY

Regarding the proxy extra args, it seems these aren’t supported when running a containerized agent (relevant code reference).

One issue is that variables like FLEET_CA, KIBANA_CA, ELASTICSEARCH_CA, ELASTIC_AGENT_CERT, and ELASTIC_AGENT_CERT_KEY are essentially file paths. Since Helm doesn’t allow users to directly input or read file contents, the workaround is to let users specify their content instead. Then, we can create custom ConfigMaps that the Helm chart can mount, setting up the respective container environment variables accordingly.

@nimarezainia
Copy link
Contributor

One issue is that variables like FLEET_CA, KIBANA_CA, ELASTICSEARCH_CA, ELASTIC_AGENT_CERT, and ELASTIC_AGENT_CERT_KEY are essentially file paths. Since Helm doesn’t allow users to directly input or read file contents, the workaround is to let users specify their content instead. Then, we can create custom ConfigMaps that the Helm chart can mount, setting up the respective container environment variables accordingly.

just a correction, these may be file-paths or actual CA/certs. It would be great if we could support the file path option also.

@strawgate
Copy link
Contributor

I believe at least elasticsearch ca is ignored in fleet mode (which the issue creator mentions), worth checking the other variables as well.

@pkoutsovasilis
Copy link
Contributor

@nimarezainia I indeed do remember some certificate-related env vars that could be either a path or the actual certificate value but for these ones from what I have seen in the code and from what I read in the documentation

FLEET_CA (string) The path to a certificate authority. Overrides ELASTICSEARCH_CA when set.By default, Elastic Agent uses the list of trusted certificate authorities (CA) from the operating system where it is running. If the certificate authority that signed your node certificates is not in the host system’s trusted certificate authorities list, use this config to add the path to the .pem file that contains your CA’s certificate.

KIBANA_CA (string) The path to a certificate authority.By default, Elastic Agent uses the list of trusted certificate authorities (CA) from the operating system where it is running. If the certificate authority that signed your node certificates is not in the host system’s trusted certificate authorities list, use this config to add the path to the .pem file that contains your CA’s certificate.

ELASTICSEARCH_CA (string) The path to a certificate authority.By default, Elastic Agent uses the list of trusted certificate authorities (CA) from the operating system where it is running. If the certificate authority that signed your node certificates is not in the host system’s trusted certificate authorities list, use this config to add the path to the .pem file that contains your CA’s certificate.

ELASTIC_AGENT_CERT (string) The path to the mutual TLS client certificate that Elastic Agent will use to connect to Fleet Server.

ELASTIC_AGENT_CERT_KEY (string) The path to the mutual TLS private key that Elastic Agent will use to connect to Fleet Server.

are paths only? please tell me what I am missing.

Moreover, supporting a user specifying a path during the installation and making this path appear inside a pod with the same contents is not possible as Helm doesn't support reading contents of arbitrary paths. Two possible solutions I can thing of are:

  1. allow the users specify already existing configmaps that they have created and which will be mounted by the chart inside the agent container
  2. allow the users to specify the contents of each certificate through the chart values.yaml and then the chart will create configmaps from them and mount them inside the agent container

@nimarezainia
Copy link
Contributor

I may be mistaken. @AndersonQ would you know? can these fields have a cert or is it always a path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

No branches or pull requests

5 participants