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 ¶
- type Client
- func (c *Client) CheckConnection() error
- func (c *Client) CreateOrUpdate(ctx context.Context, obj cr.Object) error
- func (c *Client) DeleteApp(ctx context.Context, app application.Application) error
- func (c *Client) DeployApp(ctx context.Context, app application.Application) error
- func (c *Client) DeployAppManifests(ctx context.Context, appCR *applicationv1alpha1.App, ...) error
- func (c *Client) GetClusterKubeConfig(ctx context.Context, clusterName string, clusterNamespace string) (string, error)
- func (c *Client) GetHelmValues(name, namespace string, values interface{}) error
- type DoesNotHaveLabels
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client extends the client from controller-runtime
func New ¶
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 ¶
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
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 ¶
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) CreateOrUpdate ¶ added in v0.1.0
CreateOrUpdate attempts first to create the object given but if an AlreadyExists error is returned it instead updates the existing resource.
func (*Client) DeleteApp ¶ added in v0.7.0
func (c *Client) DeleteApp(ctx context.Context, app application.Application) error
DeleteApp removes an App CR and its ConfigMap from the cluster
func (*Client) DeployApp ¶ added in v0.6.0
func (c *Client) DeployApp(ctx context.Context, app application.Application) error
DeployApp takes an Application and applies its manifests to the cluster in the correct order, ensuring the ConfigMap is made available first.
func (*Client) DeployAppManifests ¶ added in v0.6.0
func (c *Client) DeployAppManifests(ctx context.Context, appCR *applicationv1alpha1.App, configMap *corev1.ConfigMap) error
DeployAppManifests takes an applications App CR and ConfigMap manifests and ensures they are applied in the correct order, with the ConfigMap being added first.
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.
func (*Client) GetHelmValues ¶ added in v0.0.10
GetHelmValues retrieves the helm values of a Helm release in the provided name and namespace and it will Unmarshal the values into the provided values struct.
type DoesNotHaveLabels ¶ added in v0.0.14
type DoesNotHaveLabels []string
DoesNotHaveLabels filters the list/delete operation for objects that don't have the given set of labels.
func (DoesNotHaveLabels) ApplyToDeleteAllOf ¶ added in v0.0.14
func (m DoesNotHaveLabels) ApplyToDeleteAllOf(opts *cr.DeleteAllOfOptions)
ApplyToDeleteAllOf applies this configuration to the given an List options.
func (DoesNotHaveLabels) ApplyToList ¶ added in v0.0.14
func (m DoesNotHaveLabels) ApplyToList(opts *cr.ListOptions)
ApplyToList applies this configuration to the given list options.