Compare commits

...

62 Commits

Author SHA1 Message Date
Chris Lu
09385434ef fix build 2021-07-23 00:44:49 -07:00
Chris Lu
714bdba2b4 fix security alerts
fix https://github.com/seaweedfs/seaweedfs-csi-driver/security/dependabot/go.mod/go.mongodb.org%2Fmongo-driver/open
2021-07-23 00:43:05 -07:00
Chris Lu
e31e483037
Merge pull request #28 from cmacrae/better_docker_image
image: Provide a better built container image
2021-07-12 14:25:06 -07:00
Calum MacRae
8a82e63fe1
CI: Ensure Docker tags derived from refs include legal characters 2021-07-12 22:08:55 +01:00
Calum MacRae
48f7ae5ac2
image: Provide a better built container image 2021-07-12 20:00:23 +01:00
Chris Lu
cfe0766a42 use actor instead of repo owner
https://github.com/seaweedfs/seaweedfs-csi-driver/pull/27#issuecomment-877774143
2021-07-11 11:48:05 -07:00
Chris Lu
fa1045c861
use GITHUB_TOKEN 2021-07-11 00:56:49 -07:00
Chris Lu
a17a59426e Revert "trying GITHUB_TOKEN instead"
This reverts commit 6fefb28e98.
2021-07-10 21:41:26 -07:00
Chris Lu
6fefb28e98
trying GITHUB_TOKEN instead 2021-07-10 21:38:16 -07:00
Chris Lu
cecbc77245
Update README.md 2021-07-10 21:11:15 -07:00
Chris Lu
9c8c528b76
Merge pull request #27 from cmacrae/add_release_pipeline
CI: Add release pipeline
2021-07-10 17:06:25 -07:00
Calum MacRae
33dd6ea35e
CI: Add release pipeline
Closes #17
2021-07-10 10:51:18 +01:00
Chris Lu
5a6563d9fd fix docker build 2021-06-30 16:08:45 -07:00
Chris Lu
0b0414ebab update go version 2021-06-30 12:52:33 -07:00
Chris Lu
54dd42dd19 use go 1.16 2021-06-29 00:57:20 -07:00
Chris Lu
48af8034f8 add release target 2021-06-29 00:57:11 -07:00
Chris Lu
bb90a8bb79 update go mod 2021-06-28 23:37:32 -07:00
Chris Lu
5ac713b8b0 load the security.toml file
fix https://github.com/chrislusf/seaweedfs/discussions/2132
2021-06-25 00:43:22 -07:00
Chris Lu
81f8d6313e
Merge pull request #22 from treo/master 2021-05-28 09:40:40 -07:00
Paul Dubs
55d2359797
Remove extraneous parameter in StatefulSet 2021-05-28 13:11:50 +02:00
Paul Dubs
a270522d25
Remove extraneous parameter for weed in DaemonSet 2021-05-28 13:11:01 +02:00
Chris Lu
45ba112fa1 support configurable cache directory
fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/20
2021-04-11 12:15:36 -07:00
Chris Lu
40fa2802eb support configurable cache size
fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/20
2021-04-11 11:50:46 -07:00
Chris Lu
177fdf0ea0 Update go.sum 2021-04-11 11:46:17 -07:00
Chris Lu
6e072681f4 reduce default concurrentWriters to 32 2021-03-30 00:18:15 -07:00
Chris Lu
23abb01600
Merge pull request #19 from nikolaishields/fix-minor-typo
Fix minor typo
2021-03-28 09:30:47 -07:00
Nikolai Shields
b0ec35d426 autosave or troubleshooting 2021-03-28 11:18:50 -05:00
Nikolai Shields
0466f0e51e Initial Commit 2021-03-28 11:18:13 -05:00
Chris Lu
b46b6c4c3f update 2021-03-12 02:57:26 -08:00
Chris Lu
92f880882c sync with seaweedfs 2.29 2021-03-06 21:20:37 -08:00
Chris Lu
b4eb1f3b52
Merge pull request #18 from ustuzhanin/helm
Helm update
2021-02-17 12:39:28 -08:00
Ustuzhanin Anton
f45aaa39dd
feat: custom updateStrategy for deamonset 2021-02-18 00:52:58 +05:00
Ustuzhanin Anton
d6cf7499e3
feat: custom updateStrategy for deamonset 2021-02-18 00:46:37 +05:00
Ustuzhanin Anton
ba19317751
feat: custom updateStrategy for deamonset 2021-02-18 00:42:52 +05:00
Ustuzhanin Anton
1e8ca97f81
Merge remote-tracking branch 'origin/master' into helm
# Conflicts:
#	README.md
2021-02-18 00:35:36 +05:00
ustuzhanin
767e95d2b6
Merge pull request #1 from seaweedfs/master
Update from upstream
2021-02-18 00:34:20 +05:00
Ustuzhanin Anton
641cce456f
feat: custom updateStrategy for deamonset 2021-02-18 00:29:44 +05:00
Chris Lu
bf92f0a086 fix build error 2021-02-17 01:09:44 -08:00
Chris Lu
56d1995f29
Update README.md 2021-02-17 00:54:46 -08:00
Chris Lu
cb9fd37baf adjust 2021-02-16 15:22:02 -08:00
Chris Lu
bbd2e539cb
Merge pull request #16 from ustuzhanin/helm
fix: add install by chart in Readme
2021-02-16 15:18:40 -08:00
Ustuzhanin Anton
171f304191
fix: README.md install by chart 2021-02-17 01:49:38 +05:00
Ustuzhanin Anton
50f31fe33c
fix: add install by chart in Readme 2021-02-17 01:23:09 +05:00
Chris Lu
ba2214b7f8
Merge pull request #15 from ustuzhanin/helm
Helm chart
2021-02-15 23:26:02 -08:00
Ustuzhanin Anton
b4390ffd5b
feat: add helm chert 2021-02-16 12:16:34 +05:00
Chris Lu
e5bc351871 Update go.mod 2021-02-08 02:42:58 -08:00
Ustuzhanin Anton
7fa73a5d2c
feat: fix helm chert 2021-02-02 15:04:18 +05:00
Chris Lu
30cd8c4168
Merge pull request #12 from danlsgiga/add-volume-mount-params
Add map.uid and map.gid volume mount params via volume context
2021-01-28 01:01:31 -08:00
Daniel Santos
ca767fdce1 Match variable names to Context instead of Parameters 2021-01-27 21:12:13 -07:00
Ustuzhanin Anton
89d2b22e4f
feat: add helm chert 2021-01-22 13:31:13 +05:00
Daniel Santos
7844509790 Use VolumeContext 2021-01-20 15:55:38 -07:00
Daniel Santos
d0d7f1ee3d Troubleshooting 2021-01-20 15:42:56 -07:00
Daniel Santos
9e3c2ce6e2 Use PublishContext instead 2021-01-20 15:40:34 -07:00
Daniel Santos
4274180f3d Add mount arguments as CSI volume parameters 2021-01-20 13:58:29 -07:00
Chris Lu
5c89ac3f88 adjust print out 2021-01-12 10:03:28 -08:00
Chris Lu
e4cb2a5c42 print out filer address 2021-01-12 09:43:13 -08:00
Chris Lu
1496166194 add missing equal sign in command line
fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/9
2021-01-11 18:37:35 -08:00
Chris Lu
e45e75e102 add an example on how to add more mount options 2021-01-11 11:31:49 -08:00
Chris Lu
fcc0835e93 refactoring 2021-01-11 11:26:51 -08:00
Chris Lu
0ddc866b7f update to latest
fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/7
2021-01-11 04:23:38 -08:00
Chris Lu
7523736239 upgrade to k8s.io/client-go v0.17.1, sync with seaweed 2.20
fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/7
2021-01-09 23:17:57 -08:00
Chris Lu
73d4234f5c reduce dependency 2020-11-22 17:17:55 -08:00
26 changed files with 1172 additions and 78 deletions

105
.github/workflows/release.yaml vendored Normal file
View File

@ -0,0 +1,105 @@
name: Build & release Docker images
on:
push:
branches:
- "**"
tags:
- 'v*'
paths:
- 'cmd/seaweedfs-csi-driver/Dockerfile'
- 'cmd/seaweedfs-csi-driver/*.go'
- 'pkg/driver/**'
- 'go.*'
- '.github/**'
# Build on PR
pull_request:
# Allow trigger for external PRs
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch history
run: git fetch --prune --unshallow
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Get the current tag name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" | sed 's/\//_/g' >> $GITHUB_ENV
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Annotate Docker images
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ github.repository }}
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./cmd/seaweedfs-csi-driver/Dockerfile
platforms: linux/amd64
push: false
labels: ${{ steps.docker_meta.outputs.labels }}
tags: ${{ github.repository }}:${{ env.RELEASE_VERSION }}
- name: Publish Docker image to DockerHub & GitHub Container Registry
uses: docker/build-push-action@v2
with:
context: .
file: ./cmd/seaweedfs-csi-driver/Dockerfile
platforms: linux/amd64
push: ${{ startsWith(github.ref, 'refs/tags/') }}
labels: ${{ steps.docker_meta.outputs.labels }}
tags: |
${{ github.repository }}:${{ env.RELEASE_VERSION }}
ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }}
- name: Update DockerHub repo description
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ github.repository }}
- name: Create Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.RELEASE_VERSION }}

View File

@ -13,6 +13,8 @@ container: build
docker build -t $(IMAGE_TAG) -f cmd/seaweedfs-csi-driver/Dockerfile.dev . docker build -t $(IMAGE_TAG) -f cmd/seaweedfs-csi-driver/Dockerfile.dev .
push: container push: container
docker push $(IMAGE_TAG) docker push $(IMAGE_TAG)
release: container
VERSION=latest docker push $(IMAGE_TAG)
clean: clean:
go clean -r -x go clean -r -x
-rm -rf _output -rm -rf _output

View File

@ -2,7 +2,7 @@
[![Docker Pulls](https://img.shields.io/docker/pulls/chrislusf/seaweedfs-csi-driver.svg?maxAge=4800)](https://hub.docker.com/r/chrislusf/seaweedfs-csi-driver/) [![Docker Pulls](https://img.shields.io/docker/pulls/chrislusf/seaweedfs-csi-driver.svg?maxAge=4800)](https://hub.docker.com/r/chrislusf/seaweedfs-csi-driver/)
[Container storage interface](https://kubernetes-csi.github.io/docs/) is an [industry standard](https://github.com/container-storage-interface/spec/blob/master/spec.md) that will enable storage vendors to develop a plugin once and have it work across a number of container orchestration systems. [Container storage interface](https://kubernetes-csi.github.io/docs/) is an [industry standard](https://github.com/container-storage-interface/spec/blob/master/spec.md) that enables storage vendors to develop a plugin once and have it work across a number of container orchestration systems.
[SeaweedFS](https://github.com/chrislusf/seaweedfs) is a simple and highly scalable distributed file system, to store and serve billions of files fast! [SeaweedFS](https://github.com/chrislusf/seaweedfs) is a simple and highly scalable distributed file system, to store and serve billions of files fast!
@ -11,7 +11,7 @@
* Already have a working Kubernetes cluster (includes `kubectl`) * Already have a working Kubernetes cluster (includes `kubectl`)
* Already have a working SeaweedFS cluster * Already have a working SeaweedFS cluster
## Utilize exiting SeaweedFS storage for your Kubernetes cluster (bare metal) ## Utilize existing SeaweedFS storage for your Kubernetes cluster (bare metal)
1. Git clone this repository and add your SeaweedFS master IP to `deploy/kubernetes/seaweedfs-csi.yaml` (2 places) 1. Git clone this repository and add your SeaweedFS master IP to `deploy/kubernetes/seaweedfs-csi.yaml` (2 places)
@ -46,6 +46,34 @@ $ kubectl delete -f deploy/kubernetes/sample-seaweedfs-pvc.yaml
$ kubectl delete -f deploy/kubernetes/seaweedfs-csi.yaml $ kubectl delete -f deploy/kubernetes/seaweedfs-csi.yaml
``` ```
# Deployment by helm chart
1. Clone project
```bash
git clone https://github.com/seaweedfs/seaweedfs-csi-driver.git
```
2. Install
```bash
helm install --set seaweedfsFiler=<filerHost:port> seaweedfs-csi-driver ./seaweedfs-csi-driver/deploy/helm/seaweedfs-csi-driver
```
3. Clean up
```bash
helm uninstall seaweedfs-csi-driver
```
# Safe rollout update
When update DaemonSet ( DS ) break processes who implements fuse mount.
And now new pod not remount net device
For better safe update use ``node.updateStrategy.type: OnDelete`` in this need manual update. Steps:
- delete DS pods on node where no exists seaweefs PV
- cordon or taint node
- evict or delete pods with seaweedfs PV
- delete DS pod on node
- uncordon or remove taint on node
- repeat all steps on all nodes
# License # License
[Apache v2 license](https://www.apache.org/licenses/LICENSE-2.0) [Apache v2 license](https://www.apache.org/licenses/LICENSE-2.0)

BIN
_output/seaweedfs-csi-driver Executable file

Binary file not shown.

View File

@ -1,18 +1,21 @@
FROM frolvlad/alpine-glibc as builder FROM amd64/golang:1.16-alpine as builder
RUN apk add git go g++
RUN mkdir -p /go/src/github.com/chrislusf/ RUN apk add git go g++ curl jq
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed && go install
RUN mkdir -p /go/src/github.com/seaweedfs/ WORKDIR /
RUN git clone https://github.com/seaweedfs/seaweedfs-csi-driver /go/src/github.com/seaweedfs/seaweedfs-csi-driver
RUN cd /go/src/github.com/seaweedfs/seaweedfs-csi-driver && go build -o /seaweedfs-csi-driver ./cmd/seaweedfs-csi-driver/main.go RUN curl -sL \
$(curl -s https://api.github.com/repos/chrislusf/seaweedfs/releases/latest \
| jq -r '.assets[]|select(.name=="linux_amd64.tar.gz")|.browser_download_url') \
| tar xzvf -
COPY ../../ /src
RUN cd /src && go build -o /seaweedfs-csi-driver ./cmd/seaweedfs-csi-driver/main.go
FROM alpine AS final FROM alpine AS final
RUN apk add fuse RUN apk add fuse
LABEL author="Chris Lu" LABEL author="Chris Lu"
COPY --from=builder /root/go/bin/weed /usr/bin/ COPY --from=builder /weed /usr/bin/
COPY --from=builder /seaweedfs-csi-driver / COPY --from=builder /seaweedfs-csi-driver /
RUN chmod +x /seaweedfs-csi-driver RUN chmod +x /seaweedfs-csi-driver

View File

@ -1,4 +1,5 @@
FROM golang:buster as builder FROM amd64/golang:1.16-alpine as builder
RUN apk add git go g++
RUN mkdir -p /go/src/github.com/chrislusf/ RUN mkdir -p /go/src/github.com/chrislusf/
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs

View File

@ -6,14 +6,18 @@ import (
"log" "log"
"os" "os"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver" "github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver"
) )
var ( var (
filer = flag.String("filer", "localhost:8888", "filer server") filer = flag.String("filer", "localhost:8888", "filer server")
endpoint = flag.String("endpoint", "unix://tmp/seaweedfs-csi.sock", "CSI endpoint to accept gRPC calls") endpoint = flag.String("endpoint", "unix://tmp/seaweedfs-csi.sock", "CSI endpoint to accept gRPC calls")
nodeID = flag.String("nodeid", "", "node id") nodeID = flag.String("nodeid", "", "node id")
version = flag.Bool("version", false, "Print the version and exit.") version = flag.Bool("version", false, "Print the version and exit.")
concurrentWriters = flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers if not 0")
cacheSizeMB = flag.Int64("cacheCapacityMB", 1000, "local file chunk cache capacity in MB (0 will disable cache)")
cacheDir = flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
) )
func main() { func main() {
@ -29,6 +33,11 @@ func main() {
os.Exit(0) os.Exit(0)
} }
glog.Infof("connect to filer %s", *filer)
drv := driver.NewSeaweedFsDriver(*filer, *nodeID, *endpoint) drv := driver.NewSeaweedFsDriver(*filer, *nodeID, *endpoint)
drv.ConcurrentWriters = *concurrentWriters
drv.CacheSizeMB = *cacheSizeMB
drv.CacheDir = *cacheDir
drv.Run() drv.Run()
} }

View File

@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
.tgz

View File

@ -0,0 +1,6 @@
apiVersion: v2
name: seaweedfs-csi-driver
description: A Helm chart for Kubernetes
type: application
version: 0.1.1
appVersion: latest

View File

@ -0,0 +1,3 @@
{{- define "seaweedfs-csi-driver.name" -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -0,0 +1,61 @@
{{- if .Values.tlsSecret }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}
labels:
app: {{ template "seaweedfs-csi-driver.name" . }}
data:
security.toml: |-
# this file is read by master, volume server, and filer
# the jwt signing key is read by master and volume server
# a jwt expires in 10 seconds
#[jwt.signing]
# key = "{{ .Values.jwtSigningKey }}"
#expires_after_seconds = 10 # seconds
#[jwt.signing.read]
#key = ""
#expires_after_seconds = 10 # seconds
# all grpc tls authentications are mutual
# the values for the following ca, cert, and key are paths to the PERM files.
[grpc]
ca = "/usr/local/share/ca-certificates/ca.crt"
[grpc.volume]
cert = "/usr/local/share/ca-certificates/tls.crt"
key = "/usr/local/share/ca-certificates/tls.key"
ca = "/usr/local/share/ca-certificates/ca.crt"
[grpc.master]
cert = "/usr/local/share/ca-certificates/tls.crt"
key = "/usr/local/share/ca-certificates/tls.key"
ca = "/usr/local/share/ca-certificates/ca.crt"
[grpc.filer]
cert = "/usr/local/share/ca-certificates/tls.crt"
key = "/usr/local/share/ca-certificates/tls.key"
ca = "/usr/local/share/ca-certificates/ca.crt"
[grpc.msg_broker]
cert = "/usr/local/share/ca-certificates/tls.crt"
key = "/usr/local/share/ca-certificates/tls.key"
ca = "/usr/local/share/ca-certificates/ca.crt"
# use this for any place needs a grpc client
# i.e., "weed backup|benchmark|filer.copy|filer.replicate|mount|s3|upload"
[grpc.client]
cert = "/usr/local/share/ca-certificates/tls.crt"
key = "/usr/local/share/ca-certificates/tls.key"
ca = "/usr/local/share/ca-certificates/ca.crt"
# volume server https options
# Note: work in progress!
# this does not work with other clients, e.g., "weed filer|mount" etc, yet.
#[https.client]
#enabled = false
#[https.volume]
#cert = ""
#key = ""
{{- end }}

View File

@ -0,0 +1,7 @@
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: {{ .Values.driverName }}
spec:
attachRequired: true
podInfoOnMount: true

View File

@ -0,0 +1,110 @@
{{- if .Values.node.enabled}}
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-node
spec:
selector:
matchLabels:
app: {{ template "seaweedfs-csi-driver.name" . }}-node
updateStrategy:
{{ toYaml .Values.node.updateStrategy | nindent 4 }}
template:
metadata:
labels:
app: {{ template "seaweedfs-csi-driver.name" . }}-node
spec:
priorityClassName: system-node-critical
serviceAccountName: {{ template "seaweedfs-csi-driver.name" . }}-node-sa
#hostNetwork: true
#dnsPolicy: ClusterFirstWithHostNet
containers:
- name: driver-registrar
image: {{ .Values.csiNodeDriverRegistrar.image }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
env:
- name: ADDRESS
value: /csi/csi.sock
- name: DRIVER_REG_SOCK_PATH
value: /var/lib/kubelet/plugins/{{ .Values.driverName }}/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
resources:
{{ toYaml .Values.csiNodeDriverRegistrar.resources | nindent 12 }}
volumeMounts:
- name: plugin-dir
mountPath: /csi/
- name: registration-dir
mountPath: /registration/
- name: csi-seaweedfs-plugin
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: {{.Values.seaweedfsCsiPlugin.image }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
args :
- "--endpoint=$(CSI_ENDPOINT)"
- "--filer=$(SEAWEEDFS_FILER)"
- "--nodeid=$(NODE_ID)"
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
- name: SEAWEEDFS_FILER
value: {{ .Values.seaweedfsFiler | quote }}
- name: NODE_ID
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- if .Values.tlsSecret }}
- name: WEED_GRPC_CLIENT_KEY
value: /var/run/secrets/app/tls/tls.key
- name: WEED_GRPC_CLIENT_CERT
value: /var/run/secrets/app/tls/tls.crt
- name: WEED_GRPC_CA
value: /var/run/secrets/app/tls/ca.crt
{{- end }}
resources:
{{ toYaml .Values.seaweedfsCsiPlugin.resources | nindent 12 }}
volumeMounts:
- name: plugin-dir
mountPath: /csi
- name: pods-mount-dir
mountPath: /var/lib/kubelet/pods
mountPropagation: "Bidirectional"
- mountPath: /dev
name: device-dir
{{- if .Values.tlsSecret }}
- name: tls
mountPath: /var/run/secrets/app/tls
{{- end }}
volumes:
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry/
type: DirectoryOrCreate
- name: plugin-dir
hostPath:
path: /var/lib/kubelet/plugins/{{ .Values.driverName }}
type: DirectoryOrCreate
- name: pods-mount-dir
hostPath:
path: /var/lib/kubelet/pods
type: Directory
- name: device-dir
hostPath:
path: /dev
{{- if .Values.tlsSecret }}
- name: tls
secret:
secretName: {{ .Values.tlsSecret }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,172 @@
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-provisioner-role
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-provisioner-binding
subjects:
- kind: ServiceAccount
name: {{ template "seaweedfs-csi-driver.name" . }}-controller-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ template "seaweedfs-csi-driver.name" . }}-provisioner-role
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-attacher-role
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csinodeinfos"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments", "volumeattachments/status"]
verbs: ["get", "list", "watch", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-attacher-binding
subjects:
- kind: ServiceAccount
name: {{ template "seaweedfs-csi-driver.name" . }}-controller-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ template "seaweedfs-csi-driver.name" . }}-attacher-role
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-snapshotter-role
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["create", "get", "list", "watch", "update", "delete"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create", "list", "watch", "delete"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-snapshotter-binding
subjects:
- kind: ServiceAccount
name: {{ template "seaweedfs-csi-driver.name" . }}-controller-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ template "seaweedfs-csi-driver.name" . }}-snapshotter-role
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-driver-registrar-controller-role
rules:
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csidrivers"]
verbs: ["create", "delete"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-driver-registrar-controller-binding
subjects:
- kind: ServiceAccount
name: {{ template "seaweedfs-csi-driver.name" . }}-controller-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ template "seaweedfs-csi-driver.name" . }}-driver-registrar-controller-role
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-driver-registrar-node-role
rules:
- apiGroups: [""]
resources: ["events"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create", "list", "watch", "delete"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-driver-registrar-node-binding
subjects:
- kind: ServiceAccount
name: {{ template "seaweedfs-csi-driver.name" . }}-node-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ template "seaweedfs-csi-driver.name" . }}-driver-registrar-node-role
apiGroup: rbac.authorization.k8s.io

View File

@ -0,0 +1,10 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-controller-sa
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-node-sa

View File

@ -0,0 +1,91 @@
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: {{ template "seaweedfs-csi-driver.name" . }}-controller
spec:
selector:
matchLabels:
app: {{ template "seaweedfs-csi-driver.name" . }}-controller
serviceName: "csi-seaweedfs"
replicas: 1
template:
metadata:
labels:
app: {{ template "seaweedfs-csi-driver.name" . }}-controller
spec:
priorityClassName: system-cluster-critical
serviceAccountName: {{ template "seaweedfs-csi-driver.name" . }}-controller-sa
containers:
# provisioner
- name: csi-provisioner
image: {{ .Values.csiProvisioner.image }}
args:
- "--csi-address=$(ADDRESS)"
- -v
- "9"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: {{ .Values.imagePullPolicy }}
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
resources:
{{ toYaml .Values.csiProvisioner.resources | nindent 12 }}
# attacher
- name: csi-attacher
image: {{ .Values.csiAttacher.image }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--timeout=120s"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: {{ .Values.imagePullPolicy }}
resources:
{{ toYaml .Values.csiAttacher.resources | nindent 12 }}
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
# SeaweedFs Plugin
- name: seaweedfs-csi-plugin
image: {{.Values.seaweedfsCsiPlugin.image}}
imagePullPolicy: {{ .Values.imagePullPolicy }}
args :
- "--endpoint=$(CSI_ENDPOINT)"
- "--filer=$(SEAWEEDFS_FILER)"
- "--nodeid=$(NODE_ID)"
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
- name: SEAWEEDFS_FILER
value: {{ .Values.seaweedfsFiler | quote }}
- name: NODE_ID
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- if .Values.tlsSecret }}
- name: WEED_GRPC_CLIENT_KEY
value: /var/run/secrets/app/tls/tls.key
- name: WEED_GRPC_CLIENT_CERT
value: /var/run/secrets/app/tls/tls.crt
- name: WEED_GRPC_CA
value: /var/run/secrets/app/tls/ca.crt
{{- end }}
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
{{- if .Values.tlsSecret }}
- name: tls
mountPath: /var/run/secrets/app/tls
{{- end }}
volumes:
- name: socket-dir
emptyDir: {}
{{- if .Values.tlsSecret }}
- name: tls
secret:
secretName: {{ .Values.tlsSecret }}
{{- end }}

View File

@ -0,0 +1,10 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: {{ .Values.storageClassName }}
namespace: {{ .Release.Namespace }}
annotations:
{{- if .Values.isDefaultStorageClass }}
storageclass.kubernetes.io/is-default-class: "true"
{{- end }}
provisioner: {{ .Values.driverName }}

View File

@ -0,0 +1,39 @@
# host and port of your SeaweedFs filer
seaweedfsFiler: ""
storageClassName: seaweedfs-storage
isDefaultStorageClass: false
tlsSecret: ""
imagePullPolicy: "IfNotPresent"
csiProvisioner:
image: quay.io/k8scsi/csi-provisioner:v1.6.1
resources: {}
csiAttacher:
image: quay.io/k8scsi/csi-attacher:v1.2.1
resources: {}
csiNodeDriverRegistrar:
image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0
resources: {}
seaweedfsCsiPlugin:
image: chrislusf/seaweedfs-csi-driver:latest
resources: {}
# NOT Change, for future releases. Must be equal Name in GetPluginInfoResponse
driverName: seaweedfs-csi-driver
node:
# Deploy node daemonset
enabled: true
# When pod on node be recreated all pod on same node lost PV.
# For safe update use updateStrategy.type: OnDelete and manual move pods who use PV and delete damonset pod
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%

View File

@ -44,7 +44,7 @@ metadata:
namespace: kube-system namespace: kube-system
annotations: annotations:
storageclass.kubernetes.io/is-default-class: "true" storageclass.kubernetes.io/is-default-class: "true"
provisioner: com.seaweedfs.csi provisioner: seaweedfs-csi-driver
--- ---
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
@ -106,16 +106,19 @@ metadata:
rules: rules:
- apiGroups: [""] - apiGroups: [""]
resources: ["persistentvolumes"] resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update"] verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""] - apiGroups: [""]
resources: ["nodes"] resources: ["nodes"]
verbs: ["get", "list", "watch"] verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["csi.storage.k8s.io"] - apiGroups: ["storage.k8s.io"]
resources: ["csinodeinfos"] resources: ["csinodes"]
verbs: ["get", "list", "watch"] verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["storage.k8s.io"] - apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"] resources: ["volumeattachments"]
verbs: ["get", "list", "watch", "update"] verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments/status"]
verbs: ["patch"]
--- ---
kind: ClusterRoleBinding kind: ClusterRoleBinding
@ -249,9 +252,8 @@ spec:
containers: containers:
# provisioner # provisioner
- name: csi-provisioner - name: csi-provisioner
image: quay.io/k8scsi/csi-provisioner:v1.0.1 image: k8s.gcr.io/sig-storage/csi-provisioner:v2.0.4
args: args:
- "--provisioner=com.seaweedfs.csi"
- "--csi-address=$(ADDRESS)" - "--csi-address=$(ADDRESS)"
- "--v=5" - "--v=5"
env: env:
@ -263,7 +265,7 @@ spec:
mountPath: /var/lib/csi/sockets/pluginproxy/ mountPath: /var/lib/csi/sockets/pluginproxy/
# attacher # attacher
- name: csi-attacher - name: csi-attacher
image: quay.io/k8scsi/csi-attacher:v1.0.1 image: k8s.gcr.io/sig-storage/csi-attacher:v3.0.2
args: args:
- "--v=5" - "--v=5"
- "--csi-address=$(ADDRESS)" - "--csi-address=$(ADDRESS)"
@ -295,6 +297,8 @@ spec:
- "--endpoint=$(CSI_ENDPOINT)" - "--endpoint=$(CSI_ENDPOINT)"
- "--filer=$(SEAWEEDFS_FILER)" - "--filer=$(SEAWEEDFS_FILER)"
- "--nodeid=$(NODE_ID)" - "--nodeid=$(NODE_ID)"
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
- "--cacheDir=$(SEAWEEDFS_CACHE_DIR)"
env: env:
- name: CSI_ENDPOINT - name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
@ -304,6 +308,10 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: spec.nodeName fieldPath: spec.nodeName
- name: SEAWEEDFS_CACHE_CAPACITY_MB
value: "1000"
- name: SEAWEEDFS_CACHE_DIR
value: /tmp
imagePullPolicy: "Always" imagePullPolicy: "Always"
volumeMounts: volumeMounts:
- name: socket-dir - name: socket-dir
@ -333,7 +341,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
containers: containers:
- name: driver-registrar - name: driver-registrar
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.1 image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.0.1
args: args:
- "--v=5" - "--v=5"
- "--csi-address=$(ADDRESS)" - "--csi-address=$(ADDRESS)"
@ -342,7 +350,7 @@ spec:
- name: ADDRESS - name: ADDRESS
value: /csi/csi.sock value: /csi/csi.sock
- name: DRIVER_REG_SOCK_PATH - name: DRIVER_REG_SOCK_PATH
value: /var/lib/kubelet/plugins/com.seaweedfs.csi/csi.sock value: /var/lib/kubelet/plugins/seaweedfs-csi-driver/csi.sock
- name: KUBE_NODE_NAME - name: KUBE_NODE_NAME
valueFrom: valueFrom:
fieldRef: fieldRef:
@ -363,6 +371,8 @@ spec:
- "--endpoint=$(CSI_ENDPOINT)" - "--endpoint=$(CSI_ENDPOINT)"
- "--filer=$(SEAWEEDFS_FILER)" - "--filer=$(SEAWEEDFS_FILER)"
- "--nodeid=$(NODE_ID)" - "--nodeid=$(NODE_ID)"
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
- "--cacheDir=$(SEAWEEDFS_CACHE_DIR)"
env: env:
- name: CSI_ENDPOINT - name: CSI_ENDPOINT
value: unix:///csi/csi.sock value: unix:///csi/csi.sock
@ -372,6 +382,10 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: spec.nodeName fieldPath: spec.nodeName
- name: SEAWEEDFS_CACHE_CAPACITY_MB
value: "1000"
- name: SEAWEEDFS_CACHE_DIR
value: /tmp
imagePullPolicy: "IfNotPresent" imagePullPolicy: "IfNotPresent"
volumeMounts: volumeMounts:
- name: plugin-dir - name: plugin-dir
@ -388,7 +402,7 @@ spec:
type: DirectoryOrCreate type: DirectoryOrCreate
- name: plugin-dir - name: plugin-dir
hostPath: hostPath:
path: /var/lib/kubelet/plugins/com.seaweedfs.csi path: /var/lib/kubelet/plugins/seaweedfs-csi-driver
type: DirectoryOrCreate type: DirectoryOrCreate
- name: pods-mount-dir - name: pods-mount-dir
hostPath: hostPath:

69
go.mod
View File

@ -3,68 +3,75 @@ module github.com/seaweedfs/seaweedfs-csi-driver
go 1.14 go 1.14
require ( require (
cloud.google.com/go v0.68.0 // indirect
cloud.google.com/go/pubsub v1.8.1 // indirect cloud.google.com/go/pubsub v1.8.1 // indirect
cloud.google.com/go/storage v1.12.0 // indirect cloud.google.com/go/storage v1.12.0 // indirect
github.com/Azure/azure-amqp-common-go/v2 v2.1.0 // indirect
github.com/Azure/azure-pipeline-go v0.2.3 // indirect github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-storage-blob-go v0.10.0 // indirect github.com/Azure/azure-storage-blob-go v0.10.0 // indirect
github.com/DataDog/zstd v1.4.5 // indirect github.com/DataDog/zstd v1.4.5 // indirect
github.com/Shopify/sarama v1.27.1 // indirect github.com/Shopify/sarama v1.27.1 // indirect
github.com/aws/aws-sdk-go v1.35.7 // indirect github.com/andybalholm/brotli v1.0.3 // indirect
github.com/chrislusf/seaweedfs v0.0.0-20201012192625-f022aff289d5 github.com/aws/aws-sdk-go v1.38.69 // indirect
github.com/container-storage-interface/spec v1.2.0 github.com/chrislusf/seaweedfs v0.0.0-20210723063554-bdb632fa62bf
github.com/container-storage-interface/spec v1.5.0
github.com/coreos/bbolt v1.3.3 // indirect github.com/coreos/bbolt v1.3.3 // indirect
github.com/coreos/etcd v3.3.15+incompatible // indirect github.com/coreos/etcd v3.3.15+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/go-systemd/v22 v22.1.0 // indirect github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-errors/errors v1.4.0 // indirect
github.com/go-redis/redis v6.15.9+incompatible // indirect github.com/go-redis/redis v6.15.9+incompatible // indirect
github.com/gocql/gocql v0.0.0-20200926162733-393f0c961220 // indirect github.com/gocql/gocql v0.0.0-20200926162733-393f0c961220 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/snappy v0.0.2 // indirect github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gophercloud/gophercloud v0.1.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/klauspost/compress v1.11.1 // indirect github.com/karlseguin/ccache v2.0.3+incompatible // indirect
github.com/klauspost/compress v1.13.1 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect github.com/klauspost/cpuid v1.3.1 // indirect
github.com/klauspost/reedsolomon v1.9.9 // indirect github.com/klauspost/reedsolomon v1.9.9 // indirect
github.com/lib/pq v1.8.0 // indirect github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/magiconair/properties v1.8.4 // indirect github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/go-ps v1.0.0 github.com/mitchellh/go-ps v1.0.0
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104 // indirect github.com/mmcloughlin/avo v0.0.0-20200803215136-443f81d77104 // indirect
github.com/olivere/elastic/v7 v7.0.20 // indirect github.com/olivere/elastic/v7 v7.0.20 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/peterh/liner v1.2.0 // indirect github.com/peterh/liner v1.2.0 // indirect
github.com/prometheus/common v0.14.0 // indirect github.com/prometheus/common v0.29.0 // indirect
github.com/prometheus/procfs v0.2.0 // indirect github.com/rakyll/statik v0.1.7 // indirect
github.com/spf13/afero v1.4.1 // indirect
github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/viper v1.7.1 // indirect github.com/spf13/viper v1.8.1 // indirect
github.com/streadway/amqp v1.0.0 // indirect github.com/streadway/amqp v1.0.0 // indirect
github.com/tidwall/gjson v1.6.1 // indirect github.com/valyala/fasthttp v1.27.0 // indirect
github.com/viant/toolbox v0.34.4 // indirect
github.com/willf/bitset v1.1.11 // indirect github.com/willf/bitset v1.1.11 // indirect
go.etcd.io/etcd v3.3.25+incompatible // indirect go.etcd.io/etcd v3.3.25+incompatible // indirect
go.mongodb.org/mongo-driver v1.4.2 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/multierr v1.6.0 // indirect go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 // indirect
gocloud.dev/pubsub/natspubsub v0.20.0 // indirect gocloud.dev/pubsub/natspubsub v0.20.0 // indirect
gocloud.dev/pubsub/rabbitpubsub v0.20.0 // indirect gocloud.dev/pubsub/rabbitpubsub v0.20.0 // indirect
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee // indirect golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb golang.org/x/net v0.0.0-20210614182718-04defd469f4e
golang.org/x/sync v0.0.0-20201008141435-b3e1573b7520 // indirect golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 // indirect
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 // indirect golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/tools v0.0.0-20201012192620-5bd05386311b // indirect golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
google.golang.org/genproto v0.0.0-20201012135029-0c95dc0d88e8 // indirect golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6 // indirect
google.golang.org/grpc v1.33.0 google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 // indirect
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect
k8s.io/apimachinery v0.18.2 // indirect gopkg.in/karlseguin/expect.v1 v1.0.1 // indirect
k8s.io/client-go v0.17.0 k8s.io/client-go v0.21.2
k8s.io/klog v1.0.0 k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20200318093247-d1ab8797c558 k8s.io/klog/v2 v2.9.0 // indirect
k8s.io/utils v0.0.0-20210629042839-4a2b36d8d73f
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e // indirect
sigs.k8s.io/structured-merge-diff/v3 v3.0.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.1 // indirect
) )
replace go.etcd.io/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20200425165423-262c93980547 replace go.etcd.io/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20200425165423-262c93980547

365
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -174,6 +174,10 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
return nil, status.Error(codes.Unimplemented, "") return nil, status.Error(codes.Unimplemented, "")
} }
func (cs *ControllerServer) ControllerGetVolume(ctx context.Context, req *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
}
func sanitizeVolumeId(volumeId string) string { func sanitizeVolumeId(volumeId string) string {
volumeId = strings.ToLower(volumeId) volumeId = strings.ToLower(volumeId)
if len(volumeId) > 63 { if len(volumeId) > 63 {

View File

@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
"github.com/container-storage-interface/spec/lib/go/csi" "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/chrislusf/seaweedfs/weed/glog"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
@ -35,14 +35,19 @@ type SeaweedFsDriver struct {
vcap []*csi.VolumeCapability_AccessMode vcap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability cscap []*csi.ControllerServiceCapability
filer string filer string
grpcDialOption grpc.DialOption grpcDialOption grpc.DialOption
ConcurrentWriters int
CacheSizeMB int64
CacheDir string
} }
func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver { func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver {
glog.Infof("Driver: %v version: %v", driverName, version) glog.Infof("Driver: %v version: %v", driverName, version)
util.LoadConfiguration("security", false)
n := &SeaweedFsDriver{ n := &SeaweedFsDriver{
endpoint: endpoint, endpoint: endpoint,
nodeID: nodeID, nodeID: nodeID,

View File

@ -4,8 +4,9 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/chrislusf/seaweedfs/weed/glog"
"os/exec" "os/exec"
"github.com/chrislusf/seaweedfs/weed/glog"
"k8s.io/utils/mount" "k8s.io/utils/mount"
) )
@ -19,8 +20,8 @@ type Mounter interface {
Mount(target string) error Mount(target string) error
} }
func newMounter(bucketName string, filer string) (Mounter, error) { func newMounter(bucketName string, driver *SeaweedFsDriver, volContext map[string]string) (Mounter, error) {
return newSeaweedFsMounter(bucketName, filer) return newSeaweedFsMounter(bucketName, driver, volContext)
} }
func fuseMount(path string, command string, args []string) error { func fuseMount(path string, command string, args []string) error {

View File

@ -8,23 +8,25 @@ import (
// Implements Mounter // Implements Mounter
type seaweedFsMounter struct { type seaweedFsMounter struct {
bucketName string bucketName string
filerUrl string driver *SeaweedFsDriver
volContext map[string]string
} }
const ( const (
seaweedFsCmd = "weed" seaweedFsCmd = "weed"
) )
func newSeaweedFsMounter(bucketName string, filer string) (Mounter, error) { func newSeaweedFsMounter(bucketName string, driver *SeaweedFsDriver, volContext map[string]string) (Mounter, error) {
return &seaweedFsMounter{ return &seaweedFsMounter{
bucketName: bucketName, bucketName: bucketName,
filerUrl: filer, driver: driver,
volContext: volContext,
}, nil }, nil
} }
func (seaweedFs *seaweedFsMounter) Mount(target string) error { func (seaweedFs *seaweedFsMounter) Mount(target string) error {
glog.V(0).Infof("mounting %s%s to %s", seaweedFs.filerUrl, seaweedFs.bucketName, target) glog.V(0).Infof("mounting %s %s to %s", seaweedFs.driver.filer, seaweedFs.bucketName, target)
args := []string{ args := []string{
"mount", "mount",
@ -32,12 +34,29 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) error {
"-umask=000", "-umask=000",
fmt.Sprintf("-dir=%s", target), fmt.Sprintf("-dir=%s", target),
fmt.Sprintf("-collection=%s", seaweedFs.bucketName), fmt.Sprintf("-collection=%s", seaweedFs.bucketName),
fmt.Sprintf("-filer=%s", seaweedFs.filerUrl), fmt.Sprintf("-filer=%s", seaweedFs.driver.filer),
fmt.Sprintf("-filer.path=/buckets/%s", seaweedFs.bucketName), fmt.Sprintf("-filer.path=/buckets/%s", seaweedFs.bucketName),
fmt.Sprintf("-cacheCapacityMB=%d", seaweedFs.driver.CacheSizeMB),
}
for arg, value := range seaweedFs.volContext {
switch arg {
case "map.uid":
args = append(args, fmt.Sprintf("-map.uid=%s", value))
case "map.gid":
args = append(args, fmt.Sprintf("-map.gid=%s", value))
}
}
if seaweedFs.driver.ConcurrentWriters > 0 {
args = append(args, fmt.Sprintf("-concurrentWriters=%d", seaweedFs.driver.ConcurrentWriters))
}
if seaweedFs.driver.CacheDir != "" {
args = append(args, fmt.Sprintf("-cacheDir=%s", seaweedFs.driver.CacheDir))
} }
err := fuseMount(target, seaweedFsCmd, args) err := fuseMount(target, seaweedFsCmd, args)
if err != nil { if err != nil {
glog.Errorf("mount %s%s to %s: %s", seaweedFs.filerUrl, seaweedFs.bucketName, target, err) glog.Errorf("mount %s %s to %s: %s", seaweedFs.driver.filer, seaweedFs.bucketName, target, err)
} }
return err return err
} }

View File

@ -55,7 +55,9 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
mo = append(mo, "ro") mo = append(mo, "ro")
} }
mounter, err := newMounter(volumeID, ns.Driver.filer) volContext := req.GetVolumeContext()
mounter, err := newMounter(volumeID, ns.Driver, volContext)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -163,4 +165,4 @@ func checkMount(targetPath string) (bool, error) {
} }
} }
return notMnt, nil return notMnt, nil
} }