k8s

package
v2.2.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 5 Imported by: 0

README

goutils/v2/k8s

The k8s package is a collection of utility functions designed to simplify common k8s tasks.


Table of contents


Functions

NewKubernetesClient(string, FileReaderFunc, KubernetesClientInterface)
NewKubernetesClient(string FileReaderFunc KubernetesClientInterface) *KubernetesClient error

NewKubernetesClient creates a new KubernetesClient using the provided kubeconfig path and file reader function.

Parameters:

kubeconfig: Path to the kubeconfig file to configure access to the Kubernetes API. reader: A function to read the kubeconfig file from the specified path.

Returns:

*KubernetesClient: A new KubernetesClient instance configured with the specified kubeconfig. error: An error if any issue occurs while creating the Kubernetes client.


RealKubernetesClient.NewDynamicForConfig(*rest.Config)
NewDynamicForConfig(*rest.Config) dynamic.Interface, error

NewDynamicForConfig creates a new dynamic client using the provided REST configuration.

Parameters:

config: The REST configuration to use to create the dynamic client.

Returns:

dynamic.Interface: A new dynamic client instance created using the provided REST configuration. error: An error if any issue occurs while creating the dynamic client.


RealKubernetesClient.NewForConfig(*rest.Config)
NewForConfig(*rest.Config) kubernetes.Interface, error

NewForConfig creates a new clientset using the provided REST configuration.

Parameters:

config: The REST configuration to use to create the clientset.

Returns:

*kubernetes.Clientset: A new clientset instance created using the provided REST configuration. error: An error if any issue occurs while creating the clientset.


RealKubernetesClient.RESTConfigFromKubeConfig([]byte)
RESTConfigFromKubeConfig([]byte) *rest.Config, error

RESTConfigFromKubeConfig creates a REST configuration from the provided kubeconfig data.

Parameters:

configData: The kubeconfig data to use to create the REST configuration.

Returns:

*rest.Config: A new REST configuration instance created using the provided kubeconfig data. error: An error if any issue occurs while creating the REST configuration.


Installation

To use the goutils/v2/k8s package, you first need to install it. Follow the steps below to install via go get.

go get github.com/l50/goutils/v2/k8s

Usage

After installation, you can import the package in your Go project using the following import statement:

import "github.com/l50/goutils/v2/k8s"

Tests

To ensure the package is working correctly, run the following command to execute the tests for goutils/v2/k8s:

go test -v

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileReaderFunc added in v2.2.6

type FileReaderFunc func(string) ([]byte, error)

FileReaderFunc defines a function signature for reading a file from a given path.

type KubernetesClient

type KubernetesClient struct {
	Clientset     kubernetes.Interface
	DynamicClient dynamic.Interface
	Config        *rest.Config
}

KubernetesClient wraps a clientset to interact with Kubernetes APIs.

**Attributes:**

Clientset: The clientset interface provided by client-go to interact with Kubernetes resources. DynamicClient: The dynamic client interface provided by client-go to interact with Kubernetes resources. Config: The kubeconfig configuration used to create the clientset and dynamic client.

func NewKubernetesClient

func NewKubernetesClient(kubeconfig string, reader FileReaderFunc, client KubernetesClientInterface) (*KubernetesClient, error)

NewKubernetesClient creates a new KubernetesClient using the provided kubeconfig path and file reader function.

**Parameters:**

kubeconfig: Path to the kubeconfig file to configure access to the Kubernetes API. reader: A function to read the kubeconfig file from the specified path.

**Returns:**

*KubernetesClient: A new KubernetesClient instance configured with the specified kubeconfig. error: An error if any issue occurs while creating the Kubernetes client.

type KubernetesClientInterface added in v2.2.6

type KubernetesClientInterface interface {
	NewForConfig(config *rest.Config) (kubernetes.Interface, error)
	NewDynamicForConfig(config *rest.Config) (dynamic.Interface, error)
	RESTConfigFromKubeConfig(configData []byte) (*rest.Config, error)
}

KubernetesClientInterface defines the interface for the KubernetesClient.

**Methods:**

NewForConfig: Creates a new clientset using the provided REST configuration. NewDynamicForConfig: Creates a new dynamic client using the provided REST configuration. RESTConfigFromKubeConfig: Creates a REST configuration from the provided kubeconfig data.

type RealKubernetesClient added in v2.2.6

type RealKubernetesClient struct{}

RealKubernetesClient implements the KubernetesClientInterface using the client-go library.

func (*RealKubernetesClient) NewDynamicForConfig added in v2.2.6

func (r *RealKubernetesClient) NewDynamicForConfig(config *rest.Config) (dynamic.Interface, error)

NewDynamicForConfig creates a new dynamic client using the provided REST configuration.

**Parameters:**

config: The REST configuration to use to create the dynamic client.

**Returns:**

dynamic.Interface: A new dynamic client instance created using the provided REST configuration. error: An error if any issue occurs while creating the dynamic client.

func (*RealKubernetesClient) NewForConfig added in v2.2.6

func (r *RealKubernetesClient) NewForConfig(config *rest.Config) (kubernetes.Interface, error)

NewForConfig creates a new clientset using the provided REST configuration.

**Parameters:**

config: The REST configuration to use to create the clientset.

**Returns:**

*kubernetes.Clientset: A new clientset instance created using the provided REST configuration. error: An error if any issue occurs while creating the clientset.

func (*RealKubernetesClient) RESTConfigFromKubeConfig added in v2.2.6

func (r *RealKubernetesClient) RESTConfigFromKubeConfig(configData []byte) (*rest.Config, error)

RESTConfigFromKubeConfig creates a REST configuration from the provided kubeconfig data.

**Parameters:**

configData: The kubeconfig data to use to create the REST configuration.

**Returns:**

*rest.Config: A new REST configuration instance created using the provided kubeconfig data. error: An error if any issue occurs while creating the REST configuration.

Jump to

Keyboard shortcuts

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