kubectl

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package kubectl configures kubectl for Podplane clusters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Args added in v0.2.0

func Args(kubeContext, kubeconfig string) []string

Args returns leading kubectl flags for an optional context and kubeconfig path.

func ClusterIDFromContext

func ClusterIDFromContext(kubeContext, kubeconfig string) (string, error)

ClusterIDFromContext returns a Podplane cluster ID from a kubeconfig context. If kubeContext is empty, the current context is used.

func ClusterKey

func ClusterKey(clusterID string, local bool) string

ClusterKey returns the kubectl cluster key for the given clusterID. Remote: podplane-{clusterID} Local: podplane-local-{clusterID}

func ConfigureClusterAccess

func ConfigureClusterAccess(stdout io.Writer, clusterID, serverURL, sub, caCertPath string, local bool) error

ConfigureClusterAccess configures kubectl access for a Podplane cluster by setting the cluster, credentials, and context entries used by the kubectl exec auth hook. When local is true the kubeconfig keys use a "local-" prefix so they don't collide with remote clusters.

func ContextKey

func ContextKey(clusterID string, local bool) string

ContextKey returns the kubectl context key for the given clusterID. Remote: {clusterID} Local: local-{clusterID}, or just "local" when clusterID is "default"

func CredentialsKey

func CredentialsKey(sub string, clusterID string, local bool) string

CredentialsKey returns the kubectl credentials (user) key for the given sub and clusterID. Remote: podplane-{clusterID}-{sub} Local: podplane-local-{clusterID}-{sub}

func DeleteClusterAccess

func DeleteClusterAccess(stdout io.Writer, clusterID string, subs []string, local bool) error

DeleteClusterAccess removes the kubeconfig context, cluster, and user entries created by ConfigureClusterAccess. Missing entries are ignored so cleanup can safely run after partial setup or repeated delete/logout attempts.

func SetCluster

func SetCluster(stdout io.Writer, clusterID string, kubeApiUrl string, caCertPath string, local bool) error

SetCluster first uses kubectl to check if a cluster with the same key already exists (and early exits if so), then runs kubectl to set a cluster

func SetContext

func SetContext(stdout io.Writer, sub string, clusterID string, local bool) error

SetContext first uses kubectl to check if a context with the same key already exists (and early exits if so), then runs kubectl to set a context

func SetCredentials

func SetCredentials(stdout io.Writer, sub string, clusterID string, local bool) error

SetCredentials first uses kubectl to check if a credential with the same key already exists (and early exits if so), then runs kubectl to set credentials.

The credentials key is `podplane-<clusterID>-<sub>`. The exec plugin invokes `podplane hooks kubectl-auth --cluster <clusterID> --user <sub>`.

Types

type Error added in v0.2.0

type Error struct {
	Stage  string
	Err    error
	Stderr string
}

Error is returned when a kubectl invocation fails.

func (*Error) Error added in v0.2.0

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap added in v0.2.0

func (e *Error) Unwrap() error

Unwrap returns the underlying exec error.

Jump to

Keyboard shortcuts

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