/k8s-http-multiplexer

HTTP request multiplexer inside a Kubernetes cluster

Primary LanguageGoApache License 2.0Apache-2.0

K8S Http Multiplexer

CI Docker pulls Go Report Card Quality Gate Status Reliability Rating Maintainability Rating Security Rating Coverage Go version License

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.

Installation

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

Configuration

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.

Development

This project requires below tools while developing:

License

Apache License 2.0

How k8s-http-multiplexer handles authentication/authorization with kube-apiserver?

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.