Code Monkey home page Code Monkey logo

Comments (8)

Cryptophobia avatar Cryptophobia commented on June 2, 2024

From @bacongobbler on March 6, 2017 15:27

It is not possible to reference the downward API today with pods. However, you can infer the pod namespace by the application name, which is available in the environment. The pod IP and others are currently unavailable, however we've generally pushed back on that due to concerns of exposing the cluster to the application developer (most multi-tenant systems like Heroku do not give you host information, for example).

If you'd like to take a tackle at this, you probably will want to make a proposal or write documentation that comes up with a couple use cases for this as well as how it'd look in the CLI, then write a PR against that doc.

Hope this helps!

from workflow.

Cryptophobia avatar Cryptophobia commented on June 2, 2024

From @gottfrois on March 6, 2017 15:45

thanks @bacongobbler for the quick answer. Being able to know POD IP as well as the host the POD is running on might be valuable information in order to force services communication to go through a service mesh running as a DaemonSet on the same host the POD is running.

I'm using linkerd to abstract services communication and the way it is setup is by having all http requests proxy through the linkerd instance running on the same host as the POD.

Here is the k8s POD configuration:

env:
- name: NODE_NAME
  valueFrom:
    fieldRef:
      fieldPath: spec.nodeName
- name: POD_IP
  valueFrom:
    fieldRef:
      fieldPath: status.podIP
- name: http_proxy
  value: $(NODE_NAME):4140

The POD_IP is really just to ensure load balancing is working while testing my setup but the NODE_NAME is used to make sure we proxy http requests through the local instance of linkerd.

Hope it helps to understand the usecase better.
Do you see any workaround for the moment?

from workflow.

Cryptophobia avatar Cryptophobia commented on June 2, 2024

From @gottfrois on March 6, 2017 16:2

The workaround I see is to manually query the k8s api within the POD using the following command:

$ KUBE_TOKEN=$(< /var/run/secrets/kubernetes.io/serviceaccount/token)
$ curl -sk -H "Authorization: Bearer $KUBE_TOKEN" https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1/namespaces/default/pods/$HOSTNAME | jq '.status.hostIP' | sed 's/"//g'
10.240.0.5

from workflow.

Cryptophobia avatar Cryptophobia commented on June 2, 2024

From @gottfrois on March 6, 2017 16:13

It would then be possible to execute a bash script to populate the HTTP_PROXY env variable:

command:
- "/bin/bash"
- "-c"
- "HTTP_PROXY=`./hostIP.sh`:4140 ..."

but is there a way to execute arbitraty commands on deis? Maybe in the Procfile directly!?

web: HTTP_PROXY=`./hostIP.sh`:4140 bundle exec puma -C config/puma.rb

from workflow.

Cryptophobia avatar Cryptophobia commented on June 2, 2024

From @robholland on March 29, 2017 8:51

@gottfrois Could you not have your config/puma.rb set the variable?

from workflow.

Cryptophobia avatar Cryptophobia commented on June 2, 2024

From @gottfrois on March 29, 2017 10:4

using a shell script called from the procfile worked, i guess it could be done in puma config as well yes

from workflow.

lshemesh avatar lshemesh commented on June 2, 2024

I'm guessing this could also be accomplished using a webhook and a MutatingWebhookConfiguration. I'm currently experimenting with that approach.

from workflow.

Cryptophobia avatar Cryptophobia commented on June 2, 2024

Let us know if you figure out a more elegant way @lshemesh ! 👍 There is also the lifecyclehooks as we talked about which are there but not really documented anywhere yet.

from workflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.