Skip to content

Commit

Permalink
Merge pull request #136 from topolvm/support-k8s-1.24
Browse files Browse the repository at this point in the history
support Kubernetes v1.24
  • Loading branch information
satoru-takeuchi authored Jul 25, 2022
2 parents abf8d21 + aa824d5 commit 86b8039
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 304 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@v3
- uses: actions/setup-go@v3
with:
go-version: "1.17"
go-version: "1.18"
- run: make -C e2e setup
- run: make -C e2e init-cluster
- run: make -C e2e test
6 changes: 3 additions & 3 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@v3
with:
go-version: "1.17"
go-version: "1.18"

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

- name: "Setup helm-docs"
run: |
HELM_DOCS_VERSION="1.7.0"
HELM_DOCS_VERSION="1.11.0"
OS=$(uname)
curl -sSfL 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 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@v3
- uses: actions/setup-go@v3
with:
go-version: "1.17"
go-version: "1.18"
- 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@v3
- uses: actions/setup-go@v3
with:
go-version: "1.17"
go-version: "1.18"
- 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.17 as builder
FROM golang:1.18 as builder

WORKDIR /workspace

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

K8S_VERSION = 1.23.3
K8S_VERSION = 1.24.2
ENVTEST_K8S_VERSION = $(shell echo $(K8S_VERSION) | cut -d "." -f 1-2)
CTRLTOOLS_VERSION = 0.7.0
HELM_VERSION = 3.8.0
HELM_DOCS_VERSION = 1.7.0
CTRLTOOLS_VERSION = 0.9.0
HELM_VERSION = 3.9.0
HELM_DOCS_VERSION = 1.11.0

## DON'T EDIT BELOW THIS LINE
GOOS := $(shell go env GOOS)
Expand Down Expand Up @@ -66,7 +66,6 @@ vet: ## Run go vet against code.

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 ./...
source <($(SETUP_ENVTEST) use -p env $(ENVTEST_K8S_VERSION)); \
go test -race -v -count 1 ./... --timeout=60s
Expand Down Expand Up @@ -101,20 +100,14 @@ push: ## Push docker image.
##@ Tools

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

.PHONY: staticcheck
staticcheck: ## Install staticcheck
if ! which staticcheck >/dev/null; then \
env GOFLAGS= go install honnef.co/go/tools/cmd/staticcheck@latest; \
fi

.PHONY: nilerr
nilerr: ## Install nilerr
if ! which nilerr >/dev/null; then \
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
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.23, 1.22, 1.21
- Kubernetes: 1.24, 1.23, 1.22

## Target CSI Drivers

Expand Down
82 changes: 45 additions & 37 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,82 @@ 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.
5. Golang version
- Consider whether the golang should be updated.
### Upgrade procedure

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

Choose the [TopoLVM](https://github.com/topolvm/topolvm/releases) version that supports target Kubernetes version.

We should also update the following files.
To change the version, edit `e2e/Makefile`. If TopoLVM which supports the target Kubernetes version has not released yet, you can specify the commit hash instead of the tag.

- `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
#### Kubernetes

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

### Update dependencies
To change the version, edit the following files.

Next, we should update `go.mod` by the following commands.
- `Makefile`
- `README.md`
- `e2e/Makefile`

We should also 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.

```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 we need to upgrade the `controller-runtime` version, do the following as well.
Read the [`controller-runtime`'s release note](https://github.com/kubernetes-sigs/controller-runtime/releases), and update to the newest version that is compatible with all supported kubernetes versions. If there are breaking changes, we should decide how to manage these changes.

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

Read the kubebuilder's `go.mod`(https://github.com/kubernetes-sigs/kubebuilder/blob/\<upgrading Kubernetes release version\>/go.mod), and check the `controller-tools` version corresponding to `controller-runtime`. To change the version, edit `Makefile`.

#### Depending tools

The following tools do not depend on other software, use latest versions.
- [helm](https://github.com/helm/helm/releases)
- To change the version, edit the following files.
- `.github/workflows/helm.yaml`
- `Makefile`
- [helm-docs](github.com/norwoodj/helm-docs/releases)
- To change the version, edit the following files.
- `.github/workflows/helm.yaml`
- `Makefile`
- [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus/releases)
- To change the version, edit `Makefile`.

#### Depending modules

Read `kubernetes' go.mod`(https://github.com/kubernetes/kubernetes/blob/\<upgrading Kubernetes release version\>/go.mod), and update the `prometheus/*` modules. Here is the example to update `prometheus/client_golang`.

```
$ VERSION=v1.12.1
$ go get github.com/prometheus/client_golang@$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
#### Golang version

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

### Prepare for the next upgrade
#### Final check

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

ifeq ($(TEST_KUBERNETES_TARGET),current)
KUBERNETES_VERSION := 1.23.3
TOPOLVM_VERSION := v0.14.0
KUBERNETES_VERSION := 1.24.2
else ifeq ($(TEST_KUBERNETES_TARGET),prev)
KUBERNETES_VERSION := 1.22.4
TOPOLVM_VERSION := v0.14.0
KUBERNETES_VERSION := 1.23.6
else ifeq ($(TEST_KUBERNETES_TARGET),prev2)
KUBERNETES_VERSION := 1.21.2
# Kubernetes 1.21 does not support KubeSchedulerConfiguration API version v1beta2,
# so use older version of TopoLVM
TOPOLVM_VERSION := v0.10.4
KUBERNETES_VERSION := 1.22.9
endif
export KUBERNETES_VERSION

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

Expand Down
28 changes: 28 additions & 0 deletions e2e/autoresizer-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ kind: Cluster
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
apiVersion: "kubeadm.k8s.io/v1beta3"
kind: ClusterConfiguration
metadata:
name: config
kubernetesVersion: "v@KUBERNETES_VERSION@"
networking:
serviceSubnet: 10.0.0.0/16
scheduler:
extraVolumes:
- name: "config"
hostPath: /mnt/host/scheduler
mountPath: /var/lib/scheduler
readOnly: true
extraArgs:
config: /var/lib/scheduler/scheduler-config.yaml
- |
# v1beta2 is for Kubernetes 1.22
# TODO: remove this when we drop support for Kubernetes 1.22
apiVersion: "kubeadm.k8s.io/v1beta2"
kind: ClusterConfiguration
metadata:
Expand All @@ -19,6 +37,16 @@ kubeadmConfigPatches:
extraArgs:
config: /var/lib/scheduler/scheduler-config.yaml
- |
apiVersion: "kubeadm.k8s.io/v1beta3"
kind: JoinConfiguration
metadata:
name: config
nodeRegistration:
kubeletExtraArgs:
volume-stats-agg-period: 1s # speed up metric updates such as kubelet_volume_stats_used_bytes
- |
# v1beta2 is for Kubernetes 1.22
# TODO: remove this when we drop support for Kubernetes 1.22
apiVersion: "kubeadm.k8s.io/v1beta2"
kind: JoinConfiguration
metadata:
Expand Down
49 changes: 29 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,70 @@ go 1.17
require (
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/onsi/gomega v1.18.1
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/client_model v0.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
github.com/prometheus/common v0.32.1
github.com/spf13/cobra v1.4.0
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/client-go v0.24.2
sigs.k8s.io/controller-runtime v0.12.1
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
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/emicklei/go-restful v2.9.5+incompatible // 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/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // 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/gnostic v0.5.7-v3refs // 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/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // 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/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/procfs v0.7.3 // 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/net v0.0.0-20220127200216-cd36cc0744dd // 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/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // 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
k8s.io/apiextensions-apiserver v0.24.0 // indirect
k8s.io/component-base v0.24.0 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
)
Loading

0 comments on commit 86b8039

Please sign in to comment.