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 dead simple k8s configs #32

Merged
merged 4 commits into from
Oct 4, 2016
Merged

Add dead simple k8s configs #32

merged 4 commits into from
Oct 4, 2016

Conversation

adleong
Copy link
Member

@adleong adleong commented Oct 4, 2016

Writeup to follow.

@adleong adleong self-assigned this Oct 4, 2016
Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

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

this all looks very cool. think the helper script can be a bit nicer..

set -e

sleep 10
curl -s "${K8S_API:-localhost:8001}/api/v1/namespaces/$NS/pods/$POD_NAME" | jq '.status.hostIP' | sed 's/"//g'
Copy link
Member

@olix0r olix0r Oct 4, 2016

Choose a reason for hiding this comment

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

FWIW, I think this could be even more useful as an init/wrapper script:

i.e. proxied_run

#!/bin/sh

set -e

if [ $# -lt 1 ]; then
  echo "usage: proxied_run cmd args..." >&2
  exit 1
fi

k8s_api="${K8S_API:-localhost:8001}/api/v1/namespaces/$NS/pods/$POD_NAME"

host_ip=$(curl -s  | jq '.status.hostIP' | sed 's/"//g')
export http_proxy=$host_ip:4140 HTTP_PROXY=$host_ip:4140

exec "$@"

Copy link
Member

Choose a reason for hiding this comment

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

Seems like a tall order to ask that jq be installed (this won't ever work on busybox etc)...

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing it as a wrapper looks nice. I agree that's probably better.

jq is a tall order but how do you suggest interacting with the kubernetes API? busybox probably doesn't even have curl...

Copy link
Member

@olix0r olix0r Oct 4, 2016

Choose a reason for hiding this comment

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

Wait. I think we can just use the downward API for this!

Something like:

containers:
- ...
  env:
  - name: LINKERD_IP
    valueFrom:
      fieldRef:
        fieldPath: status.hostIP

Copy link
Member Author

Choose a reason for hiding this comment

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

kubernetes/kubernetes#24657

available in 1.4

Choose a reason for hiding this comment

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

@adleong kubernetes #24657 just make a proposal for hostIP which is finally merged in kubernetes #42717, in kubernetes #27880, spec.NodeName is added to downward API.

Copy link
Member

Choose a reason for hiding this comment

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

@andyxning thanks for the note!


set -e

sleep 10
Copy link
Member

Choose a reason for hiding this comment

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

??? why?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a mystery. It seems like when the container starts, the k8s API isn't guaranteed to already know about it. If we query the API too soon, this pod isn't there.

mountPath: "/io.buoyant/linkerd/config"
readOnly: true
- name: kubectl
image: buoyantio/kubectl:1.2.3
Copy link
Member

Choose a reason for hiding this comment

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

not a blocker, but we probably want to get a newer kubectl out (1.4 is out now...)

Copy link
Member

Choose a reason for hiding this comment

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

building now...

containers:
- name: l5d
image: buoyantio/linkerd:0.8.1
imagePullPolicy: Always
Copy link
Member

Choose a reason for hiding this comment

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

fwiw we probably don't need to set imagePullPolicy on stable tags

Copy link
Member Author

Choose a reason for hiding this comment

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

good point

@siggy siggy force-pushed the alex/dead-simple-k8s branch from 235e2ec to f7b433f Compare October 4, 2016 18:35
Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

⭐️ Looks good!


```bash
http_proxy=$(kubectl get svc | grep l5d | awk '{ print $3 }'):4140 curl -s http://hello
http_proxy=$(kubectl get svc | grep l5d | awk '{ print $3 }'):4140 curl -s http://world
Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh, let's use JSONpath here:

$ http_proxy=$(kubectl get svc l5d -o jsonpath="{.spec.loadBalancerIP}"):4140 curl -s http://hello
$ http_proxy=$(kubectl get svc l5d -o jsonpath="{.spec.loadBalancerIP}"):4140 curl -s http://world


```bash
kubectl apply -f linkerd-viz.yml
open http://$(kubectl get svc | grep linkerd-viz | awk '{ print $3 }')
Copy link
Contributor

@klingerf klingerf Oct 4, 2016

Choose a reason for hiding this comment

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

And here:

$ open http://$(kubectl get svc linkerd-viz -o jsonpath="{.spec.loadBalancerIP}")

@siggy siggy mentioned this pull request Oct 4, 2016
@siggy
Copy link
Member

siggy commented Oct 4, 2016

fwiw there's now a lot of duplication between these config files and the ones under k8s-daemonset/k8s and getting-started/k8s, ticketed at: #33

@siggy siggy merged commit b52ec31 into master Oct 4, 2016
@siggy siggy deleted the alex/dead-simple-k8s branch October 4, 2016 22:31
@siggy siggy removed the reviewable label Oct 4, 2016
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.

6 participants