proxy

package
v0.0.0-...-b9bb202 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 22 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ProxierTypeKey = "kubernetes-port-forward"
)
View Source
const (
	// ProxyConfigMapKey the key to use in the configmap made for the proxy to
	// describe the config key
	ProxyConfigMapKey = "config"
)

Variables

This section is empty.

Functions

func CreateControllerProxy

func CreateControllerProxy(
	ctx context.Context,
	config ControllerProxyConfig,
	lbs labels.Set,
	clock clock.Clock,
	configI core.ConfigMapInterface,
	roleI rbac.RoleInterface,
	roleBindingI rbac.RoleBindingInterface,
	saI core.ServiceAccountInterface,
	secretI core.SecretInterface,
) error

CreateControllerProxy establishes the Kubernetes resources needed for proxying to a Juju controller. The end result of this function is a service account with a set of permissions that the Juju client can use for proxying to a controller.

func EnsureProxyService

func EnsureProxyService(
	ctx context.Context,
	lbs labels.Set,
	name string,
	clock clock.Clock,
	roleI rbac.RoleInterface,
	roleBindingI rbac.RoleBindingInterface,
	saI core.ServiceAccountInterface,
	secretI core.SecretInterface,
) error

EnsureProxyService ensures there is a proxy service account in existence for the namespace of a Kubernetes model.

func EnsureSecretForServiceAccount

func EnsureSecretForServiceAccount(
	ctx context.Context,
	saName string,
	objMeta meta.ObjectMeta,
	clock clock.Clock,
	secretAPI core.SecretInterface,
	saAPI core.ServiceAccountInterface,
) (*corev1.Secret, error)

EnsureSecretForServiceAccount ensures secret for the provided service created and ready to use.

func FetchTokenReadySecret

func FetchTokenReadySecret(ctx context.Context, name string, api core.SecretInterface, clock clock.Clock) (*corev1.Secret, error)

FetchTokenReadySecret fetches and returns the secret when the token field gets populated.

func WaitForProxyService

func WaitForProxyService(
	ctx context.Context,
	name string,
	saI core.ServiceAccountInterface,
) error

WaitForProxyService attempt to block the caller until the proxy service is fully provisioned within Kubernetes or until the function gives up trying to wait. This should be a very quick wait.

Types

type ControllerProxyConfig

type ControllerProxyConfig struct {
	// Name to apply to kubernetes resources created for the controller
	// proxy. This name is also used later on for discovery of the proxy config.
	Name string `json:"name"`

	// Namespace to create the proxy kubernetes resources in. This is ultimately
	// used for discovery of the proxy settings.
	Namespace string `json:"namespace"`

	// RemotePort the remote port of the service to use when proxying
	RemotePort string `json:"remote-port"`

	// TargetService the service to target for proxying
	TargetService string `json:"target-service"`
}

ControllerProxyConfig is used to configure the kubernetes resources made for the controller proxy objects.

type GetProxyConfig

type GetProxyConfig struct {
	// APIHost to expect when performing SNI with the kubernetes API.
	APIHost string

	// Namespace is the namespace the proxied targets resides in.
	Namespace string

	// RemotePort to proxy to.
	RemotePort string

	// The service in the above Namespace to proxy onto.
	Service string
}

GetProxyConfig is as config input to the GetProxy function. It describes basic properties to seed the returned Proxier object with.

type Proxier

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

func GetControllerProxy

func GetControllerProxy(
	ctx context.Context,
	name,
	apiHost string,
	configI core.ConfigMapInterface,
	saI core.ServiceAccountInterface,
	secretI core.SecretInterface,
) (*Proxier, error)

GetControllerProxy returns the proxier for the controller specified by name.

func GetProxy

func GetProxy(
	ctx context.Context,
	name string,
	config GetProxyConfig,
	saI core.ServiceAccountInterface,
	secretI core.SecretInterface,
) (*Proxier, error)

GetProxy attempts to create a Proxier from the named resources using the found service account and associated secret.

func NewProxier

func NewProxier(config ProxierConfig) *Proxier

func NewProxierFromRawConfig

func NewProxierFromRawConfig(rawConf interface{}) (*Proxier, error)

func (*Proxier) Host

func (p *Proxier) Host() string

func (*Proxier) Insecure

func (p *Proxier) Insecure()

Insecure sets the proxy to be insecure.

func (*Proxier) MarshalYAML

func (p *Proxier) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml Marshaler interface

func (*Proxier) Port

func (p *Proxier) Port() string

func (*Proxier) RawConfig

func (p *Proxier) RawConfig() (map[string]interface{}, error)

RawConfig implements Proxier RawConfig interface.

func (*Proxier) SetAPIHost

func (p *Proxier) SetAPIHost(host string)

SetAPIHost updates the proxy info to use a different host address.

func (*Proxier) Start

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

func (*Proxier) Stop

func (p *Proxier) Stop()

func (*Proxier) Type

func (p *Proxier) Type() string

type ProxierConfig

type ProxierConfig struct {
	APIHost             string `yaml:"api-host" mapstructure:"api-host"`
	CAData              string `yaml:"ca-cert" mapstructure:"ca-cert"`
	Namespace           string `yaml:"namespace" mapstructure:"namespace"`
	RemotePort          string `yaml:"remote-port" mapstructure:"remote-port"`
	Service             string `yaml:"service" mapstructure:"service"`
	ServiceAccountToken string `yaml:"service-account-token" mapstructure:"service-account-token"`
}

func NewProxierConfig

func NewProxierConfig() *ProxierConfig

Jump to

Keyboard shortcuts

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