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 service attribute that would return name of a NEG #668

Closed
jaceq opened this issue Oct 31, 2019 · 7 comments
Closed

Add service attribute that would return name of a NEG #668

jaceq opened this issue Oct 31, 2019 · 7 comments

Comments

@jaceq
Copy link

jaceq commented Oct 31, 2019

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

0.12.12

Affected Resource(s)

kubernetes_service

Expected Behavior

After defining a service and adding annotation that creates a standalone NEG (or in-fact a ingress NEG):
cloud.google.com/neg: '{"exposed_ports": {"80":{}}}'
I'd like to able to fetch name of created NEG as an attribute.
I mean something similar to attribute: kubernetes_service.some_name.load_balancer_ingress.0.ip

This would enable using standalone NEGs as a backend for HTTP(S) Load balancers.

Nam of created NEG is available as annotation right after creation (and is port specific):

      metadata.0.annotations.cloud.google.com/neg-status: "{\"network_endpoint_groups\":{\"80\":\"k8s1-71f753e6-default-example-80-9b3d0709\"},\"zones\":[\"europe-west1-b\",\"europe-west1-c\",\"europe-west1-d\"]}" => "

So it's 'k8s1-71f753e6-default-example-80-9b3d0709' in above example.

@jaceq jaceq changed the title Add service attribute that would return name of a standalone NEG Add service attribute that would return name of a NEG Oct 31, 2019
@JordanP
Copy link
Contributor

JordanP commented Nov 12, 2019

That annotation looks like a JSON string, maybe you could use the jsondecode function.

@jaceq
Copy link
Author

jaceq commented Nov 14, 2019

@JordanP Sure I can. It's not about being able to transform it, it's about being able to read it.

Basically flow I'd like to achieve is:

  1. Create service with stand alone NEG
  2. Use output from service - NEG name - in order to assign it as Load Balancer backend.

Now I cannot do it, as there is no way to read (well I found a 80% of time working hacky way but that is bad) that status annotation at the same run when service is created.

@alexsomesan
Copy link
Member

Would it help to re-read the service using a kubernetes_service data-source?

See here for details: https://www.terraform.io/docs/providers/kubernetes/d/service.html

@alexsomesan
Copy link
Member

#830 should improve the situation. After the create completes you should see the annotation on the service.

@jaceq
Copy link
Author

jaceq commented May 8, 2020

@alexsomesan re-reading with data source requires either second run of TF or some workaround - as I understand normally resources are read prior to creation...

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!

@github-actions github-actions bot added the stale label Jan 7, 2022
@github-actions github-actions bot closed this as completed Feb 6, 2022
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants