Documentation ¶
Index ¶
- Constants
- func CreateControllerProxy(ctx context.Context, config ControllerProxyConfig, lbs labels.Set, ...) error
- func EnsureProxyService(ctx context.Context, lbs labels.Set, name string, clock clock.Clock, ...) error
- func EnsureSecretForServiceAccount(ctx context.Context, saName string, objMeta meta.ObjectMeta, clock clock.Clock, ...) (*corev1.Secret, error)
- func FetchTokenReadySecret(ctx context.Context, name string, api core.SecretInterface, clock clock.Clock) (*corev1.Secret, error)
- func WaitForProxyService(ctx context.Context, name string, saI core.ServiceAccountInterface) error
- type ControllerProxyConfig
- type GetProxyConfig
- type Proxier
- func GetControllerProxy(ctx context.Context, name, apiHost string, configI core.ConfigMapInterface, ...) (*Proxier, error)
- func GetProxy(ctx context.Context, name string, config GetProxyConfig, ...) (*Proxier, error)
- func NewProxier(config ProxierConfig) *Proxier
- func NewProxierFromRawConfig(rawConf interface{}) (*Proxier, error)
- func (p *Proxier) Host() string
- func (p *Proxier) Insecure()
- func (p *Proxier) MarshalYAML() (interface{}, error)
- func (p *Proxier) Port() string
- func (p *Proxier) RawConfig() (map[string]interface{}, error)
- func (p *Proxier) SetAPIHost(host string)
- func (p *Proxier) Start(ctx context.Context) (err error)
- func (p *Proxier) Stop()
- func (p *Proxier) Type() string
- type ProxierConfig
Constants ¶
const (
ProxierTypeKey = "kubernetes-port-forward"
)
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 (*Proxier) MarshalYAML ¶
MarshalYAML implements the yaml Marshaler interface
func (*Proxier) SetAPIHost ¶
SetAPIHost updates the proxy info to use a different host address.
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