Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Kubernetes v1.22 #85

Merged
merged 14 commits into from
Jan 11, 2022
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Kubernetes 1.22.1 with envtest because envtest doesn't provide 1.22.4.

$ ./bin/setup-envtest list
(installed)  v1.22.1  linux/amd64
(available)  v1.22.1  linux/amd64
(available)  v1.22.0  linux/amd64
(available)  v1.21.4  linux/amd64
(available)  v1.21.2  linux/amd64
(available)  v1.20.2  linux/amd64
(available)  v1.19.2  linux/amd64
(available)  v1.19.0  linux/amd64
(available)  v1.17.9  linux/amd64
(available)  v1.16.4  linux/amd64
(available)  v1.15.5  linux/amd64
(available)  v1.14.1  linux/amd64
(available)  v1.13.1  linux/amd64
(available)  v1.12.3  linux/amd64
(available)  v1.11.0  linux/amd64
(available)  v1.10.1  linux/amd64

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to use the latest versions of the following tools because these tools don't depend on each other.

- [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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean the next to the next version? In other words, does the new issue for v1.24 if the new supported version is v1.23?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. This text is based on Topolvm maintenance.md.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you choose this version? I checked go.mod of csi-test following maintenance.md, and found csi-test is using ginkgo v1.14.2 and gomega v1.10.4. Or just updating to latest release is enough for this time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pvc-autoscaler isn't a CSI driver, so the pvc-autoscaler doesn't need dependent on the csi-test. So I maybe chose the latest release for ginkgo and gomega.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means this instruction is not true for pvc-autoresizer? Or are there other version indications of ginkgo/gomega elsewhere other than go.mod?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means this instruction is not true for pvc-autoresizer?

Yes, sorry.
I'll remove this section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to apologize :) Thank you fixing.

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
)