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 ¶
- func FetchAndMergeFromContainer(containerName, socketPath string) error
- func FetchD2KFromContainer(containerName, name, socketPath string, port int) error
- func GetFromContainer(containerName, socketPath string) ([]byte, error)
- func KubeSoloKubeconfigPath(dataPath string) string
- func MergeAfterStartup(dataPath string) error
- func MergeContainerKubeconfig(data []byte, name, serverURL string)
- func MergeFromDisk(dataPath string) error
- func PatchContainerServerURL()
- func RemoveD2KContext(name string) bool
- func RemoveFromUserConfig(name string) bool
- func WaitForAPIServer(addr string, timeout time.Duration) error
- func WaitForContainerKubeconfig(containerName, socketPath string) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchAndMergeFromContainer ¶
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 ¶
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 ¶
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 ¶
KubeSoloKubeconfigPath returns the default location of the admin kubeconfig that KubeSolo generates during its first startup.
func MergeAfterStartup ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.