client

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Overview

package client provides a thin wrapper around the controller-runtime client.

It provides standard operations (such as Get, Patch, Delete) for interacting with a Kubernetes cluster as well some helper functions for making it easier to perform certain operations.

Note: The client when created is set to use lazy discovery and doesn't pre-cache CRDs from the cluster. This is to allow for creation of a Client instance for a Workload Cluster before the api-server is ready by using the kubeconfig available from the Management Cluster secret.

For the full list of available functions make sure to also check cr.Client for the controller-runtime methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	cr.Client
}

Client extends the client from controller-runtime

func New

func New(kubeconfigPath string) (*Client, error)

New creates a new Kubernetes client for the provided kubeconfig file

The client is an extension of the client from controller-runtime and provides some additional helper functions. The creation of the client doesn't confirm connectivity to the cluster and REST discovery is set to lazy discovery so the client can be created while the cluster is still being set up.

func NewFromRawKubeconfig

func NewFromRawKubeconfig(kubeconfig string) (*Client, error)

NewFromRawKubeconfig is like New but takes in the string contents of a Kubeconfig and creates a client for it

The client is an extension of the client from controller-runtime and provides some additional helper functions. The creation of the client doesn't confirm connectivity to the cluster and REST discovery is set to lazy discovery so the client can be created while the cluster is still being set up.

func NewWithContext added in v0.0.5

func NewWithContext(kubeconfigPath string, contextName string) (*Client, error)

NewWithContext creates a new Kubernetes client for the provided kubeconfig file and changes the current context to the provided value

The client is an extension of the client from controller-runtime and provides some additional helper functions. The creation of the client doesn't confirm connectivity to the cluster and REST discovery is set to lazy discovery so the client can be created while the cluster is still being set up.

func (*Client) CheckConnection

func (c *Client) CheckConnection() error

CheckConnection attempts to connect to the clusters API server and returns an error if not successful. A successful connection is defined as a valid response from the api-server but not necessarily a success response. For example, both a "Not Found" and a "Forbidden" response from the server is still a valid, working connection to the cluster and doesn't cause this function to return an error.

func (*Client) GetClusterKubeConfig added in v0.0.2

func (c *Client) GetClusterKubeConfig(ctx context.Context, clusterName string, clusterNamespace string) (string, error)

GetClusterKubeConfig retrieves the Kubeconfig from the secret associated with the provided cluster name.

The server hostname used in the kubeconfig is modified to use the DNS name if it is found to be using an IP address.

Jump to

Keyboard shortcuts

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