kube

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNamespace = "default"
	DefaultLocalPort = "7150"
)

Variables

This section is empty.

Functions

func BuildDefaultPortMap

func BuildDefaultPortMap(remotePort int32) []string

only require remoteport as input

func WithConfigPath

func WithConfigPath(path string) func(c *Client)

WithConfigPath configures the KubeClient with a predetermined path for the 'kubeconfig' file This avoids the usual searches done within findKubeConfig

func WithNamespace

func WithNamespace(namespace string) func(c *Client)

WithNamespace configures the KubeClient with a custom default namespace

Types

type ApplyOptions

type ApplyOptions struct {
	Name          string
	GetOptions    *metav1.GetOptions
	CreateOptions *metav1.CreateOptions
	UpdateOptions *metav1.UpdateOptions
}

type Client added in v1.0.1

type Client struct {
	// ConfigPath is the configuration file path for which the current client(-set) was created
	ConfigPath string

	// Executor is the connection between local and remote IO streams
	Executor RemoteExecutor

	// PortForwarder is the implementation for the port-forward functionality
	PortForwarder PortForwarder

	// Config is the rest.Config for which the client was built
	Config *rest.Config

	// Client is the embedded Kubernetes ClientSet
	Client *kubernetes.Clientset

	// flags are the Kubernetes-specific flags which will be injected into the CLI
	Flags *genericclioptions.ConfigFlags
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Opt) (*Client, error)

NewClient instantiates a new KubeClient with a configured and embedded Clientset

func (*Client) Apply added in v1.0.1

func (c *Client) Apply(schema schema.GroupVersionResource, resource *unstructured.Unstructured, opts *ApplyOptions) error

func (*Client) ConfigMap added in v1.0.1

func (c *Client) ConfigMap(namespace, name string, opts metav1.GetOptions) (*corev1.ConfigMap, error)

func (*Client) ConfigMaps added in v1.0.1

func (c *Client) ConfigMaps(namespace string, opts metav1.ListOptions) ([]corev1.ConfigMap, error)

func (*Client) CreateDeployment added in v1.0.1

func (c *Client) CreateDeployment(namespace string, deployment *appsv1.Deployment, opts metav1.CreateOptions) error

func (*Client) CreateIngress added in v1.0.1

func (c *Client) CreateIngress(namespace string, ingress *networkingv1.Ingress, opts metav1.CreateOptions) error

func (*Client) CreatePod added in v1.0.1

func (c *Client) CreatePod(namespace string, pod *corev1.Pod, opts metav1.CreateOptions) error

func (*Client) CreateSecret added in v1.0.1

func (c *Client) CreateSecret(namespace string, secret *corev1.Secret, opts metav1.CreateOptions) error

func (*Client) CreateService added in v1.0.1

func (c *Client) CreateService(namespace string, service *corev1.Service, opts metav1.CreateOptions) error

func (*Client) Exec added in v1.0.1

func (c *Client) Exec(command string, pod corev1.Pod) (string, string, error)

Exec executes a command within the container of a specific Pod in the current namespace configured for the client. If another namespace is required the ExecInNamespace helper provides an escape hatch

func (*Client) Ingresses added in v1.0.1

func (c *Client) Ingresses(namespace string, opts metav1.ListOptions) ([]networkingv1.Ingress, error)

func (*Client) Namespaces added in v1.0.1

func (c *Client) Namespaces(opts metav1.ListOptions) ([]corev1.Namespace, error)

func (*Client) Pods added in v1.0.1

func (c *Client) Pods(namespace string, opts metav1.ListOptions) ([]corev1.Pod, error)

func (*Client) PortForward added in v1.0.1

func (c *Client) PortForward(ctx context.Context, pod corev1.Pod) error

PortForward port-forwards a remote port of a Kubernetes container to the local machine

func (*Client) Secrets added in v1.0.1

func (c *Client) Secrets(namespace string, opts metav1.ListOptions) ([]corev1.Secret, error)

func (*Client) Service added in v1.0.1

func (c *Client) Service(namespace, name string, opts metav1.GetOptions) (*corev1.Service, error)

func (*Client) Services added in v1.0.1

func (c *Client) Services(namespace string, opts metav1.ListOptions) ([]corev1.Service, error)

type DefaultPortForwarder

type DefaultPortForwarder struct{}

func (*DefaultPortForwarder) ForwardPorts

func (*DefaultPortForwarder) ForwardPorts(method string, restConfig *rest.Config, url *url.URL, ports []string, stopChan,
	readyChan chan struct{}) error

type DefaultRemoteExecutor

type DefaultRemoteExecutor struct{}

DefaultRemoteExecutor is the standard implementation of remote command execution

func (*DefaultRemoteExecutor) Execute

func (*DefaultRemoteExecutor) Execute(url *url.URL, restConfig *rest.Config, stdout, stderr io.Writer) error

Execute implements the RemoteExecutor interface for the DefaultRemoteExecutor

type Opt

type Opt func(c *Client)

Opt represents a configuration option for the KubeClient

type PortForwarder

type PortForwarder interface {
	ForwardPorts(method string, restConfig *rest.Config, url *url.URL, ports []string, stopChan,
		readyChan chan struct{}) error
}

type RemoteExecutor

type RemoteExecutor interface {
	Execute(url *url.URL, restConfig *rest.Config, stdout, stderr io.Writer) error
}

RemoteExecutor defines the interface accepted by the Exec command - provided for test stubbing

Jump to

Keyboard shortcuts

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