Skip to content

Commit

Permalink
Add aws-s3-csi-controller component (#299)
Browse files Browse the repository at this point in the history
This is part of
#279.

This new component, `aws-s3-csi-controller`, will be the entry point for
our controller component. It's using
[controller-runtime](https://github.com/kubernetes-sigs/controller-runtime),
specifically, it implements
[`Reconciler`](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg#hdr-Reconciler)
interface to reconcile Pods in the cluster. It schedules Mountpoint Pods
in turn to cluster events such as a new workload Pod using a PV backed
by S3 CSI Driver getting scheduled into the cluster. It'd then schedule
a Mountpoint Pod for that workload Pod in the same node to provide
volume for that Pod.

#279 is still
WIP and this component contains some TODOs and it's not in use anywhere
except in tests at the moment.

---

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Signed-off-by: Burak Varlı <[email protected]>
  • Loading branch information
unexge authored Dec 16, 2024
1 parent 672645e commit 0f2689b
Show file tree
Hide file tree
Showing 19 changed files with 1,804 additions and 95 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ jobs:
run: |
export ACTION=install_tools
tests/e2e-kubernetes/scripts/run.sh
- name: Run Controller Tests
run: |
# envtest doesn't support all versions, here K8S_VERSION is a full version like 1.28.13,
# and in order to get latest supported version by envtest we convert it to 1.28.
export K8S_VERSION=${{ matrix.kubernetes-version }}
export ENVTEST_K8S_VERSION="${K8S_VERSION%.*}"
make e2e-controller
- name: Create cluster
run: |
export ACTION=create_cluster
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/credentials
bin/
tests/bin
go.work
go.work.sum
.github/artifacts/benchmark-data.json
Expand Down
41 changes: 40 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ E2E_REGION?=us-east-1
E2E_COMMIT_ID?=local
E2E_KUBECONFIG?=""

# Kubernetes version to use in envtest for controller tests.
ENVTEST_K8S_VERSION ?= 1.30.x

# split words on hyphen, access by 1-index
word-hyphen = $(word $2,$(subst -, ,$1))

Expand Down Expand Up @@ -143,8 +146,13 @@ cover:
fmt:
go fmt ./...

# Run controller tests with envtest.
.PHONY: e2e-controller
e2e-controller: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(TESTBIN) -p path)" go test ./tests/controller/... -ginkgo.v -test.v

.PHONY: e2e
e2e:
e2e: e2e-controller
pushd tests/e2e-kubernetes; \
KUBECONFIG=${E2E_KUBECONFIG} go test -timeout 30m -ginkgo.vv --bucket-region=${E2E_REGION} --commit-id=${E2E_COMMIT_ID}; \
EXIT_CODE=$$?; \
Expand All @@ -158,3 +166,34 @@ check_style:
.PHONY: clean
clean:
rm -rf bin/ && docker system prune

## Binaries used in tests.

TESTBIN ?= $(shell pwd)/tests/bin
$(TESTBIN):
mkdir -p $(TESTBIN)

ENVTEST ?= $(TESTBIN)/setup-envtest
ENVTEST_VERSION ?= release-0.19

.PHONY: envtest
envtest: $(ENVTEST)
$(ENVTEST): $(TESTBIN)
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))

# Copied from https://github.com/kubernetes-sigs/kubebuilder/blob/c32f9714456f7e5e7cc6c790bb87c7e5956e710b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go#L275-L289.
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
# $3 - specific version of package
define go-install-tool
@[ -f "$(1)-$(3)" ] || { \
set -e; \
package=$(2)@$(3) ;\
echo "Downloading $${package}" ;\
rm -f $(1) || true ;\
GOBIN=$(TESTBIN) go install $${package} ;\
mv $(1) $(1)-$(3) ;\
} ;\
ln -sf $(1)-$(3) $(1)
endef
4 changes: 4 additions & 0 deletions cmd/aws-s3-csi-controller/csicontroller/controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package csicontroller

// Name of this component, this needs to be unique as its used as an identifier in logs and metrics.
const Name = "aws-s3-csi-controller"
Loading

0 comments on commit 0f2689b

Please sign in to comment.