Skip to content

Commit

Permalink
Driver version 0.9.7
Browse files Browse the repository at this point in the history
Clean up the deploy and examples folder.
Switch to use ghcr.io registry.
Add GitHub actions.
  • Loading branch information
xandrus committed Oct 31, 2024
1 parent fa779ce commit 10be754
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 593 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build and publish moosefs-csi driver Docker image

on:
push:
branches:
- dev

env:
REGISTRY_IMAGE: moosefs/moosefs-csi
MFS_CLIENT: 4.56.6
CSI_VERSION: 0.9.7

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=raw,value=${{ env.CSI_VERSION }}-${{ env.MFS_CLIENT }}
type=raw,value=${{ env.CSI_VERSION }}-{{branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push by digest MooseFS Client v4
id: build
uses: docker/build-push-action@v6
with:
file: ./cmd/moosefs-csi-plugin/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
build-args: |
MFS_TAG=v${{ env.MFS_CLIENT }}
CSI_TAG=dev
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=raw,value=${{ env.CSI_VERSION }}-${{ env.MFS_CLIENT }}
type=raw,value=${{ env.CSI_VERSION }}-{{branch}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright (c) 2023 Saglabs SA. All Rights Reserved.
Copyright (c) 2024 Saglabs SA. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
54 changes: 28 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Saglabs SA. All Rights Reserved.
# Copyright (c) 2024 Saglabs SA. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,44 +12,46 @@
# See the License for the specific language governing permissions and
# limitations under the License.

MFS3VER=3.0.117
MFS4VER=4.44.4
DRIVER_VERSION ?= 0.9.6
MFS3TAGCE=$(DRIVER_VERSION)-$(MFS3VER)
MFS3TAGPRO=$(DRIVER_VERSION)-$(MFS3VER)-pro
MFS4TAGPRO=$(DRIVER_VERSION)-$(MFS4VER)-pro
DEVTAG=$(DRIVER_VERSION)-dev
MFS_VERSION = "4.56.6"
CSI_VERSION ?= "0.9.7"

NAME=moosefs-csi-plugin
DOCKER_REGISTRY=registry.moosefs.com
MFS_TAG=$(CSI_VERSION)-$(MFS_VERSION)
DEV_TAG=$(CSI_VERSION)-dev

ready: clean compile
publish-dev: clean compile build-dev push-dev
NAME=moosefs-csi

csi: clean compile
dev: build-dev push-dev
prod: build-prod push-prod

compile:
@echo "==> Building the project"
@echo "==> Building the CSI driver"
@env CGO_ENABLED=0 GOCACHE=/tmp/go-cache GOOS=linux GOARCH=amd64 go build -a -o cmd/moosefs-csi-plugin/${NAME} cmd/moosefs-csi-plugin/main.go

build-dev:
@echo "==> Building DEV docker images"
@docker build -t $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(DEVTAG) cmd/moosefs-csi-plugin
@docker build -t $(DOCKER_REGISTRY)/moosefs-csi-plugin:latest-dev cmd/moosefs-csi-plugin
@echo "==> Building DEV CSI images"
@docker build --no-cache -t moosefs/$(NAME):dev -t moosefs/$(NAME):$(DEV_TAG) --build-arg MFS_TAG=v$(MFS_VERSION) --build-arg CSI_TAG=dev cmd/moosefs-csi-plugin

push-dev:
@echo "==> Publishing DEV $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(DEVTAG)"
@docker push $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(DEVTAG)
@docker push $(DOCKER_REGISTRY)/moosefs-csi-plugin:latest-dev
@echo "==> Your DEV image is now available at $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(DEVTAG)"
@echo "==> Publishing DEV CSI image on hub.docker.com: moosefs/$(NAME):$(DEV_TAG)"
@docker push moosefs/$(NAME):$(DEV_TAG)
@docker push moosefs/$(NAME):dev

build-prod:
@docker build -t $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(MFS3TAGCE) cmd/moosefs-csi-plugin -f cmd/moosefs-csi-plugin/Dockerfile-mfs3-ce
@docker build -t $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(MFS3TAGPRO) cmd/moosefs-csi-plugin -f cmd/moosefs-csi-plugin/Dockerfile-mfs3-pro
@docker build -t $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(MFS4TAGPRO) cmd/moosefs-csi-plugin -f cmd/moosefs-csi-plugin/Dockerfile-mfs4-pro
@echo "==> Building Production CSI images"
@docker build --no-cache -t moosefs/$(NAME):$(MFS_TAG) --build-arg MFS_TAG=v$(MFS_VERSION) --build-arg CSI_TAG=$(CSI_VERSION) cmd/moosefs-csi-plugin

push-prod:
@docker push $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(MFS3TAGCE)
@docker push $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(MFS3TAGPRO)
@docker push $(DOCKER_REGISTRY)/moosefs-csi-plugin:$(MFS4TAGPRO)
@echo "==> Publishing PRODUCTION CSI image on hub.docker.com: moosefs/$(NAME):$(MFS_TAG)"
@docker push moosefs/$(NAME):$(MFS_TAGCE)

dev-buildx:
@echo "==> Using buildx to build and publish dev image"
@docker buildx build --no-cache --push --platform linux/amd64,linux/arm64,linux/arm/v7 --build-arg MFS_TAG=v$(MFS_VERSION) --build-arg CSI_TAG=dev -t moosefs/$(NAME):dev -t moosefs/$(NAME):$(DEV_TAG) cmd/moosefs-csi-plugin

prod-buildx:
@echo "==> Using buildx to build and publish production image"
@docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 --build-arg MFS_TAG=v$(MFS_VERSION) --build-arg CSI_TAG=dev -t moosefs/$(NAME):$(MFS_TAG) cmd/moosefs-csi-plugin

clean:
@echo "==> Cleaning releases"
Expand Down
40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ MooseFS source code can be found [on GitHub](https://github.com/moosefs/moosefs)

*Note that a pool of MooseFS Clients that are available for use by containers is created on each node. By default the number of MooseFS Clients in the pool is `1`.*

## Changelog

Driver verson 0.9.7
* Added support for MooseFS 4 client.
* Enabled passing additional mfsmount parameters during the mount process (password and more).
* Support for cross-platform compilation has been enabled.
* Repository images support AMD64, ARM64 and ARMv7 architectures by default.

## Installation on Kubernetes

### Prerequisites
Expand All @@ -20,34 +28,40 @@ MooseFS source code can be found [on GitHub](https://github.com/moosefs/moosefs)

### **Deployment**

1. Complete `deploy/kubernetes/csi-moosefs-config.yaml` configuration file with your settings:
1. Edit `deploy/kubernetes/csi-moosefs-config.yaml` config map file with your settings:

* `master_host` – domain name (**recommended**) or IP address of your MooseFS Master Server(s). It is an equivalent to `-H master_host` or `-o mfsmaster=master_host` passed to MooseFS Client.
* `master_port` – port number of your MooseFS Master Server. It is an equivalent to `-P master_port` or `-o mfsport=master_port` passed to MooseFS Client.
* `k8s_root_dir` – each mount's root directory on MooseFS. Each path is relative to this one. Equivalent to `-S k8s_root_dir` or `-o mfssubfolder=k8s_root_dir` passed to MooseFS Client.
* `driver_working_dir` – a driver working directory inside MooseFS where persistent volumes, logs and metadata is stored (actual path is: `k8s_root_dir/driver_working_dir`)
* `mount_count` – number of pre created MooseFS clients running on each node
and apply:
* `mfs_logging` – driver can create logs from each component in `k8s_root_dir/driver_working_dir/logs` directory. Boolean `"true"`/`"false"` value.

2. Apply csi-moosefs-config config map to the cluster:

```
$ kubectl apply -f deploy/kubernetes/csi-moosefs-config.yaml
```
2. ConfigMap should now be created:
Check the config map status:
```
$ kubectl get configmap -n kube-system
NAME DATA AGE
csi-moosefs-config 6 42s
```
3. Update `deploy/kubernetes/csi-moosefs.yaml` file with the image that uses required MooseFS or MooseFS Pro version and MooseFS CSI Plugin version. Default images are the latest version of the plugin and the latest version of MooseFS (Community):
3. Update `deploy/kubernetes/csi-moosefs.yaml` file with the aproprieate image:
The default image consists of the latest version of the CSI plug-in and the latest version of the MooseFS Community Edition client:
* Find plugin named `csi-moosefs-plugin`
* Update the `image` version suffix in the plugin's section accordingly, for example:
* `0.9.4-3.0.117` – for plugin version 0.9.4 and MooseFS Community 3.0.117
* `0.9.4-4.44.4-pro` – for plugin version 0.9.4 and MooseFS Pro 4.44.4
* Locate image definition under the `csi-moosefs-plugin` plugin name(line 230 and line 323)
`mage: registry.moosefs.com/moosefs-csi-plugin:0.9.7-4.56.6`
* Update the `image` version suffix in the plugin's section accordingly:
* `0.9.7-3.0.118` – plugin version 0.9.7 and MooseFS CE 3.0.118
* `0.9.7-4.56.6` – plugin version 0.9.7 and MooseFS CE 4.56.6
* `0.9.7-3.0.118-pro` – plugin version 0.9.7 and MooseFS PRO 3.0.118
* `0.9.7-4.56.6-pro` – plugin version 0.9.7 and MooseFS PRO 4.56.6
You can find a complete list of available images at: \
https://registry.moosefs.com/v2/moosefs-csi-plugin/tags/list.
Expand Down Expand Up @@ -104,7 +118,8 @@ MooseFS source code can be found [on GitHub](https://github.com/moosefs/moosefs)
172.17.2.80:9421 4.2T 1.4T 2.8T 33% /data
```
You may take a look at MooseFS CGI Monitoring Interface ("Quotas" tab) to check if a quota for 5 GiB on a newly created volume directory has been set. Dynamically provisioned volumes are stored on MooseFS in `k8s_root_dir/driver_working_dir/volumes` directory.
You may take a look at MooseFS GUI Monitoring Interface ("Quotas" tab) to check if a quota for 5 GiB on a newly created volume directory has been set.
Dynamically provisioned volumes are stored on MooseFS in `k8s_root_dir/driver_working_dir/volumes` directory.
5. Clean up:
Expand Down Expand Up @@ -233,12 +248,13 @@ spec:
| Kubernetes | MooseFS CSI Driver |
|:----------:|:------------------:|
| `v1.26.2` | `v0.9.4` |
| `v1.24.2` | `v0.9.4` |
| `v1.26` | `v0.9.7` |
| `-----` | `------` |
| `v1.30` | `v0.9.7` |
## Copyright
Copyright (c) 2020-2023 Saglabs SA
Copyright (c) 2020-2024 Saglabs SA
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0).
Expand Down
39 changes: 23 additions & 16 deletions cmd/moosefs-csi-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 Saglabs SA. All Rights Reserved.
# Copyright (c) 2024 Saglabs SA. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,22 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM debian:buster
ARG CSI_TAG="dev"
ARG MFS_TAG="v4.56.6"

# Install wget, lsb-release and curl
RUN apt update && \
apt install -y wget lsb-release curl fuse libfuse3-dev tree ca-certificates e2fsprogs gnupg2 && \
# security updates
apt install -y apt systemd
#Build MooseFS CSI driver from source
FROM golang:1.23-bookworm AS csibuilder
WORKDIR /build
ARG CSI_TAG
RUN git clone --depth 1 --branch ${CSI_TAG} https://github.com/moosefs/moosefs-csi.git
RUN cd moosefs-csi && CGO_ENABLED=0 GOCACHE=/tmp/go-cache GOOS=linux go build -a -o /build/moosefs-csi-plugin cmd/moosefs-csi-plugin/main.go

# Add key
RUN wget -O - http://repository.moosefs.com/moosefs.key | apt-key add -
RUN echo "deb http://repository.moosefs.com/4.44.4/apt/debian/buster buster main" > /etc/apt/sources.list.d/moosefs.list

# Install MooseFS client
RUN apt update --allow-releaseinfo-change && apt install -y moosefs-pro-client

# Copy the CSI plugin
ADD moosefs-csi-plugin /bin/
#Build MooseFS Client from source
FROM registry.moosefs.com/mfsbuilder-debian12:latest AS mfsbuilder
WORKDIR /moosefs
ARG MFS_TAG
RUN git clone --depth 1 --branch ${MFS_TAG} https://github.com/moosefs/moosefs.git /moosefs
RUN autoreconf -f -i
RUN ./configure --prefix=/usr --mandir=/share/man --sysconfdir=/etc --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfsbdev
RUN cd /moosefs/mfsclient && make DESTDIR=/tmp/ install

#Build CSI plugin container
FROM debian:bookworm
RUN apt update && apt install -y libfuse3-3
COPY --from=csibuilder /build/moosefs-csi-plugin /bin/moosefs-csi-plugin
COPY --from=mfsbuilder /tmp/usr/bin /usr/bin
RUN ["ln", "-s", "/usr/bin/mfsmount", "/usr/sbin/mount.moosefs"]
ENTRYPOINT ["/bin/moosefs-csi-plugin"]
33 changes: 0 additions & 33 deletions cmd/moosefs-csi-plugin/Dockerfile-mfs3-ce

This file was deleted.

Loading

0 comments on commit 10be754

Please sign in to comment.