proxier

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright 2020 Jared Allard

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const PodKind = "Pod"

Variables

This section is empty.

Functions

func NewPortForwarder

func NewPortForwarder(ctx context.Context, k kubernetes.Interface,
	r *rest.Config, log logrus.FieldLogger, opts *ProxyOpts) (chan<- PortForwardRequest, <-chan struct{}, *worker, error)

NewPortForwarder creates a new port-forward worker that handles creating port-forwards and destroying port-forwards.

Types

type CreatePortForwardRequest

type CreatePortForwardRequest struct {
	// Service is the service this port-forward implements.
	Service ServiceInfo

	// Hostnames are the DNS entries to inject into our host's DNS
	// for this port-forward. This will be attached to the IP that
	// is created for this service.
	Hostnames []string

	// Ports are the ports this port-forward exposes
	Ports []string

	// Endpoint is the specific pod to use for this service.
	Endpoint *PodInfo

	// Recreate specifies if this should be recreated if it already
	// exists
	Recreate       bool
	RecreateReason string
}

CreatePortForwardRequest is a request to create port-forward

type DeletePortForwardRequest

type DeletePortForwardRequest struct {
	// Service is the service that should delete being port-forwarded
	Service ServiceInfo
}

DeletePortForwardRequest is a request to delete a port-forward

type PodInfo

type PodInfo struct {
	// Name is the name of this pod
	Name string

	// Namespace is the namespace this pod is in
	Namespace string
}

func (*PodInfo) Key

func (s *PodInfo) Key() string

type PortForwardConnection

type PortForwardConnection struct {
	Service      ServiceInfo
	Pod          PodInfo
	Status       PortForwardStatus
	StatusReason string

	// IP that this port-forward allocates
	IP        net.IP
	Hostnames []string

	// Ports is a local -> remote port list
	Ports []string
	// contains filtered or unexported fields
}

PortForwardConnection is a port-forward that is managed by the port-forward worker.

type PortForwardRequest

type PortForwardRequest struct {
	DeletePortForwardRequest *DeletePortForwardRequest
	CreatePortForwardRequest *CreatePortForwardRequest
}

PortForwardRequest is a port-forward request, the non-nil struct is the type of request this is. There should only ever be one non-nil struct.

type PortForwardStatus

type PortForwardStatus string
var (
	PortForwardStatusRunning    PortForwardStatus = "running"
	PortForwardStatusRecreating PortForwardStatus = "recreating"
	PortForwardStatusWaiting    PortForwardStatus = "waiting"
)

type Proxier

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

Proxier handles creating an maintaining proxies to a remote Kubernetes service

func NewProxier

func NewProxier(ctx context.Context, k kubernetes.Interface, kconf *rest.Config, log logrus.FieldLogger, opts *ProxyOpts) (*Proxier, error)

NewProxier creates a new proxier instance

func (*Proxier) IsStable added in v1.12.0

func (p *Proxier) IsStable() bool

IsStable is a pass-through function to *worker.isStable. This is mostly to determine if the initial queue has been drained by checking if the worker that the proxier is using has created, deleted, or updated a port-forward in the last 2 seconds.

func (*Proxier) List

func (p *Proxier) List(ctx context.Context) ([]ServiceStatus, error)

func (*Proxier) Start

func (p *Proxier) Start(ctx context.Context) error

Start starts the proxier TODO: replace raw cluster domain with options struct, maybe also move into NewProxier

type ProxyOpts

type ProxyOpts struct {
	ClusterDomain string
	IPCidr        string
}

type ServiceInfo

type ServiceInfo struct {
	// Name is the name of this service
	Name string

	// Namespace is the namespace of this service
	Namespace string
}

func (*ServiceInfo) Key

func (s *ServiceInfo) Key() string

type ServiceStatus

type ServiceStatus struct {
	ServiceInfo ServiceInfo

	Endpoint PodInfo

	// Statuses is dependent on the number of tunnels that exist for this
	// connection. Generally this is one, since a service is usually one
	// connection. Currently only one is supported, but in the future
	// certain services will have more than one.
	Statuses []PortForwardStatus

	// Reason is the reason that this service is in this status.
	// This is generally only set for services that are in a
	// non-running state.
	Reason string

	// IP is the IP address of this tunnel
	IP string

	// Ports are the ports this service is exposing
	Ports []string
}

Jump to

Keyboard shortcuts

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