Documentation ¶
Index ¶
- Constants
- func FormatWorkloadClusterKubeconfigFilename(clusterName string) string
- func FromClusterName(clusterName string) string
- func FromEnvironment() string
- func ResolveAndValidateFilename(flagValue, clusterName string) (string, error)
- func ResolveFilename(flagValue, clusterName string) string
- func ValidateFilename(filename string) error
- func ValidateKubeconfigPath(clusterName string, parentFolders ...string) error
- type ClientFactory
- type ClusterAPIKubeconfigSecretWriter
- func (kr ClusterAPIKubeconfigSecretWriter) GetClusterKubeconfig(ctx context.Context, clusterName, kubeconfigPath string) ([]byte, error)
- func (kr ClusterAPIKubeconfigSecretWriter) WriteKubeconfig(ctx context.Context, clusterName, kubeconfigPath string, w io.Writer) error
- func (kr ClusterAPIKubeconfigSecretWriter) WriteKubeconfigContent(ctx context.Context, clusterName string, content []byte, w io.Writer) error
- type Writer
- type WriterOpt
Constants ¶
const EnvName = "KUBECONFIG"
EnvName is the standard KubeConfig environment variable name. https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable
const FromClusterFormat = "%s-eks-a-cluster.kubeconfig"
FromClusterFormat defines the format of the kubeconfig of the.
Variables ¶
This section is empty.
Functions ¶
func FormatWorkloadClusterKubeconfigFilename ¶ added in v0.13.0
FormatWorkloadClusterKubeconfigFilename returns a filename for the Kubeconfig of workload clusters. The filename does not include a basepath.
func FromClusterName ¶
FromClusterName formats an expected Kubeconfig path for EKS-A clusters. This includes a subdirecftory named after the cluster name. For example, if the clusterName is 'sandbox' the generated path would be sandbox/sandbox-eks-a-cluster.kubeconfig.
func FromEnvironment ¶
func FromEnvironment() string
FromEnvironment returns the first kubeconfig file specified in the KUBECONFIG environment variable.
The environment variable can contain a list of files, much like how the PATH environment variable contains a list of directories.
func ResolveAndValidateFilename ¶ added in v0.12.0
ResolveAndValidate composes ResolveFilename and ValidateFile.
Literally, that's all it does. They're frequently called together, so hopefully this is a helper.
func ResolveFilename ¶ added in v0.12.0
ResolveFilename returns a path to a kubeconfig file by priority.
The priority is:
- CLI flag (flagValue)
- A file created at cluster creation, found by a combining the cluster name with present working directory.
- The first filename found in the KUBECONFIG environment variable.
NO VALIDATION IS PERFORMED. See ValidateFile for validation.
There are other places one may wish to consult or load a kubeconfig file from, but this function tries to walk the narrow line between what the kubernetes client code does (#1, #3, and some other things that we more or less don't support), with some of the existing EKSA CLI tools that look for kubeconfig files relative to the working directory that were created at cluster creation time. These different functionalities don't always mesh, and aren't always compatible, but this function tries to combine them as much as possible, without breaking either.
func ValidateFilename ¶ added in v0.12.0
ValidateFilename loads a file to validate it's basic contents.
The values of the fields within aren't validated, but the file's existence and basic structure are checked.
func ValidateKubeconfigPath ¶ added in v0.12.0
Types ¶
type ClientFactory ¶ added in v0.19.0
type ClientFactory interface { // BuildClientFromKubeconfig builds a Kubernetes client from a kubeconfig file. BuildClientFromKubeconfig(kubeconfigPath string) (kubernetes.Client, error) }
ClientFactory builds Kubernetes clients.
type ClusterAPIKubeconfigSecretWriter ¶ added in v0.19.0
type ClusterAPIKubeconfigSecretWriter struct {
// contains filtered or unexported fields
}
ClusterAPIKubeconfigSecretWriter reads the kubeconfig secret on a cluster and copies the contents to a writer.
func NewClusterAPIKubeconfigSecretWriter ¶ added in v0.19.0
func NewClusterAPIKubeconfigSecretWriter(unauthClient ClientFactory, opts ...WriterOpt) ClusterAPIKubeconfigSecretWriter
NewClusterAPIKubeconfigSecretWriter creates a ClusterAPIKubeconfigSecretWriter.
func (ClusterAPIKubeconfigSecretWriter) GetClusterKubeconfig ¶ added in v0.19.0
func (kr ClusterAPIKubeconfigSecretWriter) GetClusterKubeconfig(ctx context.Context, clusterName, kubeconfigPath string) ([]byte, error)
GetClusterKubeconfig gets the cluster's kubeconfig from the secret.
func (ClusterAPIKubeconfigSecretWriter) WriteKubeconfig ¶ added in v0.19.0
func (kr ClusterAPIKubeconfigSecretWriter) WriteKubeconfig(ctx context.Context, clusterName, kubeconfigPath string, w io.Writer) error
WriteKubeconfig retrieves the contents of the specified cluster's kubeconfig from a secret and copies it to an io.Writer.
func (ClusterAPIKubeconfigSecretWriter) WriteKubeconfigContent ¶ added in v0.19.0
func (kr ClusterAPIKubeconfigSecretWriter) WriteKubeconfigContent(ctx context.Context, clusterName string, content []byte, w io.Writer) error
WriteKubeconfigContent copies a raw kubeconfig to an io.Writer.
type Writer ¶ added in v0.19.0
type Writer interface { WriteKubeconfig(ctx context.Context, clusterName, kubeconfig string, w io.Writer) error WriteKubeconfigContent(ctx context.Context, clusterName string, content []byte, w io.Writer) error }
Writer reads the kubeconfig secret on a cluster and copies the contents to a writer.
type WriterOpt ¶ added in v0.19.0
type WriterOpt func(*ClusterAPIKubeconfigSecretWriter)
WriterOpt allows to configure [KubeconfigWriter].
func WithBackoff ¶ added in v0.19.0
WithBackoff sets the optional backoff duration for a KubeconfigWriter.
func WithTimeout ¶ added in v0.19.0
WithTimeout sets the optional timeout for a KubeconfigWriter.