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

Add support for Docker Swarm #225

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 14 additions & 0 deletions deploy/docker-swarm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.21-alpine as builder
ARG VERSION=0.0.0-dev

WORKDIR /go/src/github.com/vultr/vultr-csi
COPY --from=src . /go/src/github.com/vultr/vultr-csi
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o csi-vultr-plugin ./cmd/csi-vultr-driver

FROM alpine:3.18

RUN apk add --no-cache ca-certificates e2fsprogs findmnt bind-tools e2fsprogs-extra xfsprogs xfsprogs-extra blkid

COPY --from=builder /go/src/github.com/vultr/vultr-csi/csi-vultr-plugin /
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
34 changes: 34 additions & 0 deletions deploy/docker-swarm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PLUGIN_NAME = vultr/vultr-csi
PLUGIN_TAG = latest
PLUGIN_ARCH = amd64

all: clean rootfs create

clean:
@echo "### rm ./plugin"
@rm -rf ./plugin

rootfs:
@echo "### docker build: rootfs image with ${PLUGIN_NAME}"
@docker build --build-context src=../../ --platform linux/${PLUGIN_ARCH} -t ${PLUGIN_NAME}:rootfs .
@echo "### create rootfs directory in ./plugin/rootfs"
@mkdir -p ./plugin/rootfs
@docker create --name tmp ${PLUGIN_NAME}:rootfs
@docker export tmp | tar -x -C ./plugin/rootfs
@echo "### copy config.json to ./plugin/"
@cp config.json ./plugin/
@docker rm -vf tmp

create:
@echo "### remove existing plugin ${PLUGIN_NAME}:${PLUGIN_TAG} if exists"
@docker plugin rm -f ${PLUGIN_NAME}:${PLUGIN_TAG} || true
@echo "### create new plugin ${PLUGIN_NAME}:${PLUGIN_TAG} from ./plugin"
@docker plugin create ${PLUGIN_NAME}:${PLUGIN_TAG} ./plugin

enable:
@echo "### enable plugin ${PLUGIN_NAME}:${PLUGIN_TAG}"
@docker plugin enable ${PLUGIN_NAME}:${PLUGIN_TAG}

push: clean rootfs create enable
@echo "### push plugin ${PLUGIN_NAME}:${PLUGIN_TAG}"
@docker plugin push ${PLUGIN_NAME}:${PLUGIN_TAG}
50 changes: 50 additions & 0 deletions deploy/docker-swarm/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"description": "Vultr csi plugin for Docker",
"documentation": "https://github.com/moby/moby/blob/master/docs/cluster_volumes.md",
"entrypoint": [
"/entrypoint.sh"
],
"env": [
{
"name": "VULTR_API_URL",
"settable": [
"value"
],
"value": ""
},
{
"name": "VULTR_API_TOKEN",
"settable": [
"value"
],
"value": ""
}
],
"interface": {
"socket": "csi-vultr.sock",
"types": [
"docker.csicontroller/1.0",
"docker.csinode/1.0"
]
},
"linux": {
"allowAllDevices": true,
"capabilities": [
"CAP_SYS_ADMIN"
]
},
"mounts": [
{
"destination": "/dev",
"options": [
"rbind"
],
"source": "/dev",
"type": "bind"
}
],
"network": {
"type": "host"
},
"propagatedMount": "/data/published"
}
6 changes: 6 additions & 0 deletions deploy/docker-swarm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

exec /csi-vultr-plugin \
-endpoint "unix:///run/docker/plugins/csi-vultr.sock" \
-api-url "${VULTR_API_URL}" \
-token "${VULTR_API_TOKEN}"
Loading