ingressutil

package module
v0.0.0-...-080488a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

README

ingressutil

Utilities for writing an ingress controller.

Currently, this package only exposes one type.

IngressRouter

  • This type can be used to monitor for changes to an ingress in Kubernetes. Use StartAutoUpdate() to trigger this.
  • IngressRouter can match an HTTP Request to a namespace, service and upstream address using MatchRequest
  • Currently, this only does exact hostname match, and path prefix. This means that wildcard hosts and path regexes aren't supported

Blog Post

Coming Soon!

Documentation

Overview

Package ingressutil provides utilities for building a kubernetes ingress controller

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostname

func GetHostname(r *http.Request) string

func SetUpstream

func SetUpstream(r *http.Request, namespace, name, addr string) *http.Request

SetUpstream forces the upstream value to be set, so that you do not need to query the map again

Types

type IngressRouter

type IngressRouter interface {
	// MatchRequest matches an HTTP Request to the namespace, service and upstream address with port to forward the HTTP request to.
	MatchRequest(r *http.Request) (namespace, name, addr string, found bool)

	// StartAutoUpdate starts listening to kube for updates. It returns a function which can be called to block until all ingresses have been read
	StartAutoUpdate(ctx context.Context, kubeClient *kubernetes.Clientset) (waitTillReady func())
}

IngressRouter monitors updates to kube ingresses, and maintains a routing table based on hostname and path. NOTE: This does not currently support wildcard domains, or regex in paths

func NewIngressRouter

func NewIngressRouter() IngressRouter

NewIngressRouter is used to create an IngressRouter

type IngressRouterStub

type IngressRouterStub struct {
	Namespace string
	Name      string
	Upstream  string
}

IngressRouterStub can be used to create an ingress router for tests or local dev. It simply returns the fields in it's properties

func (*IngressRouterStub) MatchRequest

func (ir *IngressRouterStub) MatchRequest(r *http.Request) (string, string, string, bool)

func (*IngressRouterStub) StartAutoUpdate

func (ir *IngressRouterStub) StartAutoUpdate(ctx context.Context, kubeClient *kubernetes.Clientset) func()

Directories

Path Synopsis
caddy module

Jump to

Keyboard shortcuts

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