mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #82248 from rosti/proxyless
kubeadm: Fetching kube-proxy's config map is now optional
This commit is contained in:
commit
c8c1aeaa5c
@ -24,6 +24,7 @@ go_library(
|
|||||||
"//pkg/proxy/apis/config:go_default_library",
|
"//pkg/proxy/apis/config:go_default_library",
|
||||||
"//pkg/proxy/apis/config/v1alpha1:go_default_library",
|
"//pkg/proxy/apis/config/v1alpha1:go_default_library",
|
||||||
"//pkg/proxy/apis/config/validation: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/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
|
@ -18,7 +18,9 @@ package componentconfigs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"k8s.io/klog"
|
||||||
|
|
||||||
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/version"
|
"k8s.io/apimachinery/pkg/util/version"
|
||||||
@ -63,6 +65,13 @@ func GetFromKubeProxyConfigMap(client clientset.Interface, version *version.Vers
|
|||||||
// Read the ConfigMap from the cluster
|
// Read the ConfigMap from the cluster
|
||||||
kubeproxyCfg, err := apiclient.GetConfigMapWithRetry(client, metav1.NamespaceSystem, kubeadmconstants.KubeProxyConfigMap)
|
kubeproxyCfg, err := apiclient.GetConfigMapWithRetry(client, metav1.NamespaceSystem, kubeadmconstants.KubeProxyConfigMap)
|
||||||
if err != nil {
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ func TestGetFromConfigMap(t *testing.T) {
|
|||||||
component RegistrationKind
|
component RegistrationKind
|
||||||
configMap *fakeConfigMap
|
configMap *fakeConfigMap
|
||||||
expectedError bool
|
expectedError bool
|
||||||
|
expectedNil bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "valid kube-proxy",
|
name: "valid kube-proxy",
|
||||||
@ -59,10 +60,10 @@ func TestGetFromConfigMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid kube-proxy - missing ConfigMap",
|
name: "valid kube-proxy - missing ConfigMap",
|
||||||
component: KubeProxyConfigurationKind,
|
component: KubeProxyConfigurationKind,
|
||||||
configMap: nil,
|
configMap: nil,
|
||||||
expectedError: true,
|
expectedNil: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid kube-proxy - missing key",
|
name: "invalid kube-proxy - missing key",
|
||||||
@ -123,8 +124,8 @@ func TestGetFromConfigMap(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj == nil {
|
if rt.expectedNil != (obj == nil) {
|
||||||
t.Error("unexpected nil return value")
|
t.Error("unexpected return value")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,11 @@ func getComponentConfigs(client clientset.Interface, clusterConfiguration *kubea
|
|||||||
return err
|
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 {
|
if ok := registration.SetToInternalConfig(obj, clusterConfiguration); !ok {
|
||||||
return errors.Errorf("couldn't save componentconfig value for kind %q", string(kind))
|
return errors.Errorf("couldn't save componentconfig value for kind %q", string(kind))
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
if cfg.ComponentConfigs.Kubelet == nil {
|
||||||
t.Errorf("invalid cfg.ComponentConfigs.Kubelet")
|
t.Errorf("invalid cfg.ComponentConfigs.Kubelet")
|
||||||
}
|
}
|
||||||
if cfg.ComponentConfigs.KubeProxy == nil {
|
|
||||||
t.Errorf("invalid cfg.ComponentConfigs.KubeProxy")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user