This is a project for multiplexing HTTP requests inside a Kubernetes cluster. When you need to send a HTTP request to each container in a cluster with a single HTTP request, k8s-http-multiplexer is what you need exactly.
Please note that k8s-http-multiplexer should be running inside a target Kubernetes cluster to properly operate.
k8s-http-multiplexer can be deployed as Kubernetes deployment or standalone installation. You can use sample deployment file to deploy your Kubernetes cluster. Before make deployment, you should deploy the sample configmap to the cluster. k8s-http-multiplexer reads that configmap to take proper actions on each HTTP request.
$ kubectl create -f deployment/configmap.yaml
$ kubectl create -f deployment/deployment_all.yaml
k8s-http-multiplexer can be customized with several command line arguments at the app level, and a configmap at the business level. Here is the list of arguments you can pass:
--kubeConfigPath string Kube config file path to access cluster. Required while running out of Kubernetes cluster.
--configFilePath string Path of the config file of k8s-http-multiplexer to read, defaults to /opt/config/config.yaml
--inCluster bool Boolean variable if k8s-http-multiplexer is running inside k8s cluster or not, required for
debugging purpose. Defaults to true.
You can inspect sample config file and sample configmap object.
This project requires below tools while developing:
- Golang 1.17
- pre-commit
- golangci-lint - required by pre-commit
Apache License 2.0
k8s-http-multiplexer uses client-go to interact
with kube-apiserver
. client-go uses the service account token
mounted inside the Pod at the /var/run/secrets/kubernetes.io/serviceaccount
path while initializing the client.
If you have RBAC enabled on your cluster, when you applied the sample deployment file config/sample.yaml, it will create required serviceaccount, role and rolebinding and then use that serviceaccount to be used by our k8s-http-multiplexer pods.
If RBAC is not enabled on your cluster, please follow that documentation to enable it.