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

ci: add kubernetes version matrix for kind tests #642

Merged
merged 1 commit into from
Sep 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .pipelines/e2e-job-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pr:
paths:
exclude:
- docs/*
- website/*

pool: staging-pool

Expand Down
76 changes: 33 additions & 43 deletions .pipelines/templates/e2e-test-kind.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
jobs:
- job:
displayName: e2e_test_kind/helm
timeoutInMinutes: 10
cancelTimeoutInMinutes: 5
dependsOn:
- lint
- scan_images
- unit_test
- build
workspace:
clean: all
variables:
- group: csi-secrets-store-e2e-kind
steps:
- script: |
export REGISTRY="e2e"
export IMAGE_VERSION=e2e-$(git rev-parse --short HEAD)
echo "Image version: ${IMAGE_VERSION}"
echo "##vso[task.setvariable variable=IMAGE_VERSION]${IMAGE_VERSION}"
echo "##vso[task.setvariable variable=REGISTRY]${REGISTRY}"
make e2e-bootstrap
displayName: "Build image"
env:
CI_KIND_CLUSTER: true
- script: |
make e2e-test
displayName: "Run e2e tests on kind cluster"
env:
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
KEY_NAME: $(KEY_NAME)
KEY_VERSION: $(KEY_VERSION)
KEYVAULT_NAME: $(KEYVAULT_NAME)
SECRET_NAME: $(SECRET_NAME)
TENANT_ID: $(TENANT_ID)
CI_KIND_CLUSTER: true
AZURE_ENVIRONMENT_FILEPATH: "/etc/kubernetes/custom_environment.json"
strategy:
matrix:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we are running with 4 k8s version and not 3?

Copy link
Member Author

Choose a reason for hiding this comment

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

1.19 is still not EOL and 1.22 is the latest. Is there a reason we only want to run 3?

Copy link
Contributor

Choose a reason for hiding this comment

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

We generally support n-2 right? (total 3 releases)

Copy link
Member Author

@aramase aramase Sep 17, 2021

Choose a reason for hiding this comment

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

1.19, 1.20 and 1.21 are the current supported versions. 1.22 is the latest which we're also running test against here. I think it's good to catch regressions with latest kubernetes versions earlier when they're available. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Sounds good.

Also, Should we document explicit k8s version we are supporting? Something like currently supported k8s versions. What say?

Copy link
Member Author

@aramase aramase Sep 17, 2021

Choose a reason for hiding this comment

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

sgtm! We can add the current supported version and versions we test in our docs.

kind_v1_19_11_helm:
KIND_K8S_VERSION: v1.19.11
IS_HELM_TEST: true
kind_v1_20_7_helm:
KIND_K8S_VERSION: v1.20.7
IS_HELM_TEST: true
kind_v1_21_2_helm:
KIND_K8S_VERSION: v1.21.2
IS_HELM_TEST: true
kind_v1_22_0_helm:
KIND_K8S_VERSION: v1.22.0
IS_HELM_TEST: true
kind_v1_19_11_deployment_manifest:
KIND_K8S_VERSION: v1.19.11
IS_HELM_TEST: false
kind_v1_20_7_deployment_manifest:
KIND_K8S_VERSION: v1.20.7
IS_HELM_TEST: false
kind_v1_21_2_deployment_manifest:
KIND_K8S_VERSION: v1.21.2
IS_HELM_TEST: false
kind_v1_22_0_deployment_manifest:
KIND_K8S_VERSION: v1.22.0
IS_HELM_TEST: false

- script: |
make e2e-kind-cleanup
displayName: 'Delete kind cluster'
condition: always()

- job:
displayName: e2e_test_kind/deployment_manifest
timeoutInMinutes: 10
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
- group: csi-secrets-store-e2e-kind
steps:
- script: |
export REGISTRY="e2e"
Expand All @@ -58,7 +51,7 @@ jobs:
CI_KIND_CLUSTER: true
- script: |
make e2e-test
displayName: "Run e2e tests on kind cluster"
displayName: Run e2e tests
env:
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
Expand All @@ -69,11 +62,8 @@ jobs:
TENANT_ID: $(TENANT_ID)
CI_KIND_CLUSTER: true
AZURE_ENVIRONMENT_FILEPATH: "/etc/kubernetes/custom_environment.json"
IS_HELM_TEST: false
REGISTRY: ${REGISTRY}
IMAGE_VERSION: ${IMAGE_VERSION}

- script: |
make e2e-kind-cleanup
displayName: 'Delete kind cluster'
displayName: Delete kind cluster
condition: always()
54 changes: 34 additions & 20 deletions .pipelines/templates/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
jobs:
- job: unit_test
timeoutInMinutes: 10
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
- name: TRIVY_VERSION
value: 0.19.2
steps:
- script: make lint
displayName: Run lint
- script: make build build-windows
displayName: Build
- script: make unit-test
displayName: Run unit tests
- script: bash <(curl -s https://codecov.io/bash) -C $(Build.SourceVersion)
displayName: Upload coverage to codecov
- script: make helm-lint
displayName: Run helm lint
- template: scan-images.yaml
- job: scan_images
timeoutInMinutes: 10
workspace:
clean: all
variables:
- name: TRIVY_VERSION
value: 0.19.2
steps:
- template: scan-images.yaml
- job: lint
timeoutInMinutes: 5
workspace:
clean: all
steps:
- script: make lint
displayName: golangci-lint
- script: make helm-lint
displayName: helm lint
- job: build
timeoutInMinutes: 5
workspace:
clean: all
steps:
- script: make build build-windows
displayName: build
- job: unit_test
timeoutInMinutes: 5
workspace:
clean: all
steps:
- script: make unit-test
displayName: unit test
- script: bash <(curl -s https://codecov.io/bash) -C $(Build.SourceVersion)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

opened #647

Copy link
Member Author

@aramase aramase Sep 20, 2021

Choose a reason for hiding this comment

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

thanks @sozercan!

displayName: Upload coverage to codecov
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BUILDKIT_VERSION ?= v0.8.1

# E2E test variables
KIND_VERSION ?= 0.11.0
KIND_K8S_VERSION ?= 1.21.2
KIND_K8S_VERSION ?= v1.21.2

$(TOOLS_DIR)/golangci-lint: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
cd $(TOOLS_MOD_DIR) && \
Expand Down Expand Up @@ -148,7 +148,7 @@ mod:
.PHONY: e2e-bootstrap
e2e-bootstrap: install-helm
ifdef CI_KIND_CLUSTER
curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KIND_K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv kubectl /usr/local/bin/
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KIND_K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv kubectl /usr/local/bin/
make setup-kind
endif
docker pull $(IMAGE_TAG) || make e2e-container
Expand All @@ -172,15 +172,15 @@ setup-kind:
# Check for existing kind cluster
if [ $$(kind get clusters) ]; then kind delete cluster; fi
# using kind config to create cluster for testing custom cloud environments
TERM=dumb kind create cluster --image kindest/node:v${KIND_K8S_VERSION} --config test/kind-config.yaml
TERM=dumb kind create cluster --image kindest/node:${KIND_K8S_VERSION} --config test/kind-config.yaml

.PHONY: install-helm
install-helm:
helm version --short | grep -q v3 || (curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash)

.PHONY: e2e-local-bootstrap
e2e-local-bootstrap: build
kind create cluster --image kindest/node:v${KIND_K8S_VERSION} --config test/kind-config.yaml
kind create cluster --image kindest/node:${KIND_K8S_VERSION} --config test/kind-config.yaml
make image
kind load docker-image --name kind $(IMAGE_TAG)

Expand Down
6 changes: 1 addition & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
trigger:
branches:
include:
- master
- release-*
trigger: none

pr:
branches:
Expand Down