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

Add default TLS client cert and key paths for Prometheus input and receiver #1510

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

musa-asad
Copy link
Contributor

@musa-asad musa-asad commented Jan 20, 2025

Description of the issue

The Prometheus input and receiver within the CloudWatch Agent do not have default TLS client certificate and key file paths set. Without these default paths, the agent does not know which certificate to use for mutual TLS authentication with the Target Allocator server. This prevents the agent from properly connecting to the Target Allocator, as the agent cannot locate the required TLS certificates.

Description of changes

  • Added client certificate and key variables with default file paths to Prometheus input and receiver.
  • Assigned client certificate and key variables variables to Target Allocator TLS settings.
  • Updated unit test to test for new variables.
  • Fixed linting issues.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  1. Created EKS cluster using custom agent, operator, and target allocator images (Implement mTLS resources and configuration for Target Allocator server amazon-cloudwatch-agent-operator#284).
  2. Ran helm upgrade --install --debug amazon-cloudwatch-observability helm-charts/charts/amazon-cloudwatch-observability --set clusterName=<cluster_name> --set region=us-west-2 --namespace amazon-cloudwatch --create-namespace with custom helm charts (Implement mTLS resources for CloudWatch Agent client aws-observability/helm-charts#163) and edited values.yaml with a custom agent and prometheus configuration.
  3. Set up sample application: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Sample-Workloads-memcached.html.
Screenshot 2025-01-21 at 3 41 56 AM

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@musa-asad musa-asad changed the title Add default TLS client cert and key paths for Prometheus input Add default TLS client cert and key paths for Prometheus input and receiver Jan 21, 2025
@musa-asad musa-asad self-assigned this Jan 21, 2025
@musa-asad musa-asad marked this pull request as ready for review January 21, 2025 08:46
@musa-asad musa-asad requested a review from a team as a code owner January 21, 2025 08:46
var DEFAULT_TLS_CA_FILE_PATH = filepath.Join("/etc", "amazon-cloudwatch-observability-agent-cert", "tls-ca.crt")
var (
DefaultTLSCaFilePath = filepath.Join("/etc", "amazon-cloudwatch-observability-agent-cert", "tls-ca.crt")
DefaultTLSCertFilePath = filepath.Join("/etc", "amazon-cloudwatch-observability-agent-outbound-cert", "client.crt")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that we already have amazon-cloudwatch-observability-agent-cert used in a couple of places. Is the outbound-cert new? Is it only for TA?

Copy link
Contributor Author

@musa-asad musa-asad Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outbound-cert is only for when the agent behaves as a client in mTLS. Right now, it's only being used for when the agent acts as a client to the TA server, but it could be used against other servers too.

  • amazon-cloudwatch-observability-agent-client-cert -> client cert and key for fluent-bit
  • amazon-cloudwatch-observability-agent-server-cert -> server cert and key for agent (technically can be used in this place, but avoided due to separation of concerns)
  • amazon-cloudwatch-observability-agent-cert -> server cert and key for dcgm, neuron, and ta
  • amazon-cloudwatch-observability-agent-outbound-cert -> client cert and key for agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants