https://github.com/mkenney/k8s-proxy
A simple, dynamic HTTP ingress service for Kubernetes development environments.
https://github.com/mkenney/k8s-proxy
go golang ingress k8s k8s-proxy kubernetes proxy proxy-service
Last synced: 5 months ago
JSON representation
A simple, dynamic HTTP ingress service for Kubernetes development environments.
- Host: GitHub
- URL: https://github.com/mkenney/k8s-proxy
- Owner: mkenney
- License: mit
- Created: 2018-04-02T01:01:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-13T05:46:22.000Z (over 7 years ago)
- Last Synced: 2024-04-22T19:19:05.066Z (about 2 years ago)
- Topics: go, golang, ingress, k8s, k8s-proxy, kubernetes, proxy, proxy-service
- Language: Go
- Homepage:
- Size: 49.8 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# k8s-proxy
This project provides a simple HTTP proxy service for easily working with multiple web services in a [Kubernetes](https://kubernetes.io/) development environment. A [Docker image](https://hub.docker.com/r/mkenney/k8s-proxy/) is available.
## Overview
The `k8s-proxy` service will serve all traffic on ports `80` and `443`. SSL traffic on port `443` is encrypted using a self-signed certificate, with all of the associated issues that brings. The exposed ports are configurable in the [`k8s-proxy.yml`](https://github.com/mkenney/k8s-proxy/blob/master/k8s-proxy.yml) file. You must set both the exposed ports in the deployment and service, as well as the `K8S_PROXY_PORT` and `K8S_PROXY_SSLPORT` environment variables in the deployment. Exposing the ports allows them to receive traffic and defining the environment variables tells the proxy service which ports to listen on.
The proxy will route traffic by matching the domain being requested to a service running in the cluster. By default, this is done based on the service name. For example a request for `http://service1.any.host.here` would be routed to a service named 'service1', if it exists.
That is convenient but can be cumbersom in practice. You can also map a subdomain to a particular service by applying labels to the service. All labels are optional:
```yaml
kind: Service
apiVersion: v1
metadata:
name: ui_backend_service
labels:
- k8s-proxy-scheme: https # HTTP scheme to use when addressing this service.
- k8s-proxy-port: 30021 # Port on the service to send traffic to.
- k8s-proxy-domain: api.myapp # Subdomain to map this service to.
```
Using labels you can be sure that traffic to `http://api.myapp.any.host.here` and `https://api.myapp.any.host.here` (ssl) will be routed to your service.
## Prerequisites
A properly configured and accessible Kubernetes environment and the `start.sh` script expects the `kubectl` executable to be available in the `$PATH`. Your kube context should be set for the intended environment before executing the script.
## Getting started
Start or restart the proxy service. Listens on ports `80` and `443`.
```
./start.sh
```
Or manually apply the deployment and service.
```
kubectl apply -f k8s-proxy.yml
```
Ports can be configured in the k8s-proxy.yml deployment. You must set both the container ports and the `K8S_PROXY_PORT` and `K8S_PROXY_SSL_PORT` environment variables (which inform the proxy executable which ports to bind to).