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

Expose EMF TCP and UDP ports, and others, in the service #182

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

lucabrunox
Copy link
Contributor

@lucabrunox lucabrunox commented Jun 6, 2024

Description of changes:

Currently the operator creates a service for the agent with a fixed set of ports, without taking into account the agent configuration. That means adding emf: {} to the cwagent config will make the container listen to the ports 25888 tcp and udp, but the service does not add these ports.

The change does a little bit of refactoring to make the service ports the same as the container ports. I've split the commits to be more readable:

  • First the getContainerPorts function is made self-contained and it's moved to the ports.go file. This is not changing functionality, it's just moving it around.
  • Then change service.go to convert getContainerPorts into ServicePorts.
  • Finally add support for both TCP and UDP ports for EMF.

Manual testing:

This is an example k8s service having the ports 25888 for EMF when using the new operator image:

amazon-cloudwatch   service/cloudwatch-agent                                  ClusterIP   10.100.72.71     <none>        4315/TCP,4316/TCP,2000/TCP,25888/TCP,25888/UDP   14d
amazon-cloudwatch   service/cloudwatch-agent-headless                         ClusterIP   None             <none>        4316/TCP,2000/TCP,25888/TCP,25888/UDP,4315/TCP   14d

And the CWA container ports:

Controlled By:  DaemonSet/cloudwatch-agent
Containers:
  otc-container:
    Container ID:   containerd://d2e40914eb4ec970eac4a1676bbffc72b6acdfd1cd64df9c89e89bf226b7914a
    Image:          public.ecr.aws/cloudwatch-agent/cloudwatch-agent:1.300039.0b612
    Image ID:       public.ecr.aws/cloudwatch-agent/cloudwatch-agent@sha256:4e5ecc0152c99b338f06044963f2d451e7f6f09ea61723b80be14e8749e1ca4e
    Ports:          4315/TCP, 4316/TCP, 2000/TCP, 25888/TCP, 25888/UDP

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

Copy link
Contributor

@lisguo lisguo left a comment

Choose a reason for hiding this comment

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

lgtm

Name: EMF,
Port: receiverDefaultPortsMap[EMF],
tcp := corev1.ServicePort{
Name: EMFTcp,

Choose a reason for hiding this comment

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

Does the port Name need to correspond to anything else? Docs say "When considering the endpoints for a Service, this must match the 'name' field in the EndpointPort." Does that apply for us?

Choose a reason for hiding this comment

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

Spoke with @lisguo offline, we do not create Endpoints in the operator, so there's nothing to worry about here.

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