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

## Confirmed environments
bells17 marked this conversation as resolved.
Show resolved Hide resolved

- Kubernetes: 1.22, 1.21, 1.20

## Target CSI Drivers

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

This is the maintenance guide for pvc-autoresizer.
Copy link
Member

Choose a reason for hiding this comment

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

This line is not necessary because it's clear that this document is for maintenance by the document title.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


How to upgrade supported Kubernetes version
bells17 marked this conversation as resolved.
Show resolved Hide resolved
-------------------------------------------

pvc-autoresizer depends on some Kubernetes repositories like `k8s.io/client-go` and should support 3 consecutive Kubernets versions at a time.
bells17 marked this conversation as resolved.
Show resolved Hide resolved
Here is the guide for how to upgrade the supported versions.
Copy link
Member

Choose a reason for hiding this comment

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

This line is not necessary because it's clear that this section is for changing the supported Kubernetes versions by the section title.

Issues and PRs related to the last upgrade task also help you understand how to upgrade the supported versions,
so checking them together with this guide is recommended when you do this task.
Copy link
Member

Choose a reason for hiding this comment

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

How about adding the link to this PR?

#85


### Check release notes

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

1. 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 which version is compatible with the Kubernetes versions.
bells17 marked this conversation as resolved.
Show resolved Hide resolved
- 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.
2. TopoLVM
Copy link
Member

Choose a reason for hiding this comment

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

How about changing the order of step 1 and step 2? It' because we should select the versions supported by topolvm in any case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

- Choose the [TopoLVM](https://github.com/topolvm/topolvm/releases) version that supported target Kubernetes version.
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.
- Read [csi-test go.mod](https://github.com/kubernetes-csi/csi-test/blob/master/go.mod), and update the `ginkgo` and `gomega` modules.

Please write down to the Github issue of this task what kinds of changes we find in the release note and what we are going to do and NOT going to do to address the changes.
bells17 marked this conversation as resolved.
Show resolved Hide resolved
The format is up to you, but this is very important to keep track of what changes are made in this task, so please do not forget to do it.
bells17 marked this conversation as resolved.
Show resolved Hide resolved

Basically, we should pay attention to breaking changes and security fixes first.
If we find some interesting features added in new versions, please consider if we are going to use them or not and make a GitHub issue to incorporate them after the upgrading task is done.
Copy link
Member

Choose a reason for hiding this comment

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

I think this line is not necessary because it seems to be clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


### Update written versions

Once we decide the versions we are going to upgrade, we should update the versions written in the following files manually.
bells17 marked this conversation as resolved.
Show resolved Hide resolved

- `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 1.18`, `git grep image:`, and `git grep -i VERSION` might help us avoid overlooking necessary changes.
bells17 marked this conversation as resolved.
Show resolved Hide resolved
Please update the versions in the code and docs with great care.
Copy link
Member

Choose a reason for hiding this comment

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

This line is not necesssary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


### Update dependencies

Next, we should update `go.mod` by the following commands.
Please note that Kubernetes v1 corresponds with v0 for the release tags. For example, v1.17.2 corresponds with the `v0.17.2` tag.
Copy link
Member

Choose a reason for hiding this comment

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

How about "If the new kubernetes version is v1.x.y", the new pvc-autoresizer's version will be v0.x.y"? In addition, it's better to place this line after the following command lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


```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 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 follow [RELEASE.md](../RELEASE.md) and upgrade the minor version.
bells17 marked this conversation as resolved.
Show resolved Hide resolved

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

14 changes: 8 additions & 6 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 := 7c269d04b0b8ac8569c8c76c69569a8f9a0b92a8
Copy link
Contributor Author

Choose a reason for hiding this comment

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

7c269d04b0b8ac8569c8c76c69569a8f9a0b92a8 -> https://github.com/topolvm/topolvm/tree/v0.10.3

Copy link
Contributor

Choose a reason for hiding this comment

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

How about simply specifying v0.13.0 instead of commit hash?

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
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
)