kube-service-exposer

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2023 License: MPL-2.0

README

kube-service-exposer

kube-service-exposer is a simple TCP proxy that exposes a Kubernetes service on a port defined by a specific annotation within the given set of host CIDRs.

Installation

Download the installation manifest:

kubectl apply -f https://raw.githubusercontent.com/siderolabs/kube-service-exposer/main/deploy/kube-service-exposer.yaml

Optionally, download and customize the args passed to the container before applying:

args:
  - --debug=true
  - --annotation-key=my-annotation-key/port
  - --bind-cidrs=172.20.0.0/24

Multiple bind CIDRs can be specified by separating them with commas. If --bind-cidrs are specified, the IP addresses on the hosts will be matched against these CIDRs, and the Service will be exposed only on the matching addresses.


## Usage

Add the annotation `kube-service-exposer.sidero.dev/port` to the service you want to expose:

```yaml
apiVersion: v1
kind: Service
metadata:
  name: nginx
  annotations:
    kube-service-exposer.sidero.dev/port: "12345"
spec:
  selector:
    app: nginx
  ports:
    - name: http
      port: 80
      protocol: TCP

The service will be exposed on port 12345 on all nodes, on the IP addresses within the CIDRs specified (all addresses by default).

Note: kube-service-exposer only works with TCP. Services without any TCP ports will be ignored. If a Service contains multiple TCP ports, kube-service-exposer pick the first one.

Directories

Path Synopsis
cmd
kube-service-exposer
Package main is the entry point for kube-service-exposer.
Package main is the entry point for kube-service-exposer.
internal
cidrs
Package cidrs provides functions for working with CIDRs.
Package cidrs provides functions for working with CIDRs.
debug
Package debug provides a way to check if the build is a debug build.
Package debug provides a way to check if the build is a debug build.
exposer
Package exposer implements the Exposer controller.
Package exposer implements the Exposer controller.
ip
Package ip contains logic for managing IP addresses.
Package ip contains logic for managing IP addresses.
memoizer
Package memoizer provides a container for a value that is initialized and cached lazily.
Package memoizer provides a container for a value that is initialized and cached lazily.
reconciler
Package reconciler implements a reconciler for reconciling Service resources.
Package reconciler implements a reconciler for reconciling Service resources.
service
Package service contains logic for managing Service resources.
Package service contains logic for managing Service resources.
version
Package version provides version information.
Package version provides version information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL