Skip to content
Draft
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ __debug_*
test/e2e/inventory*
test/e2e/sa-key*
test/e2e/kubeconfig*

# kubetest2 testing
_rundir
_artifacts*
credentials.json

# binaries
/cloud-controller-manager
/stackit-csi-plugin
/kubetest2-stackit
1 change: 1 addition & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ builds:
ldflags:
- -s -w
- -X github.com/stackitcloud/cloud-provider-stackit/pkg/version.Version={{.Env.VERSION}}
- -X github.com/stackitcloud/cloud-provider-stackit/pkg/csi.DriverName={{.Env.DRIVER_NAME}}

10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ REGISTRY ?= ghcr.io
REPO ?= stackitcloud/cloud-provider-stackit
PLATFORMS ?= amd64 arm64
IS_DEV ?= true
DRIVER_NAME ?=

.PHONY: all
all: verify
Expand All @@ -19,10 +20,12 @@ include ./hack/tools.mk

build: $(BUILD_IMAGES)

stackit-csi-plugin: LDFLAGS = $(if $(DRIVER_NAME),-X github.com/stackitcloud/cloud-provider-stackit/pkg/csi.DriverName=$(DRIVER_NAME))

$(BUILD_IMAGES): $(SOURCES)
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=${GOPROXY} go build \
-trimpath \
-ldflags $(LDFLAGS) \
$(if $(LDFLAGS),-ldflags '$(LDFLAGS)') \
-o $@ \
cmd/$@/main.go

Expand All @@ -40,6 +43,7 @@ image-%: $(APKO) $(KO)
APKO_EXTRA_PACKAGES=$(APKO_EXTRA_PACKAGES) \
LOCAL=$(LOCAL) \
VERSION=$(VERSION) \
DRIVER_NAME=$(DRIVER_NAME) \
PLATFORMS="$(PLATFORMS)" \
REGISTRY=$(REGISTRY) \
REPO=$(REPO)/$* \
Expand All @@ -61,7 +65,7 @@ modules: ## Runs go mod to ensure modules are up to date.

.PHONY: test
test: ## Run tests.
./hack/test.sh ./cmd/... ./pkg/...
./hack/test.sh ./cmd/... ./pkg/... ./test/...

.PHONY: test-cover
test-cover: ## Run tests with coverage.
Expand Down Expand Up @@ -132,13 +136,15 @@ mocks: $(MOCKGEN)
# API mocks
@$(MOCKGEN) -destination ./pkg/mock/loadbalancer/loadbalancer.go -package loadbalancer github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api DefaultAPI
@$(MOCKGEN) -destination ./pkg/mock/iaas/iaas.go -package iaas github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api DefaultAPI
@$(MOCKGEN) -destination ./pkg/mock/ske/ske.go -package ske github.com/stackitcloud/stackit-sdk-go/services/ske/v2api DefaultAPI

# client mocks
@$(MOCKGEN) -destination ./pkg/stackit/metadata/metadata_mock.go -package metadata ./pkg/stackit/metadata IMetadata
@$(MOCKGEN) -destination ./pkg/csi/util/mount/mount_mock.go -package mount ./pkg/csi/util/mount IMount

@$(MOCKGEN) -destination ./pkg/stackit/client/mock/iaas_mock.go -typed -package client ./pkg/stackit/client IaaSClient
@$(MOCKGEN) -destination ./pkg/stackit/client/mock/loadbalancer_mock.go -typed -package client ./pkg/stackit/client LoadBalancingClient
@$(MOCKGEN) -destination ./pkg/stackit/client/mock/ske_mock.go -typed -package client ./pkg/stackit/client SKEClient
@$(MOCKGEN) -destination ./pkg/stackit/client/mock/mock.go -package client ./pkg/stackit/client Factory

.PHONY: generate
Expand Down
10 changes: 10 additions & 0 deletions cmd/kubetest2-stackit/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import (
"github.com/stackitcloud/cloud-provider-stackit/test/e2e/kubetest2-stackit/deployer"
"sigs.k8s.io/kubetest2/pkg/app"
)

func main() {
app.Main(deployer.Name, deployer.New)
}
28 changes: 14 additions & 14 deletions cmd/stackit-csi-plugin/apko-base-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ contents:
packages:
- busybox # required by fsck.xfs as it is a sh script
- ca-certificates
- blkid=~2.41.2
- blockdev=~2.41.2
- e2fsprogs=~1.47.3
- e2fsprogs-extra=~1.47.3
- lsblk=~2.41.2
- mount=~2.41.2
- umount=~2.41.2
- btrfs-progs=~6.17
- udev=~258.1
- util-linux-misc=~2.41.2 # contains fsck
- xfsprogs=~6.17.0
- xfsprogs-core=~6.17.0
- xfsprogs-extra=~6.17.0 # contains xfs_io
- findmnt=~2.41.2
- blkid=~2.42.2
- blockdev=~2.42.2
- btrfs-progs=~7.1
- e2fsprogs=~1.47.4
- e2fsprogs-extra=~1.47.4
- lsblk=~2.42.2
- mount=~2.42.2
- umount=~2.42.2
- udev=~261.2
- util-linux-misc=~2.42.2 # contains fsck
- xfsprogs=~7.1.1
- xfsprogs-core=~7.1.1
- xfsprogs-extra=~7.1.1 # contains xfs_io
- findmnt=~2.42.2

accounts:
run-as: root
Expand Down
7 changes: 4 additions & 3 deletions cmd/stackit-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ func handle(ctx context.Context) {
}
// Initialize cloud
driverOpts := &blockstorage.DriverOpts{
Endpoint: endpoint,
ClusterID: cluster,
PVCLister: csi.GetPVCLister(),
Endpoint: endpoint,
ClusterID: cluster,
DriverName: csi.DriverName,
PVCLister: csi.GetPVCLister(),
}

if legacyStorageMode {
Expand Down
4 changes: 3 additions & 1 deletion deploy/csi-plugin/controllerplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
labels:
app: csi-stackit-controllerplugin
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
serviceAccount: csi-stackit-controller-sa
containers:
- name: csi-attacher
Expand Down Expand Up @@ -64,7 +66,7 @@ spec:
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: Always
imagePullPolicy: "IfNotPresent"
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
Expand Down
14 changes: 13 additions & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Accessing the Cluster](#accessing-the-cluster)
- [Destroying the Cluster](#destroying-the-cluster)
- [Testing Custom Branches or Images](#testing-custom-branches-or-images)
- [Building the kubetest2 STACKIT Deployer](#building-the-kubetest2-stackit-deployer)
- [Running End-to-End (E2E) Tests for the CSI Driver](#running-end-to-end-e2e-tests-for-the-csi-driver)
- [Parallel E2E Test Suite](#parallel-e2e-test-suite)
- [Sequential E2E Test Suite (Snapshots & Backups)](#sequential-e2e-test-suite-snapshots--backups)
Expand Down Expand Up @@ -38,7 +39,6 @@ Before running the script, you must have the following installed and configured
- You must be authenticated. Run `stackit auth login` if you haven't already.
2. **jq:** The `jq` command-line JSON processor.
3. **SSH Key Pair:** The script needs an SSH key pair to access the VM.

- By default, it looks for `$HOME/.ssh/stackit-ccm-test.pub` and `$HOME/.ssh/stackit-ccm-test`.
- You can generate a new key pair with:

Expand Down Expand Up @@ -171,6 +171,18 @@ E2E_DEPLOY_CCM_IMAGE="ghcr.io/stackitcloud/cloud-provider-stackit/cloud-controll
--kubernetes-version <K8S_VERSION>
```

## Building the kubetest2 STACKIT Deployer

The repository now includes a local `kubetest2-stackit` deployer binary for provisioning a single STACKIT SKE cluster during a `kubetest2` run.

Build it with:

```bash
make build
```

The binary is written to the repository root as `./kubetest2-stackit` alongside the existing controller-manager and CSI binaries.

## Running End-to-End (E2E) Tests for the CSI Driver

The CSI E2E test suite validates the full functionality of the CSI driver. Tests are divided into parallel and sequential execution sets to accommodate different operational requirements, particularly for stateful operations like snapshots.
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/google/uuid v1.6.0
github.com/kubernetes-csi/csi-lib-utils v0.24.0
github.com/kubernetes-csi/csi-test/v5 v5.5.0
github.com/octago/sflags v0.3.1
github.com/onsi/ginkgo/v2 v2.32.0
github.com/onsi/gomega v1.42.1
github.com/prometheus/client_golang v1.24.0
Expand All @@ -17,6 +18,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/core v0.26.0
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.13.0
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.15.0
github.com/stackitcloud/stackit-sdk-go/services/ske v1.17.0
go.uber.org/mock v0.6.0
golang.org/x/sync v0.22.0
golang.org/x/sys v0.47.0
Expand All @@ -31,6 +33,8 @@ require (
k8s.io/klog/v2 v2.140.0
k8s.io/mount-utils v0.36.3
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3
sigs.k8s.io/kubetest2 v0.0.0-20260510045745-558f16b589d1
sigs.k8s.io/yaml v1.6.0
)

replace k8s.io/cloud-provider => github.com/stackitcloud/cloud-provider v0.36.0-ske-2
Expand Down Expand Up @@ -81,6 +85,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/moby/sys/mountinfo v0.7.2 // indirect
github.com/moby/term v0.5.2 // indirect
Expand Down Expand Up @@ -136,5 +141,4 @@ require (
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.3 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE
github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2oVvCQ=
Expand Down Expand Up @@ -153,6 +155,8 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/octago/sflags v0.3.1 h1:LW65z20iAQKteEyjsnnc+/lyoCUnIoRuAocggr6RB6A=
github.com/octago/sflags v0.3.1/go.mod h1:hVUkbnYwMU9kZiZJyOAIVN56YiVMMPxgJ46kRZ19jh0=
github.com/onsi/ginkgo/v2 v2.32.0 h1:Hw7s2pVrQo/8Yz5N77qdnpHaoc+c6cC9WIV1Jce+J6E=
github.com/onsi/ginkgo/v2 v2.32.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
github.com/onsi/gomega v1.42.1 h1:iN1rCUX+44NZ1Dc97MPoeFYbFR0vh8zxoxMFwKdyZ6I=
Expand Down Expand Up @@ -190,6 +194,8 @@ github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.15.0 h1:YWpy3VDK
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.15.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.17.0 h1:fQFPbm5cNsTxFy86EDiVBXcxM+7TzXtN44arGYxQWgI=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.17.0/go.mod h1:TbqmZhLMofmfl+HhVl6oHYcI3zvXTm1vRjN3A/fOkM4=
github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs=
github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -369,6 +375,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 h1:hSfpvjjTQXQY2
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
sigs.k8s.io/kubetest2 v0.0.0-20260510045745-558f16b589d1 h1:ttox7lK6ZgN/goexDpOxStOl1Q6j4CwprvK+rkS0c1M=
sigs.k8s.io/kubetest2 v0.0.0-20260510045745-558f16b589d1/go.mod h1:1IMaKFT+Htrbn6ixEZq6GTCk13CP/S0vwujFC5qs55U=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/structured-merge-diff/v6 v6.3.3 h1:u08YRbVUi59ri4YD6cg0UqNM4Dimn0sIl+wldcx5PYw=
Expand Down
41 changes: 41 additions & 0 deletions parallel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -euo pipefail

export STACKIT_SERVICE_ACCOUNT="$(cat ./credentials.json)"

run_id="stackit-parallel"
cluster_name="kt2-par"
kubernetes_version="1.35.6"
rundir_root="${PWD}/_rundir"
artifacts_root="${PWD}/_artifacts-parallel"
testdriver="${rundir_root}/${run_id}/csi-testdriver.yaml"
parallel_nodes="$(getconf _NPROCESSORS_ONLN 2>/dev/null || true)"

if [[ ! "${parallel_nodes}" =~ ^[0-9]+$ ]] || (( parallel_nodes < 1 )); then
parallel_nodes=4
fi

go run ./cmd/kubetest2-stackit \
--run-id "${run_id}" \
--cluster-name "${cluster_name}" \
--rundir "${rundir_root}" \
--artifacts "${artifacts_root}" \
--up \
--test=ginkgo \
--project-id e928aade-ce15-4188-8230-c162c8fb3bd4 \
--region eu01 \
--kubernetes-version "${kubernetes_version}" \
--availability-zone eu01-1 \
--machine-type c2i.2 \
--node-image-name flatcar \
--node-image-version 4593.2.3-containerd2.1.9 \
--csi-image-name ttl.sh/csi-plugin/stackit-csi-plugin \
--csi-image-tag 5h \
-- \
--test-package-version="v${kubernetes_version}" \
--focus-regex="External.Storage" \
--skip-regex="\[Feature:|\[Disruptive\]|\[Serial\]" \
--ginkgo-args="-v" \
--parallel="${parallel_nodes}" \
--test-args="--storage.testdriver=${testdriver}"
Loading