Skip to content

Commit

Permalink
Support Kubernetes v1.23
Browse files Browse the repository at this point in the history
Signed-off-by: Shinya Hayashi <shinya-hayashi@cybozu.co.jp>
  • Loading branch information
peng225 committed Feb 7, 2022
1 parent 7078bac commit 544329b
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- run: make -C e2e setup
- run: make -C e2e init-cluster
- run: make -C e2e test
8 changes: 4 additions & 4 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17

- name: Setup Helm
uses: azure/setup-helm@v1
with:
version: v3.5.0
version: v3.8.0

- name: Setup helm-docs
run: |
HELM_DOCS_VERSION="1.5.0"
HELM_DOCS_VERSION="1.7.0"
OS=$(uname)
curl -L -sS https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_${OS}_x86_64.tar.gz \
| tar zx -C /tmp
Expand All @@ -38,7 +38,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.10

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.0.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- run: make setup
- run: make
- run: make test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- run: make setup
- run: make image
- run: make tag IMAGE_TAG=${{ steps.check_version.outputs.version }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage1: Build the pvc-autoresizer binary
FROM golang:1.16 as builder
FROM golang:1.17 as builder

WORKDIR /workspace

Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Makefile for pvc-autoresizer

ENVTEST_K8S_VERSION = 1.22.1
K8S_VERSION = 1.23.3
ENVTEST_K8S_VERSION = $(shell echo $(K8S_VERSION) | cut -d "." -f 1-2)
CTRLTOOLS_VERSION = 0.7.0
HELM_VERSION = 3.7.2
HELM_DOCS_VERSION = 1.6.0
HELM_VERSION = 3.8.0
HELM_DOCS_VERSION = 1.7.0

## DON'T EDIT BELOW THIS LINE
GOOS := $(shell go env GOOS)
Expand Down Expand Up @@ -68,7 +69,7 @@ test: manifests generate tools fmt vet ## Run tests.
test -z "$$($(shell go env GOPATH)/bin/nilerr ./... 2>&1 | tee /dev/stderr)"
go install ./...
source <($(SETUP_ENVTEST) use -p env $(ENVTEST_K8S_VERSION)); \
go test -race -v -count 1 ./...
go test -race -v -count 1 ./... --timeout=60s

##@ Build

Expand Down Expand Up @@ -125,7 +126,7 @@ $(SETUP_ENVTEST):
setup: # Setup tools
mkdir -p bin
GOBIN=$(BINDIR) go install sigs.k8s.io/controller-tools/cmd/controller-gen@v$(CTRLTOOLS_VERSION)
curl -o $(BINDIR)/kubectl -sfL https://storage.googleapis.com/kubernetes-release/release/v$(ENVTEST_K8S_VERSION)/bin/linux/amd64/kubectl
curl -o $(BINDIR)/kubectl -sfL https://storage.googleapis.com/kubernetes-release/release/v$(K8S_VERSION)/bin/linux/amd64/kubectl
chmod a+x $(BINDIR)/kubectl
GOBIN=$(BINDIR) go install github.com/norwoodj/helm-docs/cmd/helm-docs@v$(HELM_DOCS_VERSION)
curl -L -sS https://get.helm.sh/helm-v$(HELM_VERSION)-linux-amd64.tar.gz \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It queries the volume usage metrics from Prometheus that collects metrics from `

## Supported environments

- Kubernetes: 1.22, 1.21, 1.20
- Kubernetes: 1.23, 1.22, 1.21

## Target CSI Drivers

Expand Down
8 changes: 5 additions & 3 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ First of all, we should have a look at the release notes in the order below.
- [helm-docs](github.com/norwoodj/helm-docs/releases)
- [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus/releases)
4. Depending modules
- Read [kubernetes go.mod](https://github.com/kubernetes/kubernetes/blob/master/go.mod), and update the `prometheus/*` modules.
- Read [kubernetes go.mod](https://github.com/kubernetes/kubernetes/blob/master/go.mod), and update the `prometheus/*` modules.
5. Golang version
- Consider whether the golang should be updated.

We should write down in the github issue of this task what are the important changes and the required actions to manage incompatibilities if exist.
The format is up to you.
Expand All @@ -38,6 +40,7 @@ We should also update the following files.
- `README.md`: Documentation which indicates what versions are supported by pvc-autoresizer
- `Makefile`: Makefile for running envtest
- `e2e/Makefile`: Makefile for running e2e tests
- `.github/workflows`: Configuration files of github actions

`git grep <the kubernetes version which support will be dropped>, `git grep image:`, and `git grep -i VERSION` might help to avoid overlooking necessary changes.

Expand All @@ -46,12 +49,11 @@ We should also update the following files.
Next, we should update `go.mod` by the following commands.

```bash
# If the new kubernetes version is v1.x.y", the `VERSION` will be v0.x.y.
$ VERSION=<upgrading Kubernetes release version>
$ go get k8s.io/api@v${VERSION} k8s.io/apimachinery@v${VERSION} k8s.io/client-go@v${VERSION}
```

If the new kubernetes version is v1.x.y", the new pvc-autoresizer's version will be v0.x.y.

If we need to upgrade the `controller-runtime` version, do the following as well.

```bash
Expand Down
22 changes: 13 additions & 9 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
TEST_KUBERNETES_TARGET ?= current

ifeq ($(TEST_KUBERNETES_TARGET),current)
KUBERNETES_VERSION := 1.22.4
KUBERNETES_VERSION := 1.23.3
TOPOLVM_VERSION := 0.10.5
else ifeq ($(TEST_KUBERNETES_TARGET),prev)
KUBERNETES_VERSION := 1.21.2
KUBERNETES_VERSION := 1.22.4
TOPOLVM_VERSION := 0.10.5
else ifeq ($(TEST_KUBERNETES_TARGET),prev2)
KUBERNETES_VERSION := 1.20.7
KUBERNETES_VERSION := 1.21.2
# Kubernetes 1.21 does not support KubeSchedulerConfiguration API version v1beta2,
# so use older version of TopoLVM
TOPOLVM_VERSION := 0.10.4
endif
export KUBERNETES_VERSION

KUBE_PROMETHEUS_VERSION := 0.9.0
TOPOLVM_VERSION := 0.10.3
KUBE_PROMETHEUS_VERSION := 0.10.0
KIND_NODE_IMAGE=kindest/node:v$(KUBERNETES_VERSION)
KIND_CLUSTER_NAME := autoresizer-e2e

GINKGO_VERSION := $(shell awk '/github.com\/onsi\/ginkgo/ {print substr($$2, 2)}' ../go.mod)
GINKGO_VERSION := $(shell awk '/github.com\/onsi\/ginkgo\/v2/ {print substr($$2, 2)}' ../go.mod)

SUDO := sudo
BINDIR := $(shell pwd)/../bin
Expand All @@ -31,12 +35,13 @@ setup:
mkdir -p $(BINDIR)
curl -o $(BINDIR)/kubectl -sfL https://storage.googleapis.com/kubernetes-release/release/v$(KUBERNETES_VERSION)/bin/linux/amd64/kubectl
chmod a+x $(BINDIR)/kubectl
GOBIN=$(BINDIR) go install github.com/onsi/ginkgo/ginkgo@v$(GINKGO_VERSION)
GOBIN=$(BINDIR) go install github.com/onsi/ginkgo/v2/ginkgo@v$(GINKGO_VERSION)

.PHONY: init-cluster
init-cluster: launch-kind autoresizer.img kube-prometheus
# https://github.com/prometheus-operator/kube-prometheus/tree/v$(KUBE_PROMETHEUS_VERSION)#quickstart"
$(KUBECTL) apply -f kube-prometheus/manifests/setup
# add options to avoid applying error (https://github.com/prometheus-community/helm-charts/issues/1500#issuecomment-969149744)
$(KUBECTL) apply -f kube-prometheus/manifests/setup --force-conflicts=true --server-side
until $(KUBECTL) get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
$(KUBECTL) apply -f kube-prometheus/manifests/
# setup autoresizer
Expand Down Expand Up @@ -88,7 +93,6 @@ kube-prometheus:
.PHONY: clean
clean: stop-lvmd
rm -rf \
$(BINDIR) \
$(TMPDIR) \
autoresizer.img \
kube-prometheus
4 changes: 2 additions & 2 deletions e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -140,7 +140,7 @@ var _ = Describe("pvc-autoresizer", func() {
var resources []resource

var _ = AfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
if CurrentSpecReport().Failed() {
failedTest = true
} else {
By("[AfterEach] cleanup resources")
Expand Down
69 changes: 58 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,65 @@
module github.com/topolvm/pvc-autoresizer

go 1.16
go 1.17

require (
github.com/go-logr/logr v0.4.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.17.0
github.com/go-logr/logr v1.2.0
github.com/onsi/ginkgo/v2 v2.1.1
github.com/onsi/gomega v1.18.0
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.26.0
github.com/spf13/cobra v1.2.1
k8s.io/api v0.22.4
k8s.io/apimachinery v0.22.4
k8s.io/client-go v0.22.4
sigs.k8s.io/controller-runtime v0.10.3
sigs.k8s.io/yaml v1.2.0
github.com/prometheus/common v0.28.0
github.com/spf13/cobra v1.3.0
k8s.io/api v0.23.3
k8s.io/apimachinery v0.23.3
k8s.io/client-go v0.23.3
sigs.k8s.io/controller-runtime v0.11.0
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/zapr v1.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiextensions-apiserver v0.23.0 // indirect
k8s.io/component-base v0.23.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
)
Loading

0 comments on commit 544329b

Please sign in to comment.