Merge pull request #82248 from rosti/proxyless

kubeadm: Fetching kube-proxy's config map is now optional
This commit is contained in:
Kubernetes Prow Robot 2019-09-05 11:30:30 -07:00 committed by GitHub
commit c8c1aeaa5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 10 deletions

View File

@ -24,6 +24,7 @@ go_library(
"//pkg/proxy/apis/config:go_default_library",
"//pkg/proxy/apis/config/v1alpha1:go_default_library",
"//pkg/proxy/apis/config/validation:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",

View File

@ -18,7 +18,9 @@ package componentconfigs
import (
"github.com/pkg/errors"
"k8s.io/klog"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/version"
@ -63,6 +65,13 @@ func GetFromKubeProxyConfigMap(client clientset.Interface, version *version.Vers
// Read the ConfigMap from the cluster
kubeproxyCfg, err := apiclient.GetConfigMapWithRetry(client, metav1.NamespaceSystem, kubeadmconstants.KubeProxyConfigMap)
if err != nil {
// The Kube-Proxy config map may be non-existent, because the user has decided to manage it by themselves
// or to use other proxy solution. It may also be forbidden - if the kube-proxy phase was skipped we have neither
// the config map, nor the RBAC rules allowing join access to it.
if apierrors.IsNotFound(err) || apierrors.IsForbidden(err) {
klog.Warningf("Warning: No kube-proxy config is loaded. Continuing without it: %v", err)
return nil, nil
}
return nil, err
}

View File

@ -47,6 +47,7 @@ func TestGetFromConfigMap(t *testing.T) {
component RegistrationKind
configMap *fakeConfigMap
expectedError bool
expectedNil bool
}{
{
name: "valid kube-proxy",
@ -59,10 +60,10 @@ func TestGetFromConfigMap(t *testing.T) {
},
},
{
name: "invalid kube-proxy - missing ConfigMap",
component: KubeProxyConfigurationKind,
configMap: nil,
expectedError: true,
name: "valid kube-proxy - missing ConfigMap",
component: KubeProxyConfigurationKind,
configMap: nil,
expectedNil: true,
},
{
name: "invalid kube-proxy - missing key",
@ -123,8 +124,8 @@ func TestGetFromConfigMap(t *testing.T) {
return
}
if obj == nil {
t.Error("unexpected nil return value")
if rt.expectedNil != (obj == nil) {
t.Error("unexpected return value")
}
})
}

View File

@ -203,6 +203,11 @@ func getComponentConfigs(client clientset.Interface, clusterConfiguration *kubea
return err
}
// Some components may not be installed or managed by kubeadm, hence GetFromConfigMap won't return an error or an object
if obj == nil {
continue
}
if ok := registration.SetToInternalConfig(obj, clusterConfiguration); !ok {
return errors.Errorf("couldn't save componentconfig value for kind %q", string(kind))
}

View File

@ -449,7 +449,6 @@ func TestGetComponentConfigs(t *testing.T) {
},
},
},
expectedError: true,
},
}
@ -483,9 +482,6 @@ func TestGetComponentConfigs(t *testing.T) {
if cfg.ComponentConfigs.Kubelet == nil {
t.Errorf("invalid cfg.ComponentConfigs.Kubelet")
}
if cfg.ComponentConfigs.KubeProxy == nil {
t.Errorf("invalid cfg.ComponentConfigs.KubeProxy")
}
})
}
}