Add --kubelet-client-{certificate,key} to the apiserver args and make it allowed to access the kubelets
This commit is contained in:
		| @@ -168,12 +168,6 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, skipPreFlight | |||||||
| 	// Try to start the kubelet service in case it's inactive | 	// Try to start the kubelet service in case it's inactive | ||||||
| 	preflight.TryStartKubelet() | 	preflight.TryStartKubelet() | ||||||
|  |  | ||||||
| 	// Warn about the limitations with the current cloudprovider solution. |  | ||||||
| 	if cfg.CloudProvider != "" { |  | ||||||
| 		fmt.Println("WARNING: For cloudprovider integrations to work --cloud-provider must be set for all kubelets in the cluster.") |  | ||||||
| 		fmt.Println("\t(/etc/systemd/system/kubelet.service.d/10-kubeadm.conf should be edited for this purpose)") |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return &Init{cfg: cfg, selfHosted: selfHosted}, nil | 	return &Init{cfg: cfg, selfHosted: selfHosted}, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -322,6 +322,8 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration, selfHosted bool) [ | |||||||
| 		"--client-ca-file="+getCertFilePath(kubeadmconstants.CACertName), | 		"--client-ca-file="+getCertFilePath(kubeadmconstants.CACertName), | ||||||
| 		"--tls-cert-file="+getCertFilePath(kubeadmconstants.APIServerCertName), | 		"--tls-cert-file="+getCertFilePath(kubeadmconstants.APIServerCertName), | ||||||
| 		"--tls-private-key-file="+getCertFilePath(kubeadmconstants.APIServerKeyName), | 		"--tls-private-key-file="+getCertFilePath(kubeadmconstants.APIServerKeyName), | ||||||
|  | 		"--kubelet-client-certificate="+getCertFilePath(kubeadmconstants.APIServerCertName), | ||||||
|  | 		"--kubelet-client-key="+getCertFilePath(kubeadmconstants.APIServerKeyName), | ||||||
| 		"--token-auth-file="+kubeadmapi.GlobalEnvParams.HostPKIPath+"/tokens.csv", | 		"--token-auth-file="+kubeadmapi.GlobalEnvParams.HostPKIPath+"/tokens.csv", | ||||||
| 		fmt.Sprintf("--secure-port=%d", cfg.API.Port), | 		fmt.Sprintf("--secure-port=%d", cfg.API.Port), | ||||||
| 		"--allow-privileged", | 		"--allow-privileged", | ||||||
|   | |||||||
| @@ -376,6 +376,8 @@ func TestGetAPIServerCommand(t *testing.T) { | |||||||
| 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | ||||||
| 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
| 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
|  | 				"--kubelet-client-certificate=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
|  | 				"--kubelet-client-key=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
| 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | ||||||
| 				fmt.Sprintf("--secure-port=%d", 123), | 				fmt.Sprintf("--secure-port=%d", 123), | ||||||
| 				"--allow-privileged", | 				"--allow-privileged", | ||||||
| @@ -397,6 +399,8 @@ func TestGetAPIServerCommand(t *testing.T) { | |||||||
| 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | ||||||
| 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
| 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
|  | 				"--kubelet-client-certificate=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
|  | 				"--kubelet-client-key=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
| 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | ||||||
| 				fmt.Sprintf("--secure-port=%d", 123), | 				fmt.Sprintf("--secure-port=%d", 123), | ||||||
| 				"--allow-privileged", | 				"--allow-privileged", | ||||||
| @@ -420,6 +424,8 @@ func TestGetAPIServerCommand(t *testing.T) { | |||||||
| 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | ||||||
| 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
| 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
|  | 				"--kubelet-client-certificate=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
|  | 				"--kubelet-client-key=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
| 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | ||||||
| 				fmt.Sprintf("--secure-port=%d", 123), | 				fmt.Sprintf("--secure-port=%d", 123), | ||||||
| 				"--allow-privileged", | 				"--allow-privileged", | ||||||
| @@ -445,6 +451,8 @@ func TestGetAPIServerCommand(t *testing.T) { | |||||||
| 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | 				"--client-ca-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/ca.crt", | ||||||
| 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | 				"--tls-cert-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
| 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | 				"--tls-private-key-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
|  | 				"--kubelet-client-certificate=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.crt", | ||||||
|  | 				"--kubelet-client-key=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/apiserver.key", | ||||||
| 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | 				"--token-auth-file=" + kubeadmapi.GlobalEnvParams.HostPKIPath + "/tokens.csv", | ||||||
| 				fmt.Sprintf("--secure-port=%d", 123), | 				fmt.Sprintf("--secure-port=%d", 123), | ||||||
| 				"--allow-privileged", | 				"--allow-privileged", | ||||||
|   | |||||||
| @@ -123,7 +123,9 @@ func CreatePKIAssets(cfg *kubeadmapi.MasterConfiguration, pkiDir string) error { | |||||||
| 		config := certutil.Config{ | 		config := certutil.Config{ | ||||||
| 			CommonName: "kube-apiserver", | 			CommonName: "kube-apiserver", | ||||||
| 			AltNames:   altNames, | 			AltNames:   altNames, | ||||||
| 			Usages:     []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, | 			// This makes the apiserver allowed to talk to the kubelets in the cluster | ||||||
|  | 			Organization: []string{"system:masters"}, | ||||||
|  | 			Usages:       []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, | ||||||
| 		} | 		} | ||||||
| 		apiCert, apiKey, err := pkiutil.NewCertAndKey(caCert, caKey, config) | 		apiCert, apiKey, err := pkiutil.NewCertAndKey(caCert, caKey, config) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lucas Käldström
					Lucas Käldström