Bump kind to v0.22.0

Signed-off-by: whitewindmills <jayfantasyhjh@gmail.com>
This commit is contained in:
whitewindmills 2024-05-07 11:34:53 +08:00
parent 167f213c51
commit 98cb2a91bf
13 changed files with 43 additions and 19 deletions

View File

@ -36,7 +36,7 @@ jobs:
go-version-file: go.mod
- uses: helm/kind-action@v1.10.0
with:
version: "v0.20.0"
version: "v0.22.0"
- name: run karmadactl init test
run: |
export CLUSTER_VERSION=kindest/node:${{ matrix.k8s }}

View File

@ -3,7 +3,7 @@ name: Chart Lint
env:
HELM_VERSION: v3.11.2
KIND_VERSION: v0.20.0
KIND_VERSION: v0.22.0
KIND_NODE_IMAGE: kindest/node:v1.29.0
K8S_VERSION: v1.29.0

2
go.mod
View File

@ -55,7 +55,7 @@ require (
sigs.k8s.io/cluster-api v1.5.0
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/custom-metrics-apiserver v1.29.0
sigs.k8s.io/kind v0.20.0
sigs.k8s.io/kind v0.22.0
sigs.k8s.io/mcs-api v0.1.0
sigs.k8s.io/metrics-server v0.6.1-0.20230706083104-796fc0f832c1
sigs.k8s.io/structured-merge-diff/v4 v4.4.1

4
go.sum
View File

@ -1510,8 +1510,8 @@ sigs.k8s.io/custom-metrics-apiserver v1.29.0/go.mod h1:4XXz92s/SEmP3L2nlUu6lMWor
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kind v0.8.1/go.mod h1:oNKTxUVPYkV9lWzY6CVMNluVq8cBsyq+UgPJdvA3uu4=
sigs.k8s.io/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8=
sigs.k8s.io/kind v0.20.0/go.mod h1:aBlbxg08cauDgZ612shr017/rZwqd7AS563FvpWKPVs=
sigs.k8s.io/kind v0.22.0 h1:z/+yr/azoOfzsfooqRsPw1wjJlqT/ukXP0ShkHwNlsI=
sigs.k8s.io/kind v0.22.0/go.mod h1:aBlbxg08cauDgZ612shr017/rZwqd7AS563FvpWKPVs=
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 h1:XX3Ajgzov2RKUdc5jW3t5jwY7Bo7dcRm+tFxT+NfgY0=
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3/go.mod h1:9n16EZKMhXBNSiUC5kSdFQJkdH3zbxS/JoO619G1VAY=
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 h1:W6cLQc5pnqM7vh3b7HvGNfXrJ/xL6BDMS0v1V/HHg5U=

View File

@ -79,7 +79,7 @@ util::verify_go_version
util::verify_docker
# install kind and kubectl
kind_version=v0.20.0
kind_version=v0.22.0
echo -n "Preparing: 'kind' existence check - "
if util::cmd_exist kind; then
echo "passed"

2
vendor/modules.txt vendored
View File

@ -1822,7 +1822,7 @@ sigs.k8s.io/custom-metrics-apiserver/pkg/registry/external_metrics
## explicit; go 1.18
sigs.k8s.io/json
sigs.k8s.io/json/internal/golang/encoding/json
# sigs.k8s.io/kind v0.20.0
# sigs.k8s.io/kind v0.22.0
## explicit; go 1.16
sigs.k8s.io/kind/pkg/apis/config/defaults
sigs.k8s.io/kind/pkg/apis/config/v1alpha4

View File

@ -18,4 +18,4 @@ limitations under the License.
package defaults
// Image is the default for the Config.Image field, aka the default node image.
const Image = "kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72"
const Image = "kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245"

View File

@ -142,6 +142,17 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
}
}
// Kubeadm will add `node.kubernetes.io/exclude-from-external-load-balancers` on control plane nodes.
// For single node clusters, this means we cannot have a load balancer at all (MetalLB, etc), so remove the label.
if len(allNodes) == 1 {
labelArgs := []string{"--kubeconfig=/etc/kubernetes/admin.conf", "label", "nodes", "--all", "node.kubernetes.io/exclude-from-external-load-balancers-"}
if err := node.Command(
"kubectl", labelArgs...,
).Run(); err != nil {
return errors.Wrap(err, "failed to remove control plane load balancer label")
}
}
// mark success
ctx.Status.End(true)
return nil

View File

@ -21,27 +21,29 @@ import (
)
// PortOrGetFreePort is a helper that either returns the provided port
// if valid or returns a new free port on listenAddr
func PortOrGetFreePort(port int32, listenAddr string) (int32, error) {
// if valid or returns a new free port on listenAddr and a cleanup function
func PortOrGetFreePort(port int32, listenAddr string) (int32, func(), error) {
// in the case of -1 we actually want to pass 0 to the backend to let it pick
if port == -1 {
return 0, nil
return 0, nil, nil
}
// in the case of 0 (unset) we want kind to pick one and supply it to the backend
if port == 0 {
return GetFreePort(listenAddr)
}
// otherwise keep the port
return port, nil
return port, nil, nil
}
// GetFreePort is a helper used to get a free TCP port on the host
func GetFreePort(listenAddr string) (int32, error) {
// returns the free port and a cleanup function, the cleanup function must be called
// after all free ports have been determined to ensure the same port is not returned
// multiple times
func GetFreePort(listenAddr string) (int32, func(), error) {
dummyListener, err := net.Listen("tcp", net.JoinHostPort(listenAddr, "0"))
if err != nil {
return 0, err
return 0, nil, err
}
defer dummyListener.Close()
port := dummyListener.Addr().(*net.TCPAddr).Port
return int32(port), nil
return int32(port), func() { dummyListener.Close() }, nil
}

View File

@ -386,10 +386,13 @@ func generatePortMappings(clusterIPFamily config.ClusterIPFamily, portMappings .
}
// get a random port if necessary (port = 0)
hostPort, err := common.PortOrGetFreePort(pm.HostPort, pm.ListenAddress)
hostPort, releaseHostPortFn, err := common.PortOrGetFreePort(pm.HostPort, pm.ListenAddress)
if err != nil {
return nil, errors.Wrap(err, "failed to get random host port for port mapping")
}
if releaseHostPortFn != nil {
defer releaseHostPortFn()
}
// generate the actual mapping arg
protocol := string(pm.Protocol)

View File

@ -399,10 +399,13 @@ func generatePortMappings(clusterIPFamily config.ClusterIPFamily, portMappings .
}
// get a random port if necessary (port = 0)
hostPort, err := common.PortOrGetFreePort(pm.HostPort, pm.ListenAddress)
hostPort, releaseHostPortFn, err := common.PortOrGetFreePort(pm.HostPort, pm.ListenAddress)
if err != nil {
return nil, errors.Wrap(err, "failed to get random host port for port mapping")
}
if releaseHostPortFn != nil {
defer releaseHostPortFn()
}
// generate the actual mapping arg
protocol := string(pm.Protocol)

View File

@ -54,7 +54,7 @@ func DisplayVersion() string {
}
// versionCore is the core portion of the kind CLI version per Semantic Versioning 2.0.0
const versionCore = "0.20.0"
const versionCore = "0.22.0"
// versionPreRelease is the base pre-release portion of the kind CLI version per
// Semantic Versioning 2.0.0

View File

@ -152,6 +152,11 @@ func validatePortMappings(portMappings []PortMapping) error {
}
for _, portMapping := range portMappings {
if portMapping.HostPort == -1 || portMapping.HostPort == 0 {
// Port -1 and 0 cause a random port to be selected, thus duplicates are allowed
continue
}
addr := net.ParseIP(portMapping.ListenAddress)
addrString := addr.String()