From d6382db8a6ad9fa79c12d8abf055fb28a1a0a04d Mon Sep 17 00:00:00 2001 From: Robert Volkmann Date: Fri, 5 Dec 2025 22:57:44 +0100 Subject: [PATCH] Expose --kubeconfig option for k8s_kind --- docs/manual/kinds/k8s-kind.md | 2 ++ nodes/k8s_kind/k8s_kind.go | 6 ++++++ types/types.go | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/manual/kinds/k8s-kind.md b/docs/manual/kinds/k8s-kind.md index 198d0c5784..0c7f638536 100644 --- a/docs/manual/kinds/k8s-kind.md +++ b/docs/manual/kinds/k8s-kind.md @@ -115,6 +115,8 @@ topology: extras: k8s_kind: deploy: + # Corresponds to --kubeconfig option. + kubeconfig: ./kubeconfig # Corresponds to --wait option. Wait given duration until the cluster becomes ready. wait: 0s ``` diff --git a/nodes/k8s_kind/k8s_kind.go b/nodes/k8s_kind/k8s_kind.go index f19fbe74dd..c9b8c4f24e 100644 --- a/nodes/k8s_kind/k8s_kind.go +++ b/nodes/k8s_kind/k8s_kind.go @@ -95,6 +95,12 @@ func (n *k8s_kind) Deploy(_ context.Context, _ *clabnodes.DeployParams) error { n.Cfg.Extras.K8sKind.Deploy != nil { opts := n.Cfg.Extras.K8sKind.Deploy + // Sets the explicit --kubeconfig path + if opts.KubeconfigPath != nil { + clusterCreateOptions = append(clusterCreateOptions, + cluster.CreateWithKubeconfigPath(*opts.KubeconfigPath)) + } + // Override the default wait duration if opts.Wait != nil { duration, err := time.ParseDuration(*opts.Wait) diff --git a/types/types.go b/types/types.go index a971ef8708..0d1d7f8695 100644 --- a/types/types.go +++ b/types/types.go @@ -265,7 +265,8 @@ type K8sKindExtras struct { // It is aligned with the `kind create cluster` command options, but exposes // only the ones that are relevant for containerlab. type K8sKindDeployExtras struct { - Wait *string `yaml:"wait,omitempty"` + KubeconfigPath *string `yaml:"kubeconfig,omitempty"` + Wait *string `yaml:"wait,omitempty"` } // ContainerDetails contains information that is commonly outputted to tables or graphs.