Skip to content

Commit 4a98610

Browse files
committed
Allow overriding secretKey for kubeconfig
During reconciliation, the control plane provider copies the content from the secret provided by Kamaji, named <cluster>-admin-kubeconfig, into a generic Cluster API secret, <cluster>-kubeconfig, which can then be used by the bootstrap provider and other cluster components. This change introduces a new annotation, kamaji.clastix.io/kubeconfig-secret-key, for the KamajiControlPlane resource. This annotation instructs the control plane provider to read the kubeconfig from a specific key (the default one is admin.conf). Example: ``` kamaji.clastix.io/kubeconfig-secret-key: super-admin.svc ``` This will instruct the system to use `super-admin.svc` a kubeconfig with a local service FQDN (introduced by clastix/kamaji#403). Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 75b0578 commit 4a98610

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

controllers/kamajicontrolplane_controller_resources.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ func (r *KamajiControlPlaneReconciler) createOrUpdateKubeconfig(ctx context.Cont
147147
labels["kamaji.clastix.io/cluster"] = cluster.Name
148148
labels["kamaji.clastix.io/tcp"] = tcp.Name
149149

150-
value, ok := kamajiAdminKubeconfig.Data["admin.conf"]
150+
secretKey := "admin.conf"
151+
v, ok := kcp.GetAnnotations()["kamaji.clastix.io/kubeconfig-secret-key"]
152+
if ok && v != "" {
153+
secretKey = v
154+
}
155+
156+
value, ok := kamajiAdminKubeconfig.Data[secretKey]
151157
if !ok {
152158
return errors.New("missing key from *kamajiv1alpha1.TenantControlPlane admin kubeconfig secret")
153159
}

0 commit comments

Comments
 (0)