diff --git a/api/v1alpha1/types.go b/api/v1alpha1/types.go index 8cb98d11..07e88273 100644 --- a/api/v1alpha1/types.go +++ b/api/v1alpha1/types.go @@ -28,9 +28,10 @@ func (c CGroupDriver) String() string { } const ( - ServiceTypeLoadBalancer = (ServiceType)(corev1.ServiceTypeLoadBalancer) - ServiceTypeClusterIP = (ServiceType)(corev1.ServiceTypeClusterIP) - ServiceTypeNodePort = (ServiceType)(corev1.ServiceTypeNodePort) + ServiceTypeLoadBalancer = (ServiceType)(corev1.ServiceTypeLoadBalancer) + ServiceTypeClusterIP = (ServiceType)(corev1.ServiceTypeClusterIP) + ServiceTypeNodePort = (ServiceType)(corev1.ServiceTypeNodePort) + KubeconfigSecretKeyAnnotation = "kamaji.clastix.io/kubeconfig-secret-key" ) // +kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer diff --git a/internal/utilities/tenant_client.go b/internal/utilities/tenant_client.go index 1531e98c..724c9f31 100644 --- a/internal/utilities/tenant_client.go +++ b/internal/utilities/tenant_client.go @@ -44,7 +44,13 @@ func GetTenantKubeconfig(ctx context.Context, client client.Client, tenantContro return nil, err } - return DecodeKubeconfig(*secretKubeconfig, kubeadmconstants.SuperAdminKubeConfigFileName) + secretKey := kubeadmconstants.SuperAdminKubeConfigFileName + v, ok := tenantControlPlane.GetAnnotations()[kamajiv1alpha1.KubeconfigSecretKeyAnnotation] + if ok && v != "" { + secretKey = v + } + + return DecodeKubeconfig(*secretKubeconfig, secretKey) } func GetRESTClientConfig(ctx context.Context, client client.Client, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (*restclient.Config, error) {