Skip to content

Implemented TargetAllocator resource deployments. #208

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

Merged
merged 105 commits into from
Oct 1, 2024

Conversation

musa-asad
Copy link
Contributor

@musa-asad musa-asad commented Aug 20, 2024

Description of changes

  • Updated Dockerfile and Makefile to include the target-allocator.
  • Implemented prometheus and target-allocator types.
  • Implemented target-allocator functionality for the amazon-cloudwatch-agent-operator, which does the following:
    • If a prometheus configuration is provided alongside enabling targetAllocator in the AmazonCloudWatchAgent custom resource for a given cluster, then the amazon-cloudwatch-agent-operator will build and deploy resources (ConfigMap, Deployment, ServiceAccount, and Service) alongside the amazon-cloudwatch-agent.
  • Implemented webhook functionality for target-allocator, which assigns a replica for target-allocator to ensure a pod replica is running (currently uses upstream image for target-allocator).
  • Deploy Prometheus ConfigMap, Volume, and VolumeMount if prometheus configuration is provided; similar to applying https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/prometheus-eks.yaml.
    • Implemented service discovery for the prometheus configuration.

Manual testing

  1. Ran make generate && make manifests && make test. [amazon-cloudwatch-agent-operator repo]
  2. Ran make container.
  3. Pushed operator image inside an ECR repo. [AWS console]
  4. Set up an EKS cluster with the CWAgent EKS Add-On.
  5. Ran kubectl edit deployment amazon-cloudwatch-observability-controller-manager -n amazon-cloudwatch and added the operator image. [K8s cluster]
  6. Ran kubectl apply -f config/crd/bases/cloudwatch.aws.amazon.com_amazoncloudwatchagents.yaml --server-side --force-conflicts.
  7. Ran kubectl edit amazoncloudwatchagent cloudwatch-agent -n amazon-cloudwatch and added below:
config: '{"agent":{"region":"us-west-2"}}'
...
mode: statefulset
...
prometheus:
    config:
      scrape_configs:
      - job_name: 'cloudwatch-agent'
        scrape_interval: 10s
        static_configs:
        - targets: [ '0.0.0.0:8888' ]
...
targetAllocator:
  enabled: true
  serviceAccount: cloudwatch-agent

Note: targetAllocatorServiceAcct needs to have permissions set up before we can use it.

ConfigMaps
Screenshot 2024-09-27 at 1 20 28 AM
Screenshot 2024-09-27 at 1 20 57 AM

(when TA is disabled)
Screenshot 2024-09-27 at 1 26 39 AM

(when TA is enabled)
Screenshot 2024-09-27 at 1 21 28 AM

Note: The amazon-cloudwatch-agent package will need to be updated to parse this new prometheus.yaml format.

Deployments
Screenshot 2024-09-27 at 1 22 24 AM

ServiceAccounts
Screenshot 2024-09-27 at 1 31 31 AM

Services
Screenshot 2024-09-27 at 1 23 07 AM

Pods
Screenshot 2024-09-27 at 1 23 23 AM

Prometheus Volume & VolumeMount
Screenshot 2024-09-27 at 1 24 00 AM

Files to be edited/included from upstream in future

  • Makefile
  • cmd/otel-allocator

Testing

  • Implemented unit tests, which pass alongside previous unit tests.

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

@musa-asad musa-asad self-assigned this Aug 20, 2024
Copy link
Contributor

@okankoAMZ okankoAMZ left a comment

Choose a reason for hiding this comment

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

I focused on changes since my last review. I will take a deeper look after these changes

@musa-asad musa-asad requested a review from okankoAMZ September 27, 2024 20:15
okankoAMZ
okankoAMZ previously approved these changes Sep 27, 2024
Copy link
Contributor

@okankoAMZ okankoAMZ left a comment

Choose a reason for hiding this comment

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

I think with the provided testing this should work

okankoAMZ
okankoAMZ previously approved these changes Sep 30, 2024
Copy link
Contributor

@mitali-salvi mitali-salvi left a comment

Choose a reason for hiding this comment

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

Could you run the linter on the code ?
make fmt or make goimports

@musa-asad musa-asad merged commit b3cf3cf into aws:target-allocator Oct 1, 2024
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.

6 participants