Skip to content

Commit 6df5b94

Browse files
committed
Allow overriding secretKey for kubeadm kubeconfig
During reconciliation, the bootstrap provider copies the content from the secret provided by Kamaji, named `<cluster>-admin-kubeconfig` into a `cluster-info` configmap of tenant cluster, which then used by kubeadm to join nodes. This change introduces a new annotation, `kamaji.clastix.io/kubeconfig-secret-key`, for the TenantControlPlane resource. This annotation instructs kamaji to read the kubeconfig from a specific key (the default one is super-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 #403). Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 197518b commit 6df5b94

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

api/v1alpha1/types.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ func (c CGroupDriver) String() string {
2828
}
2929

3030
const (
31-
ServiceTypeLoadBalancer = (ServiceType)(corev1.ServiceTypeLoadBalancer)
32-
ServiceTypeClusterIP = (ServiceType)(corev1.ServiceTypeClusterIP)
33-
ServiceTypeNodePort = (ServiceType)(corev1.ServiceTypeNodePort)
31+
ServiceTypeLoadBalancer = (ServiceType)(corev1.ServiceTypeLoadBalancer)
32+
ServiceTypeClusterIP = (ServiceType)(corev1.ServiceTypeClusterIP)
33+
ServiceTypeNodePort = (ServiceType)(corev1.ServiceTypeNodePort)
34+
KubeConfigSecretKeyAnnotation = "kamaji.clastix.io/kubeconfig-secret-key"
3435
)
3536

3637
// +kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer

internal/utilities/tenant_client.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
1717
"sigs.k8s.io/controller-runtime/pkg/client"
1818

19+
"github.com/clastix/kamaji/api/v1alpha1"
1920
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
2021
)
2122

@@ -44,7 +45,13 @@ func GetTenantKubeconfig(ctx context.Context, client client.Client, tenantContro
4445
return nil, err
4546
}
4647

47-
return DecodeKubeconfig(*secretKubeconfig, kubeadmconstants.SuperAdminKubeConfigFileName)
48+
secretKey := kubeadmconstants.SuperAdminKubeConfigFileName
49+
v, ok := tenantControlPlane.GetAnnotations()[v1alpha1.KubeConfigSecretKeyAnnotation]
50+
if ok && v != "" {
51+
secretKey = v
52+
}
53+
54+
return DecodeKubeconfig(*secretKubeconfig, secretKey)
4855
}
4956

5057
func GetRESTClientConfig(ctx context.Context, client client.Client, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (*restclient.Config, error) {

0 commit comments

Comments
 (0)