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

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: e2e
name: "e2e"
on:
pull_request:
push:
branches:
- 'main'
- "main"
jobs:
e2e-k8s:
name: e2e-k8s
runs-on: ubuntu-20.04
name: "e2e-k8s"
runs-on: "ubuntu-20.04"
strategy:
matrix:
test_kubernetes_target: [current, prev, prev2]
test_kubernetes_target: ["current", "prev", "prev2"]
env:
TEST_KUBERNETES_TARGET: ${{ matrix.test_kubernetes_target }}
TEST_KUBERNETES_TARGET: "${{ matrix.test_kubernetes_target }}"
steps:
- 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
14 changes: 7 additions & 7 deletions .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: Release Charts
name: "Release Charts"

on: workflow_dispatch
on: "workflow_dispatch"

jobs:
release:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Checkout
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
- name: "Configure Git"
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Run chart-releaser
- name: "Run chart-releaser"
uses: helm/chart-releaser-action@v1.2.1
with:
config: .cr.yaml
config: ".cr.yaml"
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
34 changes: 17 additions & 17 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and Test Charts
name: "Lint and Test Charts"

on:
pull_request:
Expand All @@ -7,57 +7,57 @@ on:

jobs:
lint-test:
runs-on: ubuntu-18.04
runs-on: "ubuntu-18.04"

steps:
- name: Checkout
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Go
- name: "Setup Go"
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: "1.17"

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

- name: Setup helm-docs
- 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
sudo mv /tmp/helm-docs /usr/local/bin

- name: Run helm-docs
- name: "Run helm-docs"
run: helm-docs && git diff --no-patch --exit-code

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

- name: Set up chart-testing
- name: "Set up chart-testing"
uses: helm/chart-testing-action@v2.0.1

- name: Run chart-testing (list-changed)
id: list-changed
- name: "Run chart-testing (list-changed)"
id: "list-changed"
run: |
changed=$(ct list-changed --config ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi

- name: Run chart-testing (lint)
- name: "Run chart-testing (lint)"
run: ct lint --config ct.yaml

- name: Setup kind
- name: "Setup kind"
run: |
make -C e2e setup
make -C e2e init-cluster

- name: Run chart-testing (install)
- name: "Run chart-testing (install)"
run: ct install --config ct.yaml
10 changes: 5 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Main
name: "Main"
on:
pull_request:
push:
branches:
- 'main'
- "main"
jobs:
build:
name: build
runs-on: ubuntu-20.04
name: "build"
runs-on: "ubuntu-20.04"
steps:
- 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
28 changes: 14 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Release
name: "Release"
on:
push:
tags:
- 'v*'
- "v*"
jobs:
release:
name: release
runs-on: ubuntu-20.04
name: "release"
runs-on: "ubuntu-20.04"
steps:
- name: Validate Release Version
id: check_version
- name: "Validate Release Version"
id: "check_version"
run: |
VERSION=$(echo $GITHUB_REF | sed -ne 's/[^0-9]*\([0-9]\+\.[0-9]\+\.[0-9]\+\(-.*\)\?\).*/\1/p')
if [ "$VERSION" = "" ]; then
Expand All @@ -23,24 +23,24 @@ 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 }}
- run: make push IMAGE_TAG=${{ steps.check_version.outputs.version }}
- name: Push branch tag
- name: "Push branch tag"
if: ${{ steps.check_version.outputs.prerelease == 'false' }}
run: |
BRANCH=$(echo ${{ steps.check_version.outputs.version }} | cut -d "." -f 1-2)
make tag IMAGE_TAG=$BRANCH
make push IMAGE_TAG=$BRANCH
- name: Create Release
id: create_release
- name: "Create Release"
id: "create_release"
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release v${{ steps.check_version.outputs.version }}
draft: true
prerelease: ${{ steps.check_version.outputs.prerelease }}
tag_name: "${{ github.ref }}"
release_name: "Release v${{ steps.check_version.outputs.version }}"
draft: "true"
prerelease: "${{ steps.check_version.outputs.prerelease }}"
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
26 changes: 15 additions & 11 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
llamerada-jp marked this conversation as resolved.
Show resolved Hide resolved
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 All @@ -47,7 +52,7 @@ init-cluster: launch-kind autoresizer.img kube-prometheus

.PHONY: test
test:
E2ETEST=1 BINDIR=$(BINDIR) $(GINKGO) --failFast -v .
E2ETEST=1 BINDIR=$(BINDIR) $(GINKGO) --fail-fast -v .

.PHONY: launch-kind
launch-kind: $(TMPDIR)/topolvm
Expand All @@ -66,7 +71,7 @@ stop-lvmd:
$(call call-topolvm-make-task,$@)

define call-topolvm-make-task
if [ -d $(TMPDIR)/topolvm/example ]; then make -C $(TMPDIR)/topolvm/example $(1); fi
if [ -d $(TMPDIR)/topolvm/example ]; then make -C $(TMPDIR)/topolvm/example $(1) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) TMPDIR=$(TMPDIR); fi
endef

$(TMPDIR)/topolvm:
Expand All @@ -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
Loading