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

Set controller user-agent to vpc-resource-controller/git-version #455

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

orsenthil
Copy link
Member

@orsenthil orsenthil commented Aug 21, 2024

Issue #, if available:

#442

The cloudwatch EKS cluster logs for vpc-resource-controller actions shows the userAgent field as:
"userAgent": "controller/v0.0.0 (linux/amd64) kubernetes/$Format",

Description of changes:

The controller user agent is set in the kubeConfig / client-go in this controller's case.

And it can be customized by updating .UserAgent of the kubeconfig used in making the call.

Testing.

  1. Built the VPC RC Image with this change.
  2. Deployed it to Beta Clusters
  3. Verified it Audit Logs
fields @timestamp, @message, @logStream

| filter @logStream like /audit/

| filter requestURI like /cninodes/

image

After this change the userAgent will set to

        "@message": {
            "kind": "Event",
            "apiVersion": "audit.k8s.io/v1",
            "level": "Metadata",
            "auditID": "2e4b4b35-1aa0-4733-89c4-4xxx",
            "stage": "ResponseStarted",
            "requestURI": "/apis/vpcresources.k8s.aws/v1alpha1/cninodes?allowWatchBookmarks=true&resourceVersion=36132&timeoutSeconds=421&watch=true",
            "verb": "watch",
            "user": {
                "username": "eks:vpc-resource-controller",
                "groups": [
                    "system:authenticated"
                ]
            },
            "sourceIPs": [
                "10.0.97.217"
            ],
            "userAgent": "vpc-resource-controller/v1.5.0-11-gaabe5fd",
  • there is no unit-test for the main module for this controller at the moment; this will require some refactor.

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

main.go Outdated Show resolved Hide resolved
Copy link
Contributor

@haouc haouc left a comment

Choose a reason for hiding this comment

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

lgtm

@orsenthil orsenthil merged commit 4a70259 into aws:master Aug 21, 2024
4 checks passed
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