client

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Overview

Package client ships helper functions for building and using Kubernetes client.

Index

Constants

View Source
const (
	// PollInterval defines how long we wait before next attempt while waiting for the objects.
	PollInterval = 5 * time.Second

	// RetryTimeout defines how long we wait before timing out waiting for the objects.
	RetryTimeout = 10 * time.Minute
)

Variables

This section is empty.

Functions

func NewClientset

func NewClientset(data []byte) (*kubernetes.Clientset, error)

NewClientset returns Kubernetes clientset object from kubeconfig string.

Types

type Client

type Client interface {
	// CheckNodeExists returns a function, which checks, if given node exists.
	CheckNodeExists(name string) func() (bool, error)

	// CheckNodeReady returns a function, which checks, if given node is ready.
	CheckNodeReady(name string) func() (bool, error)

	// WaitForNode waits, until Node object shows up in the API.
	WaitForNode(name string) error

	// WaitForNodeReady waits, until Node object becomes ready.
	WaitForNodeReady(name string) error

	// LabelNode patches Node object to set given labels on it.
	LabelNode(name string, labels map[string]string) error

	// PingWait waits until API server becomes available.
	PingWait(pollInterval, retryTimeout time.Duration) error
}

Client defines exported capabilities of Flexkube k8s client.

func NewClient

func NewClient(kubeconfig []byte) (Client, error)

NewClient takes content of kubeconfig file as an argument and returns flexkube kubernetes client, which implements bunch of helper methods for Kubernetes API.

type Config

type Config struct {
	// Server is a Kubernetes API server address.
	//
	// Example value: 'k8s.example.com:6443'.
	//
	// This field is required.
	Server string `json:"server,omitempty"`

	// CACertificate stores PEM encoded X.509 CA certificate, which was used
	// to sign Kubernetes API server certificate.
	//
	// This field is required.
	CACertificate types.Certificate `json:"caCertificate,omitempty"`

	// ClientCertificate stores PEM encoded X.509 client certificate, which will
	// be used for authentication and authorization to Kubernetes API server.
	//
	// This field is optional if Token field is populated.
	ClientCertificate types.Certificate `json:"clientCertificate,omitempty"`

	// ClientCertificate stores PEM encoded private key in PKCS1, PKCS8 or EC formats,
	// which will be used for authentication and authorization to Kubernetes API server.
	// Key must match configured ClientCertificate.
	//
	// This field is optional if Token field is populated.
	ClientKey types.PrivateKey `json:"clientKey,omitempty"`

	// Token stores Kubernetes token, which will be used for authentication and authrization
	// to Kubernetes API server. Usually used by kubelet to perform TLS bootstrapping.
	Token string `json:"token,omitempty"`
}

Config is a simplified version of kubeconfig.

func (*Config) ToYAMLString

func (c *Config) ToYAMLString() (string, error)

ToYAMLString converts given configuration to kubeconfig format as YAML text.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates Config struct.

type Getter

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

Getter implements k8s.io/cli-runtime/pkg/genericclioptions.RESTClientGetter interface.

func NewGetter

func NewGetter(data []byte) (*Getter, error)

NewGetter takes content of kubeconfig file as an argument and returns implementation of RESTClientGetter k8s interface.

func (*Getter) ToDiscoveryClient

func (c *Getter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)

ToDiscoveryClient is part of k8s.io/cli-runtime/pkg/genericclioptions.RESTClientGetter interface.

func (*Getter) ToRESTConfig

func (c *Getter) ToRESTConfig() (*rest.Config, error)

ToRESTConfig is part of k8s.io/cli-runtime/pkg/genericclioptions.RESTClientGetter interface.

func (*Getter) ToRESTMapper

func (c *Getter) ToRESTMapper() (meta.RESTMapper, error)

ToRESTMapper is part of k8s.io/cli-runtime/pkg/genericclioptions.RESTClientGetter interface.

func (*Getter) ToRawKubeConfigLoader

func (c *Getter) ToRawKubeConfigLoader() clientcmd.ClientConfig

ToRawKubeConfigLoader is part of k8s.io/cli-runtime/pkg/genericclioptions.RESTClientGetter interface.

Jump to

Keyboard shortcuts

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