kubernetes-sigs / apiserver-network-proxy

Apache License 2.0
382 stars 182 forks source link
k8s-sig-cloud-provider

apiserver-network-proxy

Created due to https://github.com/kubernetes/org/issues/715.

See the KEP proposal for architecture and details.

Community, discussion, contribution, and support

Learn how to engage with the Kubernetes community on the community page.

You can reach the maintainers of this project at:

Code of conduct

Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.

Versioning and releases

As of the 0.28.0 release, the apiserver-network-proxy project is changing its versioning and release process. Going forward the project will adhere to these rules:

For Kubernetes version 1.28.0+, we recommend using the tag that corresponds to the same minor version number. For example, if you are working with Kubernetes version 1.99, please utilize the latest 0.99 tag and refer to the release-0.99 branch. It is important to note that there may be disparities in the patch level between apiserver-network-proxy and Kubernetes.

For Kubernetes version <=1.27, it is recommended to match apiserver-network-proxy server & client minor release versions. With Kubernetes, this means:

Build

Please make sure you have the REGISTRY and PROJECT_ID environment variables set. For local builds these can be set to anything. For image builds these determine the location of your image. For GCE the registry should be gcr.io and PROJECT_ID should be the project you want to use the images in. Please ensure the go bin directory (usually ~/go/bin) is in your PATH.

Mockgen

The mockgen tool must be installed on your system.

Currently, we are using go.uber.org/mock/mockgen@v0.4.0

go install go.uber.org/mock/mockgen@v0.4.0

Protoc

Proto definitions are compiled with protoc. Please ensure you have protoc installed (Instructions) and the protoc-gen-go and protoc-gen-go-grpc libraries at the appropriate version.

Currently, we are using protoc-gen-go@v1.27.1

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1

Currently, we are using protoc-gen-go-grpc@v1.2

go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

Local builds

make clean
make certs
make gen
make build

Build images

make docker-build

Examples

The current examples run two actual services as well as a sample client on one end and a sample destination for requests on the other.

GRPC Client using mTLS Proxy with dial back Agent

Frontend client =HTTP over GRPC=> (:8090) proxy (:8091) <=GRPC= agent =HTTP=> http-test-server(:8000)
  |                                                               ^
  |                               Tunnel                          |
  +---------------------------------------------------------------+

GRPC+UDS Client using Proxy with dial back Agent

Frontend client =HTTP over GRPC+UDS=> (/tmp/uds-proxy) proxy (:8091) <=GRPC= agent =HTTP=> SimpleHTTPServer(:8000)
  |                                                                            ^
  |                                     Tunnel                                 |
  +----------------------------------------------------------------------------+

HTTP-Connect Client using mTLS Proxy with dial back Agent (Either curl OR test client)

Frontend client =HTTP-CONNECT=> (:8090) proxy (:8091) <=GRPC= agent =HTTP=> SimpleHTTPServer(:8000)
  |                                                             ^
  |                              Tunnel                         |
  +-------------------------------------------------------------+

Running on kubernetes

See following README.md

Running on a local kubernetes cluster with kind

See this README.md for an example that creates a local kubernetes cluster usingkind and deploys the proxy agent on a worker node and the proxy server on a control plane node.

See this README.md for a similar example that creates a kind cluster with a user-configurable number of control plane and worker nodes and optionally sideloads custom proxy agent and server images.

Clients

apiserver-network-proxy components are intended to run as standalone binaries and should not be imported as a library. Clients communicating with the network proxy can import the konnectivity-client module.