From 8a3dde23808e36be13976ad8235fb5ae08fbf5a5 Mon Sep 17 00:00:00 2001 From: Rimantas Mocevicius Date: Sat, 7 Nov 2015 18:10:20 -0800 Subject: [PATCH] feat(proxy-2-service): add proxy-2-service chart --- proxy-2-service/Chart.yaml | 8 ++++ proxy-2-service/README.md | 42 +++++++++++++++++++ .../manifests/proxy-2-service.yaml | 15 +++++++ 3 files changed, 65 insertions(+) create mode 100644 proxy-2-service/Chart.yaml create mode 100644 proxy-2-service/README.md create mode 100644 proxy-2-service/manifests/proxy-2-service.yaml diff --git a/proxy-2-service/Chart.yaml b/proxy-2-service/Chart.yaml new file mode 100644 index 0000000000..f83acf1b50 --- /dev/null +++ b/proxy-2-service/Chart.yaml @@ -0,0 +1,8 @@ +name: proxy-2-service +home: https://github.com/kubernetes/contrib/tree/master/for-demos/proxy-to-service +version: 0.1.0 +description: Proxy a pod port or host port to a kubernetes Service +maintainers: +- Rimas Mocevicius +details: |- + Very handy for demos from your laptop to be able to access service via host IP and port diff --git a/proxy-2-service/README.md b/proxy-2-service/README.md new file mode 100644 index 0000000000..d49f0738ae --- /dev/null +++ b/proxy-2-service/README.md @@ -0,0 +1,42 @@ +# proxy-2-service + +Proxy a pod port or host port to a kubernetes Service + +While Kubernetes provides the ability to map Services to ports on each node, +those ports are in a special range set aside for allocations. This means you +can not not simply choose to expose a Service on port 80 on your nodes. You +also can not choose to expose it on some nodes but not others. These things +will be fixed in the future, but until then, here is a stop-gap measure you can +use. + +The container image `gcr.io/google_containers/proxy-to-service:v2` is a very +small container that will do port-forwarding for you. You can use it to +forward a pod port or a host port to a service. Pods can choose any port or +host port, and are not limited in the same way Services are. + +For example, suppose you want to forward a node's port 80 (HTTP) to your +node's nginx service. The following pod would do the trick: + +``` +apiVersion: v1 +kind: Pod +metadata: + name: http-proxy +spec: + containers: + - name: proxy-http + image: gcr.io/google_containers/proxy-to-service:v2 + args: [ "tcp", "80", "nginx.default" ] + ports: + - name: http + protocol: TCP + containerPort: 80 + hostPort: 80 +``` + +This creates a pod with one container receives traffic on a port 80 (HTTP) and +forwards that traffic to the `nginx` service. +You also can add more ports adding another container there. +You can run this on as many or as few nodes as you want. + +Note: Kubernetes DNS Add-on needs to be installed diff --git a/proxy-2-service/manifests/proxy-2-service.yaml b/proxy-2-service/manifests/proxy-2-service.yaml new file mode 100644 index 0000000000..d7120da0e6 --- /dev/null +++ b/proxy-2-service/manifests/proxy-2-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: http-proxy + heritage: helm +spec: + containers: + - name: http-tcp + image: gcr.io/google_containers/proxy-to-service:v2 + args: [ "tcp", "80", "nginx.default" ] + ports: + - name: http + protocol: TCP + containerPort: 80 + hostPort: 80