Documentation
¶
Index ¶
- Constants
- Variables
- func IsLive(ctx context.Context, client connection.KubeClient, loopParams ...retry.Params) error
- func Stop(client connection.KubeClient, full bool)
- type ClientLoopParams
- type Config
- type ErrorKubernetesClient
- func (i *ErrorKubernetesClient) APIResource(apiVersion, kind string) (*metav1.APIResource, error)
- func (i *ErrorKubernetesClient) APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
- func (i *ErrorKubernetesClient) Dynamic() dynamic.Interface
- func (i *ErrorKubernetesClient) GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
- func (i *ErrorKubernetesClient) InvalidateDiscoveryCache()
- type Flags
- type FlagsParser
- type InitOpt
- type InitOpts
- type KubernetesClient
- func (k *KubernetesClient) Init(params *Config, opts ...InitOpt) error
- func (k *KubernetesClient) InitContext(ctx context.Context, params *Config, opts ...InitOpt) error
- func (k *KubernetesClient) NodeInterfaceAsSSHClient() connection.SSHClient
- func (k *KubernetesClient) StartKubernetesProxy(ctx context.Context, opts *InitOpts) (string, error)
- func (k *KubernetesClient) WithLoopsParams(p ClientLoopParams) *KubernetesClient
- func (k *KubernetesClient) WithNodeInterface(client connection.Interface) *KubernetesClient
Constants ¶
const ( ConfigEnv = "KUBE_CONFIG" ConfigContextEnv = "KUBE_CONFIG_CONTEXT" ClientFromClusterEnv = "KUBE_CLIENT_FROM_CLUSTER" )
Variables ¶
var (
ErrStoppedKubeClient = fmt.Errorf("use stopped kube client")
)
Functions ¶
func IsLive ¶
func IsLive(ctx context.Context, client connection.KubeClient, loopParams ...retry.Params) error
IsLive check that client is live (can connect to API) you can pass retry loop paras as first variadic option if not pass use 2 attempts with 2 seconds wait
func Stop ¶
func Stop(client connection.KubeClient, full bool)
Stop pass full for fully stop client for example if use over ssh full stop client also with stop proxy it is safe for call with nil client
Types ¶
type ClientLoopParams ¶
type Config ¶
type Config struct {
KubeConfig string
KubeConfigContext string
KubeConfigInCluster bool
LocalKubeClient bool
RestConfig *rest.Config
}
func (*Config) IsConflict ¶
type ErrorKubernetesClient ¶
type ErrorKubernetesClient struct {
kubernetes.Interface
// contains filtered or unexported fields
}
func NewErrorKubernetesClient ¶
func NewErrorKubernetesClient(errToReturn error) (*ErrorKubernetesClient, error)
func (*ErrorKubernetesClient) APIResource ¶
func (i *ErrorKubernetesClient) APIResource(apiVersion, kind string) (*metav1.APIResource, error)
func (*ErrorKubernetesClient) APIResourceList ¶
func (i *ErrorKubernetesClient) APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
func (*ErrorKubernetesClient) Dynamic ¶
func (i *ErrorKubernetesClient) Dynamic() dynamic.Interface
func (*ErrorKubernetesClient) GroupVersionResource ¶
func (i *ErrorKubernetesClient) GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
func (*ErrorKubernetesClient) InvalidateDiscoveryCache ¶
func (i *ErrorKubernetesClient) InvalidateDiscoveryCache()
type Flags ¶
type Flags struct {
Config
// contains filtered or unexported fields
}
func (*Flags) ExtractConfig ¶ added in v0.2.0
ExtractConfig if args not passed uses os.Args
func (*Flags) IsConflictBetweenFlags ¶
func (*Flags) RewriteFromEnvs ¶
type FlagsParser ¶
type FlagsParser struct {
*baseflags.BaseParser
}
func NewFlagsParser ¶
func NewFlagsParser(sett settings.Settings) *FlagsParser
NewFlagsParser init FlagsParser prefix will trim right all _ ang - symbols and spaces left and right from settings.Settings EnvsPrefix By default parser add _ after prefix for all env vars
func (*FlagsParser) ExtractConfigAfterParse ¶
func (p *FlagsParser) ExtractConfigAfterParse(flags *Flags) (*Config, error)
ExtractConfigAfterParse extract ConnectionConfig from flags should call after InitFlags and flag.Parse or flag.FlagSet.Parse if flag.FlagSet in Flags is not parse returns error
func (*FlagsParser) InitFlags ¶
func (p *FlagsParser) InitFlags(set *flag.FlagSet) (*Flags, error)
InitFlags init flag.FlagSet and return struct with flags where flag.FlagSet parsed Flags contains copy of set. For parse use Flags.Parse if set is parsed returns error
func (*FlagsParser) ParseFlagsAndExtractConfig ¶
func (p *FlagsParser) ParseFlagsAndExtractConfig(arguments []string, set *flag.FlagSet) (*Config, error)
ParseFlagsAndExtractConfig initialize, parse and extract ConnectionConfig from flags set flag.FlagSet can be nil. If nil, func initialize new flag.FlagSet if arguments is nil extract arguments from os.Args
type InitOpt ¶
type InitOpt func(*InitOpts)
func InitWithLocalPort ¶
func InitWithNoStartKubeProxy ¶
func InitWithNoStartKubeProxy() InitOpt
type KubernetesClient ¶
type KubernetesClient struct {
connection.KubeClient
NodeInterface connection.Interface
KubeProxy connection.KubeProxy
// contains filtered or unexported fields
}
KubernetesClient connects to kubernetes API server through ssh tunnel and kubectl proxy.
func NewFakeKubernetesClient ¶
func NewFakeKubernetesClient() *KubernetesClient
func NewFakeKubernetesClientWithListGVR ¶
func NewFakeKubernetesClientWithListGVR(gvr map[schema.GroupVersionResource]string) *KubernetesClient
func NewKubernetesClient ¶
func NewKubernetesClient(sett settings.Settings) *KubernetesClient
func (*KubernetesClient) Init ¶
func (k *KubernetesClient) Init(params *Config, opts ...InitOpt) error
Init initializes kubernetes client Deprecated: use InitContext Warning! use InitWithNoStartKubeProxy for only testing purposes
func (*KubernetesClient) InitContext ¶
InitContext Warning! use InitWithNoStartKubeProxy for only testing purposes
func (*KubernetesClient) NodeInterfaceAsSSHClient ¶
func (k *KubernetesClient) NodeInterfaceAsSSHClient() connection.SSHClient
func (*KubernetesClient) StartKubernetesProxy ¶
func (k *KubernetesClient) StartKubernetesProxy(ctx context.Context, opts *InitOpts) (string, error)
StartKubernetesProxy initializes kubectl-proxy on remote host and establishes ssh tunnel to it
func (*KubernetesClient) WithLoopsParams ¶
func (k *KubernetesClient) WithLoopsParams(p ClientLoopParams) *KubernetesClient
func (*KubernetesClient) WithNodeInterface ¶
func (k *KubernetesClient) WithNodeInterface(client connection.Interface) *KubernetesClient