Commit 96850dc6 authored by Lucas Käldström's avatar Lucas Käldström

Set --anonymous-auth to false on v1.5 clusters to preserve the locked-down v1.4 behaviour

parent bb41d770
...@@ -53,7 +53,10 @@ const ( ...@@ -53,7 +53,10 @@ const (
var ( var (
// Minimum version of kube-apiserver that supports --kubelet-preferred-address-types // Minimum version of kube-apiserver that supports --kubelet-preferred-address-types
preferredAddressMinimumVersion = semver.MustParse("1.5.0-beta.2") preferredAddressAPIServerMinVersion = semver.MustParse("1.5.0")
// Minimum version of kube-apiserver that has to have --anonymous-auth=false set
anonAuthDisableAPIServerMinVersion = semver.MustParse("1.5.0")
) )
// WriteStaticPodManifests builds manifest objects based on user provided configuration and then dumps it to disk // WriteStaticPodManifests builds manifest objects based on user provided configuration and then dumps it to disk
...@@ -303,9 +306,16 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration) []string { ...@@ -303,9 +306,16 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration) []string {
// work on bare-metal where hostnames aren't usually resolvable // work on bare-metal where hostnames aren't usually resolvable
// Omit the "v" in the beginning, otherwise semver will fail // Omit the "v" in the beginning, otherwise semver will fail
k8sVersion, err := semver.Parse(cfg.KubernetesVersion[1:]) k8sVersion, err := semver.Parse(cfg.KubernetesVersion[1:])
if err == nil && k8sVersion.GTE(preferredAddressMinimumVersion) {
// If the k8s version is greater than this version, it supports telling it which way it should contact kubelets
if err == nil && k8sVersion.GTE(preferredAddressAPIServerMinVersion) {
command = append(command, "--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname") command = append(command, "--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname")
} }
// This is a critical "bugfix". Any version above this is vulnarable unless a RBAC/ABAC-authorizer is provided (which kubeadm doesn't for the time being)
if err == nil && k8sVersion.GTE(anonAuthDisableAPIServerMinVersion) {
command = append(command, "--anonymous-auth=false")
}
} }
// Check if the user decided to use an external etcd cluster // Check if the user decided to use an external etcd cluster
......
...@@ -447,6 +447,7 @@ func TestGetAPIServerCommand(t *testing.T) { ...@@ -447,6 +447,7 @@ func TestGetAPIServerCommand(t *testing.T) {
"--allow-privileged", "--allow-privileged",
"--advertise-address=foo", "--advertise-address=foo",
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname", "--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname",
"--anonymous-auth=false",
"--etcd-servers=http://127.0.0.1:2379", "--etcd-servers=http://127.0.0.1:2379",
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment