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 New(kubeconfigPath string) (*Client, error)
- func NewFromRawKubeconfig(kubeconfig string) (*Client, error)
- func NewFromSecret(ctx context.Context, kubeClient *Client, clusterName string, namespace string) (*Client, error)
- func NewWithContext(kubeconfigPath string, contextName string) (*Client, error)
- 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) ExecInPod(ctx context.Context, podName, namespace, containerName string, ...) (string, string, error)
- func (c *Client) GetAPIServerEndpoint() string
- func (c *Client) GetClusterKubeConfig(ctx context.Context, clusterName string, clusterNamespace string) (string, error)
- func (c *Client) GetClusterName() string
- func (c *Client) GetEventsForResource(ctx context.Context, resource cr.Object, ...) (*corev1.EventList, error)
- func (c *Client) GetHelmValues(name, namespace string, values interface{}) error
- func (c *Client) GetNormalEventsForResource(ctx context.Context, resource cr.Object) (*corev1.EventList, error)
- func (c *Client) GetWarningEventsForResource(ctx context.Context, resource cr.Object) (*corev1.EventList, 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 NewFromSecret ¶ added in v0.12.0
func NewFromSecret(ctx context.Context, kubeClient *Client, clusterName string, namespace string) (*Client, error)
NewFromSecret create a new Kubernetes client from a cluster kubeconfig found in a secret on the MC. This function may return a Not Found error if the kubeconfig secret is not found on the cluster.
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) GetAPIServerEndpoint ¶ added in v0.12.0
GetAPIServerEndpoint returns the full URL for the API server
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) GetClusterName ¶ added in v0.17.0
GetClusterName returns the friendly name of the Cluster from the KubeConfig
func (*Client) GetEventsForResource ¶ added in v1.8.0
func (c *Client) GetEventsForResource(ctx context.Context, resource cr.Object, extraFieldSelectors ...fields.Selector) (*corev1.EventList, error)
GetEventsForResources returns all existing events related to the provided resource
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.