kubeconfig

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package kubeconfig merges the KubeSolo admin kubeconfig into the invoking user's ~/.kube/config after installation, mirroring the behaviour of the original bash installer script.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchAndMergeFromContainer

func FetchAndMergeFromContainer(containerName, socketPath string) error

FetchAndMergeFromContainer copies the admin kubeconfig out of the named Docker container and merges it into the local user's ~/.kube/config. socketPath overrides the Docker socket; pass "" to use DOCKER_HOST or the platform default (/var/run/docker.sock).

func FetchD2KFromContainer

func FetchD2KFromContainer(containerName, name, socketPath string, port int) error

FetchD2KFromContainer copies the D2K mTLS credentials out of the named container, writes them to ~/.docker/d2k/<name>/, and creates or updates a Docker context named <name> pointing to tcp://127.0.0.1:<port>.

port is the host-mapped ephemeral port for the container's 2376/tcp binding, obtained via service.GetContainerD2KPort.

func GetFromContainer

func GetFromContainer(containerName, socketPath string) ([]byte, error)

GetFromContainer copies the admin kubeconfig out of the named container and returns the raw bytes. Unlike WaitForContainerKubeconfig it makes a single attempt — use it when the cluster is known to be running.

func KubeSoloKubeconfigPath

func KubeSoloKubeconfigPath(dataPath string) string

KubeSoloKubeconfigPath returns the default location of the admin kubeconfig that KubeSolo generates during its first startup.

func MergeAfterStartup

func MergeAfterStartup(dataPath string) error

MergeAfterStartup waits for KubeSolo to generate its admin kubeconfig and then merges it into the real user's ~/.kube/config. It returns an error if kubectl is missing or the kubeconfig never appears, so the caller can report the true outcome instead of claiming success.

func MergeContainerKubeconfig

func MergeContainerKubeconfig(data []byte, name, serverURL string)

MergeContainerKubeconfig renames the context/cluster/user entries to name, writes the result to a temp file, merges it into the real user's ~/.kube/config, and patches the cluster server URL to serverURL. serverURL should be the full https://host:port value discovered from Docker.

func MergeFromDisk

func MergeFromDisk(dataPath string) error

MergeFromDisk merges the admin kubeconfig from dataPath into the real user's ~/.kube/config immediately (no wait loop). Returns an error if the kubeconfig file does not exist or kubectl is not installed. Use this for on-demand operations like `kubesoloctl kubeconfig fetch` on Linux where KubeSolo is already running as a system service.

func PatchContainerServerURL

func PatchContainerServerURL()

PatchContainerServerURL updates the kubesolo cluster server in the real user's ~/.kube/config to https://127.0.0.1:6443. Call this after WaitAndFetchFromContainer or FetchAndMergeFromContainer in container mode so that kubectl connects via Docker's published port mapping.

func RemoveD2KContext

func RemoveD2KContext(name string) bool

RemoveD2KContext removes the Docker context and credential directory created by `kubesoloctl d2k fetch` for the named instance. It is best-effort and a no-op when the docker CLI is absent or neither artifact exists. It returns true if it removed the context or the credential directory.

func RemoveFromUserConfig

func RemoveFromUserConfig(name string) bool

RemoveFromUserConfig surgically removes the named KubeSolo context, cluster, and user entries from the real user's ~/.kube/config. name is the instance name used during install (default "kubesolo"). It is a no-op if kubectl is not installed or if no matching entries are present. It returns true if it actually removed entries.

func WaitForAPIServer

func WaitForAPIServer(addr string, timeout time.Duration) error

WaitForAPIServer polls the Kubernetes API server at addr (host:port) until it responds to HTTPS requests or timeout expires. Uses InsecureSkipVerify since the caller may not yet have the CA cert loaded in the system trust store. Any HTTP response (including 401/403) is treated as "server is up".

func WaitForContainerKubeconfig

func WaitForContainerKubeconfig(containerName, socketPath string) ([]byte, error)

WaitForContainerKubeconfig polls the kubesolo container until the admin kubeconfig is generated, then returns the raw bytes. Waits up to 60 seconds. Returns an error if the file never appears or Docker is unreachable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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