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

Docker Swarm support #64

Open
dehy opened this issue Jan 9, 2024 · 2 comments
Open

Docker Swarm support #64

dehy opened this issue Jan 9, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dehy
Copy link

dehy commented Jan 9, 2024

Is your feature request related to a problem? Please describe.
Is this plugin compatible with Docker Swarm?

Docker seems to support CSI plugins https://github.com/moby/moby/blob/master/docs/cluster_volumes.md

@dehy dehy added the enhancement New feature or request label Jan 9, 2024
@dehy
Copy link
Author

dehy commented Mar 4, 2024

Exemple of work done by Hetzner Cloud hetznercloud/csi-driver#374

@dehy
Copy link
Author

dehy commented Mar 6, 2024

So, my research, for now, have come to those findings:

https://docs.docker.com/engine/extend/
https://github.com/moby/moby/blob/master/docs/cluster_volumes.md#creating-a-docker-csi-plugin

Building the plugin for docker swarm

apt install golang-go
git clone -b release-0.3 https://github.com/dehy/scaleway-csi.git
cd scaleway-csi
make docker-build
IMAGE=scaleway/scaleway-csi:$(git rev-parse HEAD)-$(go env GOARCH)
id=$(docker create $IMAGE true)
mkdir -p scaleway-csi/rootfs
docker export "$id" | tar -x -C scaleway-csi/rootfs/
docker rm -vf "$id"
docker rmi $IMAGE

cat > scaleway-csi/config.json <<EOF
{
  "description": "Scaleway csi-driver for Docker",
  "documentation": "https://www.scaleway.com/fr/block-storage/",
  "entrypoint": ["/scaleway-csi", "--endpoint", "unix:///run/docker/plugins/scaleway-csi.sock"],
  "interface": {
    "types": ["docker.csicontroller/1.0","docker.csinode/1.0"],
    "socket": "scaleway-csi.sock"
  },
  "env": [
    { "name": "CSI_ENDPOINT", "value": "unix:///run/docker/plugins/scaleway-csi.sock" },
    { "name": "SCW_DEFAULT_ZONE", "value": "", "settable": ["value"] },
    { "name": "SCW_DEFAULT_PROJECT_ID", "value": "", "settable": ["value"] },
    { "name": "SCW_ACCESS_KEY", "value": "", "settable": ["value"] },
    { "name": "SCW_SECRET_KEY", "value": "", "settable": ["value"] }
  ],
  "linux": {
    "capabilities": ["CAP_SYS_ADMIN"]
  },
  "network": {
    "type": "host"
  },
  "propagatedMount": "/data/published"
}
EOF

docker plugin create scaleway-csi scaleway-csi/
docker plugin set scaleway-csi SCW_DEFAULT_ZONE=fr-par-1
docker plugin set scaleway-csi SCW_DEFAULT_PROJECT_ID=<TO REPLACE>
docker plugin set scaleway-csi SCW_ACCESS_KEY=<TO REPLACE>
docker plugin set scaleway-csi SCW_SECRET_KEY=<TO REPLACE>
docker plugin enable scaleway-csi

docker volume create --driver scaleway-csi test-volume --type block --sharing onewriter --limit-bytes 5G

But the volume is not created

$ docker volume ls --cluster
VOLUME NAME   GROUP     DRIVER         AVAILABILITY   STATUS
test-volume             scaleway-csi   active         pending creation

docker daemon logs

Mar 06 15:12:56 web1 dockerd[1500481]: time="2024-03-06T15:12:56.373418778+01:00" level=debug msg="Calling HEAD /_ping"
Mar 06 15:12:56 web1 dockerd[1500481]: time="2024-03-06T15:12:56.374102227+01:00" level=debug msg="Calling POST /v1.44/volumes/create"
Mar 06 15:12:56 web1 dockerd[1500481]: time="2024-03-06T15:12:56.374519265+01:00" level=debug msg="form data: {\"ClusterVolumeSpec\":{\"AccessMode\":{\"BlockVolume\":{},\"Scope\":\"single\",\"Sharing\":\"onewriter\"},\"AccessibilityRequirements\":{},\"Availability\":\"active\",\"CapacityRange\":{\"LimitBytes\":5368709120,\"RequiredBytes\":0}},\"Driver\":\"scaleway-csi\",\"Name\":\"test-volume\"}"
Mar 06 15:12:56 web1 dockerd[1500481]: time="2024-03-06T15:12:56.374679425+01:00" level=debug msg="using cluster volume"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant