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
- func FetchAndMergeFromContainer(containerName, socketPath string) error
- func FetchD2KFromContainer(containerName, 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, cluster, serverURL string) error
- func MergeFromDisk(dataPath string) error
- func NodeReady(kc []byte, addr string) (bool, error)
- func RemoveD2KContext(containerName string) bool
- func RemoveFromUserConfig(cluster string) bool
- func UserConfigPath() string
- func WaitForAPIServer(addr string, timeout time.Duration) error
- func WaitForContainerKubeconfig(containerName, socketPath string, timeout time.Duration) ([]byte, error)
- func WaitForNodeReady(kc []byte, addr string, timeout time.Duration) error
Constants ¶
const HostCluster = "kubesolo"
HostCluster is the kubeconfig cluster name of a host install.
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 kubeconfig, under a cluster named after the container. 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/<container>/, and creates or updates a Docker context named after the container pointing to tcp://127.0.0.1:<port>. Naming both after the container keeps them from replacing a context of the user's own that happens to share the instance name.
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 kubeconfig. It returns an error if the kubeconfig never appears or cannot be merged, so the caller can report the true outcome instead of claiming success.
func MergeContainerKubeconfig ¶
MergeContainerKubeconfig merges a KubeSolo container's admin kubeconfig into the real user's kubeconfig under the cluster name cluster — the container's name — and points the cluster server at serverURL, the full https://host:port value discovered from Docker.
func MergeFromDisk ¶
MergeFromDisk merges the admin kubeconfig from dataPath into the real user's kubeconfig immediately (no wait loop). Returns an error if the kubeconfig file does not exist. Use this for on-demand operations like `kubesoloctl kubeconfig fetch` on Linux where KubeSolo is already running as a system service.
func NodeReady ¶ added in v1.2.3
NodeReady asks the API server at addr (host:port), once, whether the node is Ready, with the admin credentials in the kubeconfig kc.
func RemoveD2KContext ¶
RemoveD2KContext removes the Docker context and credential directory created by `kubesoloctl d2k fetch` for the instance running in the named container. 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 context, cluster and user entries of one KubeSolo instance from the real user's kubeconfig. cluster is the instance's cluster name: its container name in container mode, and "kubesolo" for a host install. It returns true if it actually removed entries.
func UserConfigPath ¶ added in v1.2.3
func UserConfigPath() string
UserConfigPath is the kubeconfig install and fetch merge into.
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 ¶
func WaitForContainerKubeconfig(containerName, socketPath string, timeout time.Duration) ([]byte, error)
WaitForContainerKubeconfig polls the kubesolo container until the admin kubeconfig is generated, then returns the raw bytes. Waits up to timeout. Returns an error if the file never appears, the container stops or restarts — KubeSolo exited — or Docker is unreachable.
func WaitForNodeReady ¶ added in v1.2.3
WaitForNodeReady polls the API server at addr (host:port) with the admin credentials in the kubeconfig kc until the node reports Ready and its kubelet is seen alive, or timeout expires. An API server that answers is not yet a working node: the kubelet can still fail to register or to run.
Ready alone is not proof either. A replacement container opens the datastore of the one it replaced, Node object and all, so the node can read Ready before the new kubelet has started. The kubelet renews the node's Lease every ten seconds, so the Lease must be renewed while this watches: a renew time that changes, rather than one compared with this machine's clock, which need not agree with the engine's.
Types ¶
This section is empty.