-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation of csi driver lvm extension (#1)
- Loading branch information
Showing
67 changed files
with
5,135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name-template: 'v$RESOLVED_VERSION' | ||
tag-template: 'v$RESOLVED_VERSION' | ||
|
||
template: | | ||
## General Changes | ||
$CHANGES | ||
categories: | ||
- title: '🚀 Features' | ||
labels: | ||
- 'feature' | ||
- 'enhancement' | ||
- title: '🐛 Bug Fixes' | ||
labels: | ||
- 'fix' | ||
- 'bugfix' | ||
- 'bug' | ||
|
||
version-resolver: | ||
major: | ||
labels: | ||
- 'major' | ||
minor: | ||
labels: | ||
- 'minor' | ||
patch: | ||
labels: | ||
- 'patch' | ||
default: patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
name: Docker Build Action | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
name: Docker Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Log in to the container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Make tag | ||
run: | | ||
[ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true | ||
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true | ||
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true | ||
- name: Build and push image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
name: Release Drafter Action | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: release-drafter/release-drafter@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: Test Action | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Test and Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: false | ||
|
||
- name: Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
args: --build-tags integration -p bugs -p unused --timeout=3m | ||
|
||
- name: Test | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea/ | ||
vendor | ||
tools/vendor | ||
VERSION | ||
helm | ||
.vscode | ||
hack/tools/bin/* | ||
bin | ||
.ci/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM golang:1.23 AS builder | ||
|
||
WORKDIR /go/src/github.com/metal-stack/gardener-extension-csi-driver-lvm | ||
COPY . . | ||
RUN make install \ | ||
&& strip /go/bin/gardener-extension-csi-driver-lvm | ||
|
||
FROM alpine:3.21 | ||
WORKDIR / | ||
COPY charts /charts | ||
COPY --from=builder /go/bin/gardener-extension-csi-driver-lvm /gardener-extension-csi-driver-lvm | ||
CMD ["/gardener-extension-csi-driver-lvm"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM alpine:3.21 | ||
COPY bin/gardener-extension-csi-driver-lvm /gardener-extension-csi-driver-lvm | ||
CMD ["/gardener-extension-csi-driver-lvm"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 by the metal-stack. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
ENSURE_GARDENER_MOD := $(shell go get github.com/gardener/gardener@$$(go list -m -f "{{.Version}}" github.com/gardener/gardener)) | ||
GARDENER_HACK_DIR := $(shell go list -m -f "{{.Dir}}" github.com/gardener/gardener)/hack | ||
IMAGE_TAG := $(or ${GITHUB_TAG_NAME}, latest) | ||
REGISTRY := ghcr.io/metal-stack | ||
IMAGE_PREFIX := $(REGISTRY) | ||
REPO_ROOT := $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))") | ||
HACK_DIR := $(REPO_ROOT)/hack | ||
HOSTNAME := $(shell hostname) | ||
LD_FLAGS := "-w -X github.com/metal-stack/gardener-extension-csi-driver-lvm/pkg/version.Version=$(IMAGE_TAG)" | ||
VERIFY := true | ||
LEADER_ELECTION := false | ||
IGNORE_OPERATION_ANNOTATION := false | ||
WEBHOOK_CONFIG_URL := localhost | ||
|
||
GOLANGCI_LINT_VERSION := v1.62.0 | ||
GO_VERSION := 1.23 | ||
|
||
ifeq ($(CI),true) | ||
DOCKER_TTY_ARG="" | ||
else | ||
DOCKER_TTY_ARG=t | ||
endif | ||
|
||
export GO111MODULE := on | ||
|
||
TOOLS_DIR := $(HACK_DIR)/tools | ||
include $(GARDENER_HACK_DIR)/tools.mk | ||
|
||
################################################################# | ||
# Rules related to binary build, Docker image build and release # | ||
################################################################# | ||
|
||
.PHONY: tidy | ||
tidy: | ||
@GO111MODULE=on go mod tidy | ||
@mkdir -p $(REPO_ROOT)/.ci/hack && cp $(GARDENER_HACK_DIR)/.ci/* $(REPO_ROOT)/.ci/hack/ && chmod +xw $(REPO_ROOT)/.ci/hack/* | ||
|
||
.PHONY: build | ||
build: | ||
go build -ldflags $(LD_FLAGS) -tags netgo -o bin/gardener-extension-csi-driver-lvm ./cmd/gardener-extension-csi-driver-lvm | ||
|
||
.PHONY: install | ||
install: tidy $(HELM) | ||
@LD_FLAGS="-w -X github.com/gardener/$(EXTENSION_PREFIX)-$(NAME)/pkg/version.Version=$(VERSION)" \ | ||
bash $(GARDENER_HACK_DIR)/install.sh ./... | ||
|
||
.PHONY: docker-image | ||
docker-image: | ||
@docker build --no-cache \ | ||
--build-arg VERIFY=$(VERIFY) \ | ||
--tag $(IMAGE_PREFIX)/gardener-extension-csi-driver-lvm:$(IMAGE_TAG) \ | ||
--file Dockerfile --memory 6g . | ||
|
||
.PHONY: docker-push | ||
docker-push: | ||
@docker push $(IMAGE_PREFIX)/gardener-extension-csi-driver-lvm:$(IMAGE_TAG) | ||
|
||
##################################################################### | ||
# Rules for verification, formatting, linting, testing and cleaning # | ||
##################################################################### | ||
|
||
.PHONY: revendor | ||
revendor: | ||
@GO111MODULE=on go mod vendor | ||
@GO111MODULE=on go mod tidy | ||
@chmod +x $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/* | ||
@chmod +x $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/.ci/* | ||
@$(REPO_ROOT)/hack/update-github-templates.sh | ||
|
||
.PHONY: clean | ||
clean: | ||
@$(shell find ./example -type f -name "controller-registration.yaml" -exec rm '{}' \;) | ||
@bash $(GARDENER_HACK_DIR)/clean.sh ./cmd/... ./pkg/... | ||
|
||
.PHONY: check-generate | ||
check-generate: | ||
@$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/check-generate.sh $(REPO_ROOT) | ||
|
||
.PHONY: generate | ||
generate: $(VGOPATH) $(HELM) $(YQ) | ||
# echo $(shell git -c safe.directory=/go/src/github.com/metal-stack/gardener-extension-csi-driver-lvm describe --abbrev=0 --tags) > VERSION | ||
@REPO_ROOT=$(REPO_ROOT) VGOPATH=$(VGOPATH) GARDENER_HACK_DIR=$(GARDENER_HACK_DIR) bash $(GARDENER_HACK_DIR)/generate-sequential.sh ./charts/... ./cmd/... ./pkg/... | ||
|
||
.PHONY: generate-in-docker | ||
generate-in-docker: tidy install $(HELM) $(YQ) | ||
docker run --rm -i$(DOCKER_TTY_ARG) -v $(PWD):/go/src/github.com/metal-stack/gardener-extension-csi-driver-lvm golang:$(GO_VERSION) \ | ||
sh -c "cd /go/src/github.com/metal-stack/gardener-extension-csi-driver-lvm \ | ||
&& make generate \ | ||
&& chown -R $(shell id -u):$(shell id -g) ." | ||
|
||
.PHONY: test | ||
test: | ||
go test -v ./... | ||
|
||
.PHONY: push-to-gardener-local | ||
push-to-gardener-local: | ||
CGO_ENABLED=1 go build \ | ||
-ldflags "-extldflags '-static -s -w'" \ | ||
-tags 'osusergo netgo static_build' \ | ||
-o bin/gardener-extension-csi-driver-lvm \ | ||
./cmd/gardener-extension-csi-driver-lvm | ||
docker build -f Dockerfile.dev -t ghcr.io/metal-stack/gardener-extension-csi-driver-lvm:latest . | ||
kind --name gardener-local load docker-image ghcr.io/metal-stack/gardener-extension-csi-driver-lvm:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# gardener-extension-csi-driver-lvm | ||
|
||
Provides a Gardener extension for managing [csi-driver-lvm](https://github.com/metal-stack/csi-driver-lvm) for a shoot cluster. | ||
|
||
As a safety measurement, the extension checks for the old [csi-lvm](https://github.com/metal-stack/csi-lvm/tree/master) and stops reconciling if the old driver is still available. | ||
If not the extension will reconcile the new `csi-driver-lvm`. | ||
|
||
## Development | ||
|
||
This extension can be developed in the gardener-local devel environment. Before make sure you have created loop-devices on your machine (identical to how you would develop the csi-driver-lvm locally, refer to the repository [docs](https://github.com/metal-stack/csi-driver-lvm?tab=readme-ov-file#development) for further information). | ||
|
||
```sh | ||
for i in 100 101; do fallocate -l 1G loop${i}.img ; sudo losetup /dev/loop${i} loop${i}.img; done | ||
sudo losetup -a | ||
# use this for recreation or cleanup | ||
# for i in 100 101; do sudo losetup -d /dev/loop${i}; rm -f loop${i}.img; done | ||
``` | ||
|
||
1. Start up the local devel environment | ||
1. The extension's docker image can be pushed into Kind using `make push-to-gardener-local` | ||
1. Install the extension `kubectl apply -k example/` | ||
1. Parametrize the `example/shoot.yaml` and apply with `kubectl -f example/shoot.yaml` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
appVersion: "1.0" | ||
description: A Helm chart for the csi-driver-lvm extension | ||
name: gardener-extension-csi-driver-lvm | ||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//go:generate sh -c "bash $GARDENER_HACK_DIR/generate-controller-registration.sh csi-driver-lvm . $(cat ../../VERSION) ../../example/controller-registration.yaml Extension:csi-driver-lvm" | ||
|
||
// Package chart enables go:generate support for generating the correct controller registration. | ||
package chart |
27 changes: 27 additions & 0 deletions
27
charts/gardener-extension-csi-driver-lvm/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{- define "name" -}} | ||
gardener-extension-csi-driver-lvm | ||
{{- end -}} | ||
|
||
{{- define "labels.app.key" -}} | ||
app.kubernetes.io/name | ||
{{- end -}} | ||
{{- define "labels.app.value" -}} | ||
{{ include "name" . }} | ||
{{- end -}} | ||
|
||
{{- define "labels" -}} | ||
{{ include "labels.app.key" . }}: {{ include "labels.app.value" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end -}} | ||
|
||
{{- define "image" -}} | ||
{{- if hasPrefix "sha256:" .Values.image.tag }} | ||
{{- printf "%s@%s" .Values.image.repository .Values.image.tag }} | ||
{{- else }} | ||
{{- printf "%s:%s" .Values.image.repository .Values.image.tag }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- define "deploymentversion" -}} | ||
apps/v1 | ||
{{- end -}} |
12 changes: 12 additions & 0 deletions
12
charts/gardener-extension-csi-driver-lvm/templates/configmap-imagevector-overwrite.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- if .Values.imageVectorOverwrite }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "name" . }}-imagevector-overwrite | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "labels" . | indent 4 }} | ||
data: | ||
images_overwrite.yaml: | | ||
{{ .Values.imageVectorOverwrite | indent 4 }} | ||
{{- end }} |
25 changes: 25 additions & 0 deletions
25
charts/gardener-extension-csi-driver-lvm/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "name" . }}-configmap | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "labels" . | indent 4 }} | ||
data: | ||
config.yaml: | | ||
--- | ||
apiVersion: csi-driver-lvm.metal.extensions.config.gardener.cloud/v1alpha1 | ||
kind: ControllerConfiguration | ||
{{- if .Values.config.clientConnection }} | ||
clientConnection: | ||
acceptContentTypes: {{ required ".Values.config.clientConnection.acceptContentTypes is required" .Values.config.clientConnection.acceptContentTypes }} | ||
contentType: {{ required ".Values.config.clientConnection.contentType is required" .Values.config.clientConnection.contentType }} | ||
qps: {{ required ".Values.config.clientConnection.qps is required" .Values.config.clientConnection.qps }} | ||
burst: {{ required ".Values.config.clientConnection.burst is required" .Values.config.clientConnection.burst }} | ||
{{- end }} | ||
{{- if .Values.config.hostWritePath }} | ||
defaultHostWritePath: {{ .Values.config.hostWritePath }} | ||
{{- end }} | ||
{{- if .Values.config.devicePattern }} | ||
defaultDevicePattern: {{ .Values.config.devicePattern }} | ||
{{- end }} |
Oops, something went wrong.