Skip to content

Commit

Permalink
Merge pull request #85 from topolvm/support-k8s-1.22
Browse files Browse the repository at this point in the history
Support Kubernetes v1.22
  • Loading branch information
daichimukai committed Jan 11, 2022
2 parents 34b1384 + 1981530 commit 6fcc42d
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 123 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/bin
/.vscode
/.idea
/testbin
/vendor
30 changes: 14 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Makefile for pvc-autoresizer

ENVTEST_K8S_VERSION = 1.19.2
KUBEBUILDER_VERSION = 3.1.0
CTRLTOOLS_VERSION = 0.6.0
CTRLRUNTIME_VERSION = 0.8.3
HELM_VERSION = 3.5.0
HELM_DOCS_VERSION = 1.5.0

export ENVTEST_K8S_VERSION
ENVTEST_K8S_VERSION = 1.22.1
CTRLTOOLS_VERSION = 0.7.0
HELM_VERSION = 3.7.2
HELM_DOCS_VERSION = 1.6.0

## DON'T EDIT BELOW THIS LINE
GOOS := $(shell go env GOOS)
Expand Down Expand Up @@ -67,16 +63,12 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: manifests generate tools fmt vet ## Run tests.
$(shell go env GOPATH)/bin/staticcheck ./...
test -z "$$($(shell go env GOPATH)/bin/nilerr ./... 2>&1 | tee /dev/stderr)"
go install ./...

mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v$(CTRLRUNTIME_VERSION)/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(shell pwd)
go test -race -v -count 1 ./...
source <($(SETUP_ENVTEST) use -p env $(ENVTEST_K8S_VERSION)); \
go test -race -v -count 1 ./...

##@ Build

Expand Down Expand Up @@ -108,7 +100,7 @@ push: ## Push docker image.
##@ Tools

.PHONY: tools
tools: staticcheck nilerr
tools: staticcheck nilerr setup-envtest

.PHONY: staticcheck
staticcheck: ## Install staticcheck
Expand All @@ -122,10 +114,16 @@ nilerr: ## Install nilerr
env GOFLAGS= go install github.com/gostaticanalysis/nilerr/cmd/nilerr@latest; \
fi

SETUP_ENVTEST := $(BINDIR)/setup-envtest
.PHONY: setup-envtest
setup-envtest: $(SETUP_ENVTEST) ## Download setup-envtest locally if necessary
$(SETUP_ENVTEST):
# see https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest
GOBIN=$(BINDIR) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: setup
setup: # Setup tools
mkdir -p bin
curl -sfL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v$(KUBEBUILDER_VERSION)/kubebuilder_$(GOOS)_$(GOARCH) > $(BINDIR)/kubebuilder
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
chmod a+x $(BINDIR)/kubectl
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ It queries the volume usage metrics from Prometheus that collects metrics from `

**Status**: beta

## Supported environments

- Kubernetes: 1.22, 1.21, 1.20

## Target CSI Drivers

`pvc-autoresizer` supports CSI Drivers that meet the following requirements:
Expand Down
76 changes: 76 additions & 0 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Maintenance guide
=================

How to change the supported Kubernetes minor versions
-------------------------------------------

pvc-autoresizer depends on some Kubernetes repositories like `k8s.io/client-go` and should support 3 consecutive Kubernetes versions at a time.
Issues and PRs related to the last upgrade task also help you understand how to upgrade the supported versions,
so checking them together(e.g https://github.com/topolvm/pvc-autoresizer/pull/85) with this guide is recommended when you do this task.

### Check release notes

First of all, we should have a look at the release notes in the order below.

1. TopoLVM
- Choose the [TopoLVM](https://github.com/topolvm/topolvm/releases) version that supported target Kubernetes version.
2. Kubernetes
- Choose the next version and check the [release note](https://kubernetes.io/docs/setup/release/notes/). e.g. 1.17, 1.18, 1.19 -> 1.18, 1.19, 1.20
- Read the [release note](https://github.com/kubernetes-sigs/controller-runtime/releases), and check whether there are serious security fixes and whether the new minor version is compatible with older versions from the pvc-autoresizer's point of view. If there are breaking changes, we should decide how to manage these changes.
- Read the [kubebuilder go.mod](https://github.com/kubernetes-sigs/kubebuilder/blob/master/go.mod), and check the controller-tools version corresponding to controller-runtime.
3. Depending tools
- They does not depend on other software, use latest versions.
- [helm](https://github.com/helm/helm/releases)
- [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.

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.

Basically, we should pay attention to breaking changes and security fixes first.

### Update written versions

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

`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.

### Update dependencies

Next, we should update `go.mod` by the following commands.

```bash
$ 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
$ VERSION=<upgrading controller-runtime version>
$ go get sigs.k8s.io/controller-runtime@v${VERSION}
```

Then, please tidy up the dependencies.

```bash
$ go mod tidy
```

These are minimal changes for the Kubernetes upgrade, but if there are some breaking changes found in the release notes, you have to handle them as well in this step.

### Release the changes

We should update [RELEASE.md](../RELEASE.md) to add the entry for the new pvc-autoresizer's version.

### Prepare for the next upgrade

We should create an issue for the next upgrade. Besides, Please update this document if we find something to be updated.
16 changes: 9 additions & 7 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
TEST_KUBERNETES_TARGET ?= current

ifeq ($(TEST_KUBERNETES_TARGET),current)
KUBERNETES_VERSION := 1.21.2
KUBERNETES_VERSION := 1.22.4
else ifeq ($(TEST_KUBERNETES_TARGET),prev)
KUBERNETES_VERSION := 1.20.7
KUBERNETES_VERSION := 1.21.2
else ifeq ($(TEST_KUBERNETES_TARGET),prev2)
KUBERNETES_VERSION := 1.19.11
KUBERNETES_VERSION := 1.20.7
endif
export KUBERNETES_VERSION

KUBE_PROMETHEUS_VERSION := 0.8.0
TOPOLVM_VERSION := 3f3854c808df5d68f46ba316e96bfe6bb7edcd48
KUBE_PROMETHEUS_VERSION := 0.9.0
TOPOLVM_VERSION := 0.10.3
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)

SUDO := sudo
BINDIR := $(shell pwd)/../bin
TMPDIR := /tmp/autoresizer
Expand All @@ -29,7 +31,7 @@ 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@latest
GOBIN=$(BINDIR) go install github.com/onsi/ginkgo/ginkgo@v$(GINKGO_VERSION)

.PHONY: init-cluster
init-cluster: launch-kind autoresizer.img kube-prometheus
Expand Down Expand Up @@ -69,7 +71,7 @@ endef

$(TMPDIR)/topolvm:
git clone https://github.com/topolvm/topolvm.git $@
cd $@ && git checkout $(TOPOLVM_VERSION)
cd $@ && git checkout v$(TOPOLVM_VERSION)
make -C $(TMPDIR)/topolvm/example setup

autoresizer.img:
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.16
require (
github.com/go-logr/logr v0.4.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/onsi/gomega v1.17.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.1.1
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
sigs.k8s.io/controller-runtime v0.9.2
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
)

0 comments on commit 6fcc42d

Please sign in to comment.