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

Support the value $POD_NAME for the annotation #982

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

thisisnotashwin
Copy link
Contributor

@thisisnotashwin thisisnotashwin commented Jan 20, 2022

Changes proposed in this PR:

  • Support the annotation consul.hashicorp.com/service-meta-pod_name: $POD_NAME where $POD_NAME will be replaced with the Pod's name. This mimics the support we had before the endpoints controller where environment variables were interpolated for tags.
  • This PR only supports $POD_NAME for now because it's the only environment variable we've been asked to support.

How I've tested this PR:

  • Unit tests.

How I expect reviewers to test this PR:

  • Code Review

Checklist:

  • Tests added
  • CHANGELOG entry added

    HashiCorp engineers only, community PRs should not add a changelog entry.
    Entries should use present tense (e.g. Add support for...)

@thisisnotashwin thisisnotashwin added area/connect Related to Connect service mesh, e.g. injection type/bug Something isn't working labels Jan 20, 2022
@thisisnotashwin thisisnotashwin changed the title Support the value $POD_NAME for the annotation `consul.hashicorp.co… Support the value $POD_NAME for the annotation Jan 20, 2022
@thisisnotashwin thisisnotashwin requested review from a team, kschoche and ishustava and removed request for a team January 20, 2022 19:07
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

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

Looks great, left a minor comment which is 100% not blocking :)

Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

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

:shipit:

@thisisnotashwin thisisnotashwin merged commit 13aba10 into main Jan 20, 2022
@thisisnotashwin thisisnotashwin deleted the ashwin/service-meta-pod_name branch January 20, 2022 19:21
@@ -9,6 +9,8 @@ IMPROVEMENTS:
* Allow customization of `terminationGracePeriodSeconds` on the ingress gateways. [[GH-947](https://github.com/hashicorp/consul-k8s/pull/947)]
* Support `ui.dashboardURLTemplates.service` value for setting [dashboard URL templates](https://www.consul.io/docs/agent/options#ui_config_dashboard_url_templates_service). [[GH-937](https://github.com/hashicorp/consul-k8s/pull/937)]
* Allow using dash-separated names for config entries when using `kubectl`. [[GH-965](https://github.com/hashicorp/consul-k8s/pull/965)]
* Control Plane
* Support the value `$POD_NAME` for the annotation `consul.hashicorp.com/service-meta-pod_name` that will now be interpolated and set to the pod name in the service's metadata. [[GH-982](https://github.com/hashicorp/consul-k8s/pull/982)]
Copy link
Member

Choose a reason for hiding this comment

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

@thisisnotashwin it's supported for any meta annotation right? Not just service-meta-pod_name but also service-meta-foo for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really. I asked @david-yu and the ask from the customer is to only support $POD_NAME.

Copy link

Choose a reason for hiding this comment

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

@thisisnotashwin Similar question that @lkysow asked. Should it support any meta annotation? I'm looking to also grab the pod-namespace. I can make a similar PR but then we get into different territory of adding every single metadata that we might need and doesn't seem sustainable

Copy link

Choose a reason for hiding this comment

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

or would it make sense to add another value for $POD_NAMESPACE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @jeenx !! Currently we have only added support for the value $POD_NAME. I agree that adding a separate PR per env var is not sustainable, but in this case, these env vars are not actually set in the runtime env. We are actually replacing it with the value pod.Name(). Hence we would need to this do on a per env basis as it is hard to determine whether the desired variable does exist in the env or not.

Copy link
Member

Choose a reason for hiding this comment

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

It's also important to note that this isn't actually an env var. We're doing this in the endpoints controller that doesn't have access to the actual pod's environment variables. So we can only support data we actually have when looking at the pod yaml.

Copy link

Choose a reason for hiding this comment

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

Got it, would it be possible to add all that data that is available on the pod (e.g, namespace)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connect Related to Connect service mesh, e.g. injection type/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants