mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Remove gcp cloud-provider checks for kubelet version >= 1.7.2
This commit is contained in:
parent
47f1bd9f80
commit
4fa7e44480
@ -20,8 +20,6 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/klog/v2"
|
|
||||||
|
|
||||||
computealpha "google.golang.org/api/compute/v0.alpha"
|
computealpha "google.golang.org/api/compute/v0.alpha"
|
||||||
computebeta "google.golang.org/api/compute/v0.beta"
|
computebeta "google.golang.org/api/compute/v0.beta"
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
@ -29,8 +27,6 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud"
|
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud"
|
||||||
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter"
|
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter"
|
||||||
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
|
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
utilversion "k8s.io/apimachinery/pkg/util/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -42,18 +38,6 @@ const (
|
|||||||
lbNodesHealthCheckPort = 10256
|
lbNodesHealthCheckPort = 10256
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
minNodesHealthCheckVersion *utilversion.Version
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
if v, err := utilversion.ParseGeneric("1.7.2"); err != nil {
|
|
||||||
klog.Fatalf("Failed to parse version for minNodesHealthCheckVersion: %v", err)
|
|
||||||
} else {
|
|
||||||
minNodesHealthCheckVersion = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newHealthcheckMetricContext(request string) *metricContext {
|
func newHealthcheckMetricContext(request string) *metricContext {
|
||||||
return newHealthcheckMetricContextWithVersion(request, computeV1Version)
|
return newHealthcheckMetricContextWithVersion(request, computeV1Version)
|
||||||
}
|
}
|
||||||
@ -274,25 +258,3 @@ func GetNodesHealthCheckPort() int32 {
|
|||||||
func GetNodesHealthCheckPath() string {
|
func GetNodesHealthCheckPath() string {
|
||||||
return nodesHealthCheckPath
|
return nodesHealthCheckPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// isAtLeastMinNodesHealthCheckVersion checks if a version is higher than
|
|
||||||
// `minNodesHealthCheckVersion`.
|
|
||||||
func isAtLeastMinNodesHealthCheckVersion(vstring string) bool {
|
|
||||||
version, err := utilversion.ParseGeneric(vstring)
|
|
||||||
if err != nil {
|
|
||||||
klog.Errorf("vstring (%s) is not a valid version string: %v", vstring, err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return version.AtLeast(minNodesHealthCheckVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
// supportsNodesHealthCheck returns false if anyone of the nodes has version
|
|
||||||
// lower than `minNodesHealthCheckVersion`.
|
|
||||||
func supportsNodesHealthCheck(nodes []*v1.Node) bool {
|
|
||||||
for _, node := range nodes {
|
|
||||||
if !isAtLeastMinNodesHealthCheckVersion(node.Status.NodeInfo.KubeProxyVersion) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
//go:build !providerless
|
|
||||||
// +build !providerless
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package gce
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestIsAtLeastMinNodesHealthCheckVersion(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
version string
|
|
||||||
expect bool
|
|
||||||
}{
|
|
||||||
{"v1.7.3", true},
|
|
||||||
{"v1.7.2", true},
|
|
||||||
{"v1.7.2-alpha.2.597+276d289b90d322", true},
|
|
||||||
{"v1.6.0-beta.3.472+831q821c907t31a", false},
|
|
||||||
{"v1.5.2", false},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
if res := isAtLeastMinNodesHealthCheckVersion(tc.version); res != tc.expect {
|
|
||||||
t.Errorf("%v: want %v, got %v", tc.version, tc.expect, res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSupportsNodesHealthCheck(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
desc string
|
|
||||||
nodes []*v1.Node
|
|
||||||
expect bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
"All nodes support nodes health check",
|
|
||||||
[]*v1.Node{
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.7.2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.7.2-alpha.2.597+276d289b90d322",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"All nodes don't support nodes health check",
|
|
||||||
[]*v1.Node{
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.6.0-beta.3.472+831q821c907t31a",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.5.2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"One node doesn't support nodes health check",
|
|
||||||
[]*v1.Node{
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.7.3",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.7.2-alpha.2.597+276d289b90d322",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.5.2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
if res := supportsNodesHealthCheck(tc.nodes); res != tc.expect {
|
|
||||||
t.Errorf("%v: want %v, got %v", tc.desc, tc.expect, res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -63,7 +63,6 @@ func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hostNames := nodeNames(nodes)
|
hostNames := nodeNames(nodes)
|
||||||
supportsNodesHealthCheck := supportsNodesHealthCheck(nodes)
|
|
||||||
hosts, err := g.getInstancesByNames(hostNames)
|
hosts, err := g.getInstancesByNames(hostNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -229,9 +228,7 @@ func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string,
|
|||||||
// turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the
|
// turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the
|
||||||
// target pool to use local traffic health check.
|
// target pool to use local traffic health check.
|
||||||
klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from nodes health checks to local traffic health checks.", lbRefStr)
|
klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from nodes health checks to local traffic health checks.", lbRefStr)
|
||||||
if supportsNodesHealthCheck {
|
hcToDelete = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort())
|
||||||
hcToDelete = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort())
|
|
||||||
}
|
|
||||||
tpNeedsRecreation = true
|
tpNeedsRecreation = true
|
||||||
}
|
}
|
||||||
hcToCreate = makeHTTPHealthCheck(loadBalancerName, path, healthCheckNodePort)
|
hcToCreate = makeHTTPHealthCheck(loadBalancerName, path, healthCheckNodePort)
|
||||||
@ -245,9 +242,7 @@ func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string,
|
|||||||
hcToDelete = hcLocalTrafficExisting
|
hcToDelete = hcLocalTrafficExisting
|
||||||
tpNeedsRecreation = true
|
tpNeedsRecreation = true
|
||||||
}
|
}
|
||||||
if supportsNodesHealthCheck {
|
hcToCreate = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort())
|
||||||
hcToCreate = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Now we get to some slightly more interesting logic.
|
// Now we get to some slightly more interesting logic.
|
||||||
// First, neither target pools nor forwarding rules can be updated in place -
|
// First, neither target pools nor forwarding rules can be updated in place -
|
||||||
|
@ -114,11 +114,6 @@ func createAndInsertNodes(gce *Cloud, nodeNames []string, zoneName string) ([]*v
|
|||||||
v1.LabelFailureDomainBetaZone: zoneName,
|
v1.LabelFailureDomainBetaZone: zoneName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: v1.NodeStatus{
|
|
||||||
NodeInfo: v1.NodeSystemInfo{
|
|
||||||
KubeProxyVersion: "v1.7.2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user