Skip to content

Commit 1b924ec

Browse files
committed
Upgrade Kubernetes dependencies
Signed-off-by: Yuki Iwai <[email protected]>
1 parent cd83424 commit 1b924ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2660
-1514
lines changed

Makefile

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2023 The Kubeflow Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
BIN_DIR=_output/cmd/bin
216
REPO_PATH="github.com/kubeflow/mpi-operator"
317
REL_OSARCH="linux/amd64"
@@ -8,22 +22,24 @@ CONTROLLER_VERSION?=v2
822
BASE_IMAGE_SSH_PORT?=2222
923
IMG_BUILDER=docker
1024
LD_FLAGS_V2=" \
11-
-X '${REPO_PATH}/v2/pkg/version.GitSHA=${GitSHA}' \
12-
-X '${REPO_PATH}/v2/pkg/version.Built=${Date}' \
13-
-X '${REPO_PATH}/v2/pkg/version.Version=${RELEASE_VERSION}'"
25+
-X '${REPO_PATH}/pkg/version.GitSHA=${GitSHA}' \
26+
-X '${REPO_PATH}/pkg/version.Built=${Date}' \
27+
-X '${REPO_PATH}/pkg/version.Version=${RELEASE_VERSION}'"
1428
IMAGE_NAME?=mpioperator/mpi-operator
1529
KUBEBUILDER_ASSETS_PATH := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))bin/kubebuilder/bin
16-
KIND_VERSION=v0.11.1
30+
KIND_VERSION=v0.17.0
1731
# This kubectl version supports -k for kustomization.
18-
KUBECTL_VERSION=v1.21.4
19-
32+
KUBECTL_VERSION=v1.25.5
33+
ENVTEST_K8S_VERSION=1.25.0
2034
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
35+
GOARCH=$(shell go env GOARCH)
36+
GOOS=$(shell go env GOOS)
2137

22-
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
38+
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
2339

2440
build: all
2541

26-
all: ${BIN_DIR} fmt tidy lint test mpi-operator.v2
42+
all: ${BIN_DIR} fmt vet tidy lint test mpi-operator.v2
2743

2844
.PHONY: mpi-operator.v2
2945
mpi-operator.v2:
@@ -36,10 +52,14 @@ ${BIN_DIR}:
3652
fmt:
3753
go fmt ./...
3854

55+
.PHONY: vet
56+
vet:
57+
go vet ./...
58+
3959
.PHONY: test
40-
test: export KUBEBUILDER_ASSETS = ${KUBEBUILDER_ASSETS_PATH}
41-
test: bin/kubebuilder
42-
go test -covermode atomic -coverprofile=profile.cov ./...
60+
test:
61+
test: bin/envtest
62+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -covermode atomic -coverprofile=profile.cov ./...
4363

4464
# Only works with CONTROLLER_VERSION=v2
4565
.PHONY: test_e2e
@@ -54,8 +74,10 @@ dev_manifest:
5474

5575
.PHONY: generate
5676
generate:
57-
go generate ./pkg/... ./cmd/... && \
58-
openapi-gen --input-dirs github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1,k8s.io/api/core/v1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/util/intstr,k8s.io/apimachinery/pkg/version,github.com/kubeflow/common/pkg/apis/common/v1 --output-package github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --go-header-file hack/boilerplate/boilerplate.go.txt
77+
go generate ./pkg/... ./cmd/...
78+
hack/update-codegen.sh
79+
$(MAKE) crd
80+
hack/python-sdk/gen-sdk.sh
5981

6082
.PHONY: clean
6183
clean:
@@ -80,50 +102,38 @@ test_images:
80102
tidy:
81103
go mod tidy -go 1.19
82104

83-
GOLANGCI_LINT = ./bin/golangci-lint
84-
bin/golangci-lint:
85-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.50.1
86-
87-
GOOS := $(shell go env GOOS)
88-
GOARCH := $(shell go env GOARCH)
89-
K8S_VERSION := "1.19.2"
90-
bin/kubebuilder:
91-
curl -sSLo envtest-bins.tar.gz "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${K8S_VERSION}-${GOOS}-${GOARCH}.tar.gz"
92-
mkdir -p bin/kubebuilder
93-
tar -C bin/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz
94-
rm envtest-bins.tar.gz
95-
96-
bin/kubectl:
97-
mkdir -p bin
98-
curl -L -o bin/kubectl https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
99-
chmod +x bin/kubectl
100-
101105
.PHONY: lint
102106
lint: bin/golangci-lint ## Run golangci-lint linter
103107
$(GOLANGCI_LINT) run --new-from-rev=origin/master --go 1.19
104108

105-
.PHONY: kind
106-
kind:
107-
go install sigs.k8s.io/kind@${KIND_VERSION}
108-
109109
# Generate CRD
110110
crd: controller-gen
111111
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=crd
112112

113+
.PHONY: bin
114+
bin:
115+
mkdir -p $(PROJECT_DIR)/bin
116+
117+
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
118+
.PHONY: bin/golangci-lint
119+
bin/golangci-lint: bin
120+
@GOBIN=$(PROJECT_DIR)/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
121+
122+
ENVTEST = $(shell pwd)/bin/setup-envtest
123+
.PHONY: envtest
124+
bin/envtest: bin ## Download envtest-setup locally if necessary.
125+
@GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
126+
127+
bin/kubectl: bin
128+
curl -L -o $(PROJECT_DIR)/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/$(GOOS)/$(GOARCH)/kubectl
129+
chmod +x $(PROJECT_DIR)/bin/kubectl
130+
131+
.PHONY: kind
132+
kind: bin
133+
@GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/kind@${KIND_VERSION}
134+
113135
# Download controller-gen locally if necessary
114136
CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen
115-
controller-gen:
116-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
117-
118-
# go-get-tool will 'go get' any package $2 and install it to $1.
119-
define go-get-tool
120-
@[ -f $(1) ] || { \
121-
set -e ;\
122-
TMP_DIR=$$(mktemp -d) ;\
123-
cd $$TMP_DIR ;\
124-
go mod init tmp ;\
125-
echo "Downloading $(2)" ;\
126-
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
127-
rm -rf $$TMP_DIR ;\
128-
}
129-
endef
137+
.PHONY: controller-gen
138+
controller-gen: bin
139+
@GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/controller-tools/cmd/[email protected]

cmd/mpi-operator/app/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ func Run(opt *options.ServerOption) error {
207207
}
208208
}()
209209

210-
rl := &resourcelock.EndpointsLock{
211-
EndpointsMeta: metav1.ObjectMeta{
210+
rl := &resourcelock.LeaseLock{
211+
LeaseMeta: metav1.ObjectMeta{
212212
Namespace: opt.LockNamespace,
213213
Name: controllerName,
214214
},
215-
Client: leaderElectionClientSet.CoreV1(),
215+
Client: leaderElectionClientSet.CoordinationV1(),
216216
LockConfig: resourcelock.ResourceLockConfig{
217217
Identity: id,
218218
EventRecorder: recorder,

0 commit comments

Comments
 (0)