Skip to content

Add the ability to refer to runtime values (service's IP) in dependent resources. #949

Closed

Description

@madhusudancs

For example, I would like to start a service and use it's IP address in another pod. Dependencies have been discussed before in other contexts. Ref: issues #53 #54. This is very useful and simplifies handling dependent charts.

Activity

  1. changed the title [-]Ability to refer values in dependent resources.[/-] [+]Add the ability to refer values in dependent resources.[/+] on Jul 12, 2016
  2. technosophos commented on Jul 14, 2016

    @technosophos
    Member

    Isn't this solved by the Kubernetes environment variable and service discovery protocols? http://kubernetes.io/docs/user-guide/connecting-applications/#accessing-the-service

    Since templates are rendered before resources are loaded into Kubernetes, templates cannot find out at render time what the IPs are. But you could use label selectors, Downward API, Kubernetes environment variables, and skydns queries to find this information out.

  3. bacongobbler commented on Jul 14, 2016

    @bacongobbler
    Member

    I would like to start a service and use it's IP address in another pod.

    Indeed, isn't this just a re-implementation of http://kubernetes.io/docs/admin/dns/? Sounds to me this has already been solved upstream. Can you supply a use case where this would be required?

  4. madhusudancs commented on Jul 21, 2016

    @madhusudancs
    Author

    @technosophos @bacongobbler Both the service discovery methods (environment variables and DNS) within Kubernetes clusters return the cluster local IP addresses, but not the external addresses for LoadBalancer services. Also, I don't think Downward API exposes the service IP address.

    Here is a more concrete use case. I am considering converting "Cluster Federation" components to helm charts. Here is the federation-apiserver pod template spec - https://github.com/kubernetes/kubernetes/blob/master/federation/manifests/federation-apiserver-deployment.yaml#L25. The --advertise-address flag value is parametrized and should be substituted with the external address of the type: loadBalancer service created for the federation-apiserver. Look at the current code to do this - https://github.com/kubernetes/kubernetes/blob/master/federation/cluster/common.sh#L127

    To convert these to helm, I see three options. Let me know if you have any other recommendations.

    1. Put the service and deployment charts into separate helm packages. Submit the service chart and poll until the external IP is assigned and then submit the deployment chart with the IP address.
    2. Build the service polling logic into the apiserver container or into the apiserver itself.
    3. Use the new, in-alpha, init container feature and put the polling logic there.

    None of these options are any better than what we have today, which in my opinion is already unnecessarily complicated and could be much simplified if there is a tool that can handle dependencies. And among the tools we have today I think helm is the closest.

    Btw, this is just one concrete use case.

  5. technosophos commented on Jul 22, 2016

    @technosophos
    Member

    Ah! I understand much better now. Thanks.

    In today's Helm, you could use pre-install hooks to do some of the things you were thinking of. But again, I'm not sure that that would decrease the complexity of the logic.

    It sounds like what would really solve the problem for you is for some way to say to Helm: "At the time that this manifest (or resource) is loaded, do a lookup for me and inject the results here." Does that sound accurate?

    I'm not sure how to best express that in Helm right now. If you had an ideal way, what would it look like? Would it be a template directive? Want to mock that out and see if we can get some ideas going?

  6. changed the title [-]Add the ability to refer values in dependent resources.[/-] [+]Add the ability to refer to runtime values (service's IP) in dependent resources.[/+] on Aug 8, 2016
  7. added this to the milestone on Oct 7, 2016
  8. technosophos commented on Dec 19, 2016

    @technosophos
    Member

    We are still tossing around some ideas on how to do this. /cc @adamreese

  9. thomastaylor312 commented on Mar 24, 2017

    @thomastaylor312
    Contributor

    @technosophos or @adamreese Is there still ongoing discussion/plans for this on a minor release or should be bump it to the "major" milestone?

  10. pierreozoux commented on Mar 27, 2017

    @pierreozoux
    Contributor

    I'm actually working on a public chart for jitsi, and it needs to know it's public IP.
    What is the way to solve this today?

  11. bacongobbler commented on Mar 27, 2017

    @bacongobbler
    Member

    https://github.com/kubernetes/charts/blob/master/stable/drupal/templates/NOTES.txt shows some examples on how you can fetch a chart's public IP address depending on what service type was deployed. Essentially if you need the public IP at runtime, you'll have to check with the kubernetes apiserver.

  12. sabbour commented on Oct 3, 2017

    @sabbour

    This is a needed feature. Another use case:
    Web frontend running in a service talking to multiple microservices over the internet (Javascript calls) deployed in their own services.

    I need a way to be able to find out what's the public IP of a specific service from within the container.

    Currently DNS exposes the service.namespace (which is internal), and the environment variables expose the internal load balancer IP (which won't be routable from Javascript).

  13. bacongobbler commented on Oct 31, 2017

    @bacongobbler
    Member

    If someone would write up a design document with a reference implementation on how this could be solved, that would be incredibly helpful. We're not sure how to best express this in Helm, so perhaps someone from the community may know more.

  14. added
    help wanted
    on Oct 31, 2017
  15. 11 remaining items

  16. scottlindner commented on Aug 10, 2018

    @scottlindner

    I wrote a shell script that runs at container startup that talks to the cluster to get those values and drops them in environment variables.

  17. SachinHg commented on Sep 30, 2018

    @SachinHg

    Can someone please help with this feature?

  18. viane commented on Jan 16, 2019

    @viane

    Its 2019 and I'm still waiting for this feature 🤣
    My need is just to get the nodes's IP address based on the label, and assign them to the value resource in the pre-install hook.

    @technosophos Hi, sorry for DM, just wondering if my case is a valid request for this feature, I'm trying to assign the node's ip address base on their label during the chart installation. Or if there is a alternative way to do this? Thanks

  19. AlexShemeshWix commented on Jan 30, 2019

    @AlexShemeshWix

    +1

  20. gazhenko commented on Feb 6, 2019

    @gazhenko

    +1

  21. SlickNik commented on Feb 7, 2019

    @SlickNik
    Member

    @viane Unfortunately, I don't think this is possible in a pre-install hook since the resources haven't been created in Kubernetes yet. Essentially, the only way I can think of doing this is checking with the Kubernetes API server (like @bacongobbler mentions above) once the resources have been created -- either in a post-install hook, or once the pod container comes up at runtime.

  22. kierenj commented on Feb 13, 2019

    @kierenj
  23. viane commented on Feb 13, 2019

    @viane

    in my case its only available thru k8s resource, a worker node ip inside the cluster... And I still couldn't find a clean way to get this resource. But the label and node's ip was already exist inside k8s, why can't helm retrieve it ....

  24. archelangelo commented on Jun 20, 2019

    @archelangelo

    One use case would be setting up the upstream DNS service for kube-dns using the stubDomains configuration. The stubDoamins destinations can only be IP addresses of upstream DNS services. It would be great if the IP address assigned to a service can be referred to during the helm installation so that this stubDomains configuration can be done in the same helm chart. See here and here.

  25. dshakey commented on Oct 5, 2019

    @dshakey

    Bump.

  26. bacongobbler commented on Jan 27, 2020

    @bacongobbler
    Member

    closing as #6752 has been merged and will be available in 3.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurehelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions