proxy

package
v0.0.0-...-6780f68 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPErrs = map[int]*template.Template{}

HTTPErrs maps HTTP error codes to HTNL error pages.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	K8s     *k8s.K8S
	Port    int
	SSLCert string
	SSLPort int
	Timeout int
	// contains filtered or unexported fields
}

Proxy holds configuration data and methods for running the kubernetes proxy service.

func New

func New(
	port int,
	sslCert string,
	sslPort int,
	timeout int,
) (*Proxy, error)

New initializes the proxy service and returns a pointer to the service instance. If an error is generated while initializing the kubernetes service scanner an error will be returned.

func (*Proxy) AddService

func (proxy *Proxy) AddService(service apiv1.Service) error

AddService adds a service to the passthrough map.

func (*Proxy) Map

func (proxy *Proxy) Map() map[string]apiv1.Service

Map returns a map of the current kubernetes services.

func (*Proxy) Pass

func (proxy *Proxy) Pass(w http.ResponseWriter, r *http.Request)

Pass passes HTTP traffic through to the requested service.

func (*Proxy) RemoveService

func (proxy *Proxy) RemoveService(service apiv1.Service) error

RemoveService removes a service from the map.

func (*Proxy) Start

func (proxy *Proxy) Start() chan error

Start starts the proxy services.

func (*Proxy) Stop

func (proxy *Proxy) Stop()

Stop causes the proxy to shutdown. In a kubernetes cluster this will cause the container to be restarted.

func (*Proxy) UpdateServices

func (proxy *Proxy) UpdateServices(delta k8s.ChangeSet)

UpdateServices processes changes to the set of available services in the cluster.

func (*Proxy) Wait

func (proxy *Proxy) Wait()

Wait will block until the k8s services are ready

type ResponseWriter

type ResponseWriter struct {
	// contains filtered or unexported fields
}

ResponseWriter implements http.ResponseWriter and is used to intercept the responses from the proxied services to capture and inspect 502 and 503 errors.

func (*ResponseWriter) Header

func (w *ResponseWriter) Header() http.Header

Header implements http.ResponseWriter and captures response header data.

func (*ResponseWriter) Status

func (w *ResponseWriter) Status() int

Status returns the current response status code.

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(data []byte) (int, error)

Write implements http.ResponseWriter and captures response body data.

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(code int)

WriteHeader implements http.ResponseWriter and captures response status codes.

type ReverseProxy

type ReverseProxy struct {
	Active    bool
	Available time.Time
	Service   string
	URL       *url.URL
	// contains filtered or unexported fields
}

ReverseProxy defines a proxy to a service.

func NewReverseProxy

func NewReverseProxy(scheme string, service apiv1.Service, port int32) (*ReverseProxy, error)

NewReverseProxy creates a new reverse proxy to forward traffic through.

func (*ReverseProxy) ServeHTTP

func (rp *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP starts the HTTP server for this proxy.

func (*ReverseProxy) String

func (rp *ReverseProxy) String() string

String implements stringer. Return the URL for this proxy.

type Service

type Service struct {
	Name   string
	Port   int32
	Scheme string
	Proxy  *ReverseProxy
}

Service defines a k8s service proxy.

Jump to

Keyboard shortcuts

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