Documentation ¶
Overview ¶
Package client provides utilities for creating and managing Kubernetes clients.
This package includes functions and types for configuring and creating Kubernetes clients tailored to specific requirements, such as accessing AWS EKS clusters with appropriate authentication.
Example usage:
specify the opts with Kubernetes Cluster type, such as EKSClientOption, otherwise the default local client will be created. ¶
* for EKS setup:
client, err := client.New(&NewClientInput{ClusterType: ClusterTypeEKS}, EKSClientOption(ctx, "test-cluster-01", "us-east-1")) if err != nil { fmt.Printf("failed to create client: %v", err) return }
* for localhost setup:
client, err := client.New(&NewClientInput{ClusterType: ClusterTypeLOCAL, KuberKubernetesConfigPath: *configFilePath})
Index ¶
Constants ¶
const ( ClusterTypeEKS = "eks" ClusterTypeLOCAL = "local" )
ClusterTypes must match with the cmd/root.go kubernetes-type flag
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { // ClientSet returns the rest clientset to be used. ClientSet() kubernetes.Interface // ControllerClient returns the controller-runtime client to be used. ControllerClient() *controllerClient.Client // Config returns the rest.Config to be used. Config() *rest.Config }
func New ¶
func New(input *NewClientInput, opts ...NewClientOption) (Interface, error)
New creates new Kubernetes clients with the specified options.
type NewClientInput ¶
type NewClientOption ¶
type NewClientOption func(*NewClientInput)
func EKSClientOption ¶
func EKSClientOption(ctx context.Context, clusterID string) NewClientOption
EKSClientOption sets up a Kubernetes client for accessing an AWS EKS cluster.
This function assumes that the AWS SDK configuration can obtain the necessary credentials from the environment. This is the default behavior of the AWS SDK. It is recommended to use IAM Roles for Service Accounts (IRSA) for EKS clusters to grant IAM roles to the pods. Using IRSA provides fine-grained permissions and security best practices. If IRSA is not used, the pod will attempt to use the instance credentials and generate an STS token for accessing the EKS cluster.
Parameters:
ctx: the context for the AWS SDK client.
clusterID: the name of the EKS cluster.
type TokenRefresher ¶
func (*TokenRefresher) WrapTransport ¶
func (t *TokenRefresher) WrapTransport(rt http.RoundTripper) http.RoundTripper