kubeadm: make super-admin.conf changes in app/constants

- Add the new file name: super-admin.conf and a function
to return its default path GetSuperAdminKubeConfigPath()
- Add the ClusterAdminsGroupAndClusterRoleBinding object name.
This commit is contained in:
Lubomir I. Ivanov 2023-10-16 11:54:48 +03:00
parent afc302c2d2
commit 98bed52fdd
2 changed files with 26 additions and 1 deletions

View File

@ -146,8 +146,11 @@ const (
// FrontProxyClientCertCommonName defines front proxy certificate common name
FrontProxyClientCertCommonName = "front-proxy-client" //used as subject.commonname attribute (CN)
// AdminKubeConfigFileName defines name for the kubeconfig aimed to be used by the superuser/admin of the cluster
// AdminKubeConfigFileName defines name for the kubeconfig aimed to be used by the admin of the cluster
AdminKubeConfigFileName = "admin.conf"
// SuperAdminKubeConfigFileName defines name for the kubeconfig aimed to be used by the super-admin of the cluster
SuperAdminKubeConfigFileName = "super-admin.conf"
// KubeletBootstrapKubeConfigFileName defines the file name for the kubeconfig that the kubelet will use to do
// the TLS bootstrap to get itself an unique credential
KubeletBootstrapKubeConfigFileName = "bootstrap-kubelet.conf"
@ -201,6 +204,10 @@ const (
NodeAutoApproveBootstrapClusterRoleBinding = "kubeadm:node-autoapprove-bootstrap"
// NodeAutoApproveCertificateRotationClusterRoleBinding defines name of the ClusterRoleBinding that makes the csrapprover approve node auto rotated CSRs
NodeAutoApproveCertificateRotationClusterRoleBinding = "kubeadm:node-autoapprove-certificate-rotation"
// ClusterAdminsGroupAndClusterRoleBinding is the name of the Group used for kubeadm generated cluster
// admin credentials and the name of the ClusterRoleBinding that binds the same Group to the "cluster-admin"
// built-in ClusterRole.
ClusterAdminsGroupAndClusterRoleBinding = "kubeadm:cluster-admins"
// APICallRetryInterval defines how long kubeadm should wait before retrying a failed API operation
APICallRetryInterval = 500 * time.Millisecond
@ -570,6 +577,11 @@ func GetAdminKubeConfigPath() string {
return filepath.Join(KubernetesDir, AdminKubeConfigFileName)
}
// GetSuperAdminKubeConfigPath returns the location on the disk where admin kubeconfig is located by default
func GetSuperAdminKubeConfigPath() string {
return filepath.Join(KubernetesDir, SuperAdminKubeConfigFileName)
}
// GetBootstrapKubeletKubeConfigPath returns the location on the disk where bootstrap kubelet kubeconfig is located by default
func GetBootstrapKubeletKubeConfigPath() string {
return filepath.Join(KubernetesDir, KubeletBootstrapKubeConfigFileName)

View File

@ -50,6 +50,19 @@ func TestGetAdminKubeConfigPath(t *testing.T) {
}
}
func TestGetSuperAdminKubeConfigPath(t *testing.T) {
expected := filepath.Join(KubernetesDir, SuperAdminKubeConfigFileName)
actual := GetSuperAdminKubeConfigPath()
if actual != expected {
t.Errorf(
"failed GetSuperAdminKubeConfigPath:\n\texpected: %s\n\t actual: %s",
expected,
actual,
)
}
}
func TestGetBootstrapKubeletKubeConfigPath(t *testing.T) {
expected := filepath.FromSlash("/etc/kubernetes/bootstrap-kubelet.conf")
actual := GetBootstrapKubeletKubeConfigPath()