mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
kubeadm: Use the --enable-bootstrap-token-auth flag when possible
This commit is contained in:
parent
4231308582
commit
775a5d477f
@ -156,6 +156,10 @@ var (
|
|||||||
// MinimumCSRAutoApprovalClusterRolesVersion defines whether kubeadm can rely on the built-in CSR approval ClusterRole or not (note, the binding is always created by kubeadm!)
|
// MinimumCSRAutoApprovalClusterRolesVersion defines whether kubeadm can rely on the built-in CSR approval ClusterRole or not (note, the binding is always created by kubeadm!)
|
||||||
// TODO: Remove this when the v1.9 cycle starts and we bump the minimum supported version to v1.8.0
|
// TODO: Remove this when the v1.9 cycle starts and we bump the minimum supported version to v1.8.0
|
||||||
MinimumCSRAutoApprovalClusterRolesVersion = version.MustParseSemantic("v1.8.0-alpha.3")
|
MinimumCSRAutoApprovalClusterRolesVersion = version.MustParseSemantic("v1.8.0-alpha.3")
|
||||||
|
|
||||||
|
// UseEnableBootstrapTokenAuthFlagVersion defines the first version where the API server supports the --enable-bootstrap-token-auth flag instead of the old and deprecated flag.
|
||||||
|
// TODO: Remove this when the v1.9 cycle starts and we bump the minimum supported version to v1.8.0
|
||||||
|
UseEnableBootstrapTokenAuthFlagVersion = version.MustParseSemantic("v1.8.0-beta.0")
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetStaticPodDirectory returns the location on the disk where the Static Pod should be present
|
// GetStaticPodDirectory returns the location on the disk where the Static Pod should be present
|
||||||
|
@ -136,20 +136,19 @@ func createStaticPodFiles(manifestDir string, cfg *kubeadmapi.MasterConfiguratio
|
|||||||
// getAPIServerCommand builds the right API server command from the given config object and version
|
// getAPIServerCommand builds the right API server command from the given config object and version
|
||||||
func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration, k8sVersion *version.Version) []string {
|
func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration, k8sVersion *version.Version) []string {
|
||||||
defaultArguments := map[string]string{
|
defaultArguments := map[string]string{
|
||||||
"advertise-address": cfg.API.AdvertiseAddress,
|
"advertise-address": cfg.API.AdvertiseAddress,
|
||||||
"insecure-port": "0",
|
"insecure-port": "0",
|
||||||
"admission-control": defaultv17AdmissionControl,
|
"admission-control": defaultv17AdmissionControl,
|
||||||
"service-cluster-ip-range": cfg.Networking.ServiceSubnet,
|
"service-cluster-ip-range": cfg.Networking.ServiceSubnet,
|
||||||
"service-account-key-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.ServiceAccountPublicKeyName),
|
"service-account-key-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.ServiceAccountPublicKeyName),
|
||||||
"client-ca-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.CACertName),
|
"client-ca-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.CACertName),
|
||||||
"tls-cert-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerCertName),
|
"tls-cert-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerCertName),
|
||||||
"tls-private-key-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKeyName),
|
"tls-private-key-file": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKeyName),
|
||||||
"kubelet-client-certificate": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientCertName),
|
"kubelet-client-certificate": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientCertName),
|
||||||
"kubelet-client-key": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientKeyName),
|
"kubelet-client-key": filepath.Join(cfg.CertificatesDir, kubeadmconstants.APIServerKubeletClientKeyName),
|
||||||
"secure-port": fmt.Sprintf("%d", cfg.API.BindPort),
|
"secure-port": fmt.Sprintf("%d", cfg.API.BindPort),
|
||||||
"allow-privileged": "true",
|
"allow-privileged": "true",
|
||||||
"experimental-bootstrap-token-auth": "true",
|
"kubelet-preferred-address-types": "InternalIP,ExternalIP,Hostname",
|
||||||
"kubelet-preferred-address-types": "InternalIP,ExternalIP,Hostname",
|
|
||||||
// add options to configure the front proxy. Without the generated client cert, this will never be useable
|
// add options to configure the front proxy. Without the generated client cert, this will never be useable
|
||||||
// so add it unconditionally with recommended values
|
// so add it unconditionally with recommended values
|
||||||
"requestheader-username-headers": "X-Remote-User",
|
"requestheader-username-headers": "X-Remote-User",
|
||||||
@ -162,6 +161,14 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration, k8sVersion *versio
|
|||||||
}
|
}
|
||||||
|
|
||||||
command := []string{"kube-apiserver"}
|
command := []string{"kube-apiserver"}
|
||||||
|
|
||||||
|
// Note: Mutating defaultArguments dynamically must happen before the BuildArgumentListFromMap call below
|
||||||
|
if k8sVersion.AtLeast(kubeadmconstants.UseEnableBootstrapTokenAuthFlagVersion) {
|
||||||
|
defaultArguments["enable-bootstrap-token-auth"] = "true"
|
||||||
|
} else {
|
||||||
|
defaultArguments["experimental-bootstrap-token-auth"] = "true"
|
||||||
|
}
|
||||||
|
|
||||||
command = append(command, kubeadmutil.BuildArgumentListFromMap(defaultArguments, cfg.APIServerExtraArgs)...)
|
command = append(command, kubeadmutil.BuildArgumentListFromMap(defaultArguments, cfg.APIServerExtraArgs)...)
|
||||||
command = append(command, getAuthzParameters(cfg.AuthorizationModes)...)
|
command = append(command, getAuthzParameters(cfg.AuthorizationModes)...)
|
||||||
|
|
||||||
|
@ -171,6 +171,40 @@ func TestGetAPIServerCommand(t *testing.T) {
|
|||||||
"--etcd-servers=http://127.0.0.1:2379",
|
"--etcd-servers=http://127.0.0.1:2379",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
cfg: &kubeadmapi.MasterConfiguration{
|
||||||
|
API: kubeadmapi.API{BindPort: 123, AdvertiseAddress: "1.2.3.4"},
|
||||||
|
Networking: kubeadmapi.Networking{ServiceSubnet: "bar"},
|
||||||
|
CertificatesDir: testCertsDir,
|
||||||
|
KubernetesVersion: "v1.8.0-beta.0",
|
||||||
|
},
|
||||||
|
expected: []string{
|
||||||
|
"kube-apiserver",
|
||||||
|
"--insecure-port=0",
|
||||||
|
"--admission-control=Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota",
|
||||||
|
"--service-cluster-ip-range=bar",
|
||||||
|
"--service-account-key-file=" + testCertsDir + "/sa.pub",
|
||||||
|
"--client-ca-file=" + testCertsDir + "/ca.crt",
|
||||||
|
"--tls-cert-file=" + testCertsDir + "/apiserver.crt",
|
||||||
|
"--tls-private-key-file=" + testCertsDir + "/apiserver.key",
|
||||||
|
"--kubelet-client-certificate=" + testCertsDir + "/apiserver-kubelet-client.crt",
|
||||||
|
"--kubelet-client-key=" + testCertsDir + "/apiserver-kubelet-client.key",
|
||||||
|
"--secure-port=123",
|
||||||
|
"--allow-privileged=true",
|
||||||
|
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname",
|
||||||
|
"--enable-bootstrap-token-auth=true",
|
||||||
|
"--proxy-client-cert-file=/var/lib/certs/front-proxy-client.crt",
|
||||||
|
"--proxy-client-key-file=/var/lib/certs/front-proxy-client.key",
|
||||||
|
"--requestheader-username-headers=X-Remote-User",
|
||||||
|
"--requestheader-group-headers=X-Remote-Group",
|
||||||
|
"--requestheader-extra-headers-prefix=X-Remote-Extra-",
|
||||||
|
"--requestheader-client-ca-file=" + testCertsDir + "/front-proxy-ca.crt",
|
||||||
|
"--requestheader-allowed-names=front-proxy-client",
|
||||||
|
"--authorization-mode=Node,RBAC",
|
||||||
|
"--advertise-address=1.2.3.4",
|
||||||
|
"--etcd-servers=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
cfg: &kubeadmapi.MasterConfiguration{
|
cfg: &kubeadmapi.MasterConfiguration{
|
||||||
API: kubeadmapi.API{BindPort: 123, AdvertiseAddress: "4.3.2.1"},
|
API: kubeadmapi.API{BindPort: 123, AdvertiseAddress: "4.3.2.1"},
|
||||||
|
Loading…
Reference in New Issue
Block a user