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

whereami app for GKE networking examples #131

Closed
mark-church opened this issue Jul 14, 2020 · 4 comments
Closed

whereami app for GKE networking examples #131

mark-church opened this issue Jul 14, 2020 · 4 comments

Comments

@mark-church
Copy link
Contributor

mark-church commented Jul 14, 2020

@theemadnes and I would like to submit https://github.com/theemadnes/gke-whereami to this repo so it can exist in gcr.io/google-samples and be referenced by GCP documentation as examples.

context

We are expanding our examples of GKE and Anthos Ingress, Service, and general networking example/recipes for reference from GKE documentation (similar to what was done for network policy). We have recipes for internal Ingress, external Ingress, internal L4 load balancing, custom HTTP headers, sticky sessions, weight-based load balancing, multi-cluster ingress, custom gRPC health checks .... and more.

challenge

We would like to use a common app for all examples. The challenge is that we require an app that replies with enough information about itself to demonstrate whatever key feature that's being focused on. The current apps in gcr.io/google-samples are either enourmously complex (looking at you hipster shop) or they don't provide enough response to be useful (hello-app).

whereami is a single Pod Flask app (easy to understand and deploy for the user) that provides the following as a response:

# easy to use
curl $VIP
{"cluster_name":"blog","node_name":"gke-blog-default-pool-9980a7d5-fihi.c.church-243723.internal","pod_ip":"10.4.1.8","pod_name":"whereami-64b9cc85b-g24tx","pod_name_emoji":"👨‍⚕️","pod_namespace":"default","pod_service_account":null,"project_id":"church-243723","timestamp":"2020-07-14T01:52:31","zone":"us-central1-c"}

# and easy to pull out just the info you need
curl -s $VIP | jq .pod_name_emoji -r
👨‍⚕️

This makes it easy for demos to show scaling, proximity-based load balancing between regions, sticky session etc and the simplicity of just a JSON response also makes it great for documentation example (no pictures required). Would it be possible to get whereami imported into this repo and pushed to google-samples so it can be referenced and used by GKE documentation?

cc @askmeegs

@theemadnes
Copy link
Member

The fields have been updated a bit lately - a sample (current) response:

{"cluster_name":"ph-demo-01","host_header":"hello","node_name":"gke-ph-demo-01-default-pool-2259626e-qqxj.c.alexmattson-scratch.internal","pod_ip":"10.48.2.24","pod_name":"whereami-7566845f96-l5klw","pod_name_emoji":"💔","pod_namespace":"default","pod_service_account":"whereami-ksa","project_id":"alexmattson-scratch","timestamp":"2020-07-14T04:03:49","version":"1.0","zone":"us-central1-f"}

It uses a bunch of data sources in its response, like host headers, K8s downstream API, etc. Per a GOOG coworker's request, I added a feature flag to contact a downstream JSON service to include its response in the reply, which can be demo'ed using Kustomize via the overlay directory in the repo. As the name suggests, it's GKE-centric.

@theemadnes
Copy link
Member

I added the emoji bit to hash the pod_name so you have a consistent visual representation of which pod you're talking to.

@mark-church
Copy link
Contributor Author

The code is now pushed to this repo via #132 and #133. Once @theemadnes is able to get the image into the google-samples GCR we can close this issue. Thanks for all the help @askmeegs !

@theemadnes
Copy link
Member

Pushed #134 to include header reflection.

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

No branches or pull requests

3 participants