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 support for a supplemental YAML configuration for the CloudWatchAgent #241

Merged
merged 5 commits into from
Oct 16, 2024

Conversation

mitali-salvi
Copy link
Contributor

Description of changes:

  1. Add otelConfig field to the AmazonCloudWatchAgent CRD
  2. Add new data to the existing cloudwatch-agent config-map with the contents of otelConfig
  3. Mount the config map onto the agent container.
  4. Open ports on the cloudwatch-agent service and container after parsing the supplemental YAML.
    i. Conflicting ports with agent JSON will be ignored

Testing
With the supplemental YAML passed to the agent ---

cwagentconfig.json:                                                                                                                                                          │
│ ----                                                                                                                                                                         │
│ {"agent":{"region":"us-west-2"},"logs":{"metrics_collected":{"application_signals":{"hosted_in":"my-dev-cluster"},"kubernetes":{"cluster_name":"my-dev-cluster","enhanced_co │
│ ntainer_insights":true}}},"traces":{"traces_collected":{"application_signals":{}}}}                                                                                          │
│ cwagentotelconfig.yaml:                                                                                                                                                      │
│ ----                                                                                                                                                                         │
│ exporters:                                                                                                                                                                   │
│   awsxray:                                                                                                                                                                   │
│     region: us-west-2                                                                                                                                                        │
│ processors:                                                                                                                                                                  │
│   batch: null                                                                                                                                                                │
│ receivers:                                                                                                                                                                   │
│   otlp:                                                                                                                                                                      │
│     protocols:                                                                                                                                                               │
│       grpc:                                                                                                                                                                  │
│         endpoint: 0.0.0.0:4317                                                                                                                                               │
│       http:                                                                                                                                                                  │
│         endpoint: 0.0.0.0:4318                                                                                                                                               │
│ service:                                                                                                                                                                     │
│   pipelines:                                                                                                                                                                 │
│     traces/xray:                                                                                                                                                             │
│       exporters:                                                                                                                                                             │
│       - awsxray                                                                                                                                                              │
│       processors:                                                                                                                                                            │
│       - batch                                                                                                                                                                │
│       receivers:                                                                                                                                                             │
│       - otlp      

When the YAML is deleted from the custom resource, the cloudwatch-agent reconciler will delete the config-map data entry and volume mount item

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

@@ -167,6 +167,9 @@ type AmazonCloudWatchAgentSpec struct {
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
// +required
Config string `json:"config,omitempty"`
// Config is the raw YAML to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Would specify that it's in addition to the JSON.

@@ -25,3 +27,16 @@ func ReplaceConfig(instance v1alpha1.AmazonCloudWatchAgent) (string, error) {

return string(out), nil
}

func ReplaceOtelConfig(instance v1alpha1.AmazonCloudWatchAgent) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: What is this replacing?

continue
}

exprtPorts, err := cmptParser.Ports()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should this be called receiverPorts?

@jefchien jefchien merged commit fc2bdf4 into main Oct 16, 2024
8 checks passed
okankoAMZ pushed a commit to okankoAMZ/amazon-cloudwatch-agent-operator that referenced this pull request Oct 31, 2024
okankoAMZ added a commit that referenced this pull request Nov 5, 2024
* Adding support for NodeJS auto instrumentation and integ tests (#220)

* Support configurable resources for NodeJS. (#225)

* Supporting JMX annotations (#240)

* Add support for a supplemental YAML configuration for the CloudWatchAgent (#241)

* Changed naming for OTLP container ports from agent JSON (#252)

* Updated Release Notes for 1.8.0 (#251)

* Adjust EKS add-on integration test service count expectations (#256)

* Add integration tests for JMX. (#250)

* Implemented Target Allocator Container (#214)

* Implemented TargetAllocator resource deployments. (#208)

* Update cmd/amazon-cloudwatch-agent-target-allocator/config/config.go

Co-authored-by: Musa <musaasad@amazon.com>

* Update internal/config/main.go

Co-authored-by: Musa <musaasad@amazon.com>

---------

Co-authored-by: Parampreet Singh <50599809+Paramadon@users.noreply.github.com>
Co-authored-by: Musa <musaasad@amazon.com>
Co-authored-by: Mitali Salvi <44349099+mitali-salvi@users.noreply.github.com>
Co-authored-by: Jeffrey Chien <chienjef@amazon.com>
okankoAMZ added a commit that referenced this pull request Nov 26, 2024
* Implemented Target Allocator Container (#214)

* Merge `main` into `target-allocator` (#232)

NodeJS merging-in from main

* Supporting K8s 1.31 (#222) (#236)

Co-authored-by: Mitali Salvi <44349099+mitali-salvi@users.noreply.github.com>

* Implemented TargetAllocator resource deployments. (#208)

* Adding target-allocator label to service selectors (#242)

* Target allocator TLS Implementation  (#239)

* Ta https server (#2921)

* Added https server, tests, secret marshalling


---------

Co-authored-by: ItielOlenick <67790309+ItielOlenick@users.noreply.github.com>

* [Target Allocator] Enable Deployment and Daemonset modes for Agent (#253)

* Changes error to warning

* [CI/CD] Add Target Allocator(TA) Build to Build and Upload Workflow (#247)

* edited workflow

* Clean up  managed resources when disabled (#255)

* Reconciler now removes un-used managed resources for CWA collector

* remove pprof endpoint (#260)

* [TA] One service per Target Allocator  (#259)

* added one-service per TA

* Setup cert-watcher for TA server cert (#264)

* [TA] Target Allocator TLS Unit-tests (#265)

* TLS tests

* Injecting Prometheus path if not specified in agent config (#258)

* Injecting Prom path if it doesn't exist

* Rebasing Target Allocator Branch to Main  (#266)

* Adding support for NodeJS auto instrumentation and integ tests (#220)

* Support configurable resources for NodeJS. (#225)

* Supporting JMX annotations (#240)

* Add support for a supplemental YAML configuration for the CloudWatchAgent (#241)

* Changed naming for OTLP container ports from agent JSON (#252)

* Updated Release Notes for 1.8.0 (#251)

* Adjust EKS add-on integration test service count expectations (#256)

* Add integration tests for JMX. (#250)

* Implemented Target Allocator Container (#214)

* Implemented TargetAllocator resource deployments. (#208)

* Update cmd/amazon-cloudwatch-agent-target-allocator/config/config.go

Co-authored-by: Musa <musaasad@amazon.com>

* Update internal/config/main.go

Co-authored-by: Musa <musaasad@amazon.com>

---------

Co-authored-by: Parampreet Singh <50599809+Paramadon@users.noreply.github.com>
Co-authored-by: Musa <musaasad@amazon.com>
Co-authored-by: Mitali Salvi <44349099+mitali-salvi@users.noreply.github.com>
Co-authored-by: Jeffrey Chien <chienjef@amazon.com>


---------

Co-authored-by: Musa <musaasad@amazon.com>
Co-authored-by: Mitali Salvi <44349099+mitali-salvi@users.noreply.github.com>
Co-authored-by: ItielOlenick <67790309+ItielOlenick@users.noreply.github.com>
Co-authored-by: Kaushik Surya <108111936+sky333999@users.noreply.github.com>
Co-authored-by: Parampreet Singh <50599809+Paramadon@users.noreply.github.com>
Co-authored-by: Jeffrey Chien <chienjef@amazon.com>
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.

3 participants