Skip to content

Commit

Permalink
Update to version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chihyuwu committed Feb 14, 2022
1 parent bca0c70 commit 515bc7f
Show file tree
Hide file tree
Showing 18 changed files with 525 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
config/client-info.yml
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ RUN go mod download

COPY Makefile .

ARG TARGETPLATFORM

COPY main.go .
COPY pkg ./pkg
RUN make
RUN env GOARCH=$(echo "$TARGETPLATFORM" | cut -f2 -d/) \
GOARM=$(echo "$TARGETPLATFORM" | cut -f3 -d/ | cut -c2-) \
make

############## Final stage ##############
FROM alpine:latest
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

REGISTRY_NAME=synology
IMAGE_NAME=synology-csi
IMAGE_VERSION=v1.0.0
IMAGE_VERSION=v1.0.1
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION)

# For now, only build linux/amd64 platform
GOARCH?=amd64
BUILD_ENV=CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH)
ifeq ($(GOARCH),)
GOARCH:=amd64
endif
GOARM?=""
BUILD_ENV=CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM)
BUILD_FLAGS="-extldflags \"-static\""

.PHONY: all clean synology-csi-driver synocli test docker-build
Expand All @@ -21,6 +24,9 @@ synology-csi-driver:
docker-build:
docker build -f Dockerfile -t $(IMAGE_TAG) .

docker-build-multiarch:
docker buildx build -t $(IMAGE_TAG) --platform linux/amd64,linux/arm/v7,linux/arm64 . --push

synocli:
@mkdir -p bin
$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o ./bin/synocli ./synocli
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ The official [Container Storage Interface](https://github.com/container-storage-
Driver Name: csi.san.synology.com
| Driver Version | Image | Supported K8s Version |
| -------------- | --------------------------------------------------------------------- | --------------------- |
| v1.0.0 | [synology-csi:v1.0.0](https://hub.docker.com/r/synology/synology-csi) | 1.19 |
| [v1.0.1](https://github.com/SynologyOpenSource/synology-csi/tree/release-v1.0.1) | [synology-csi:v1.0.1](https://hub.docker.com/r/synology/synology-csi) | 1.20+ |
| [v1.0.0](https://github.com/SynologyOpenSource/synology-csi/tree/release-v1.0.0) | [synology-csi:v1.0.0](https://hub.docker.com/r/synology/synology-csi) | 1.19 |



Expand All @@ -18,7 +19,7 @@ The Synology CSI driver supports:

## Installation
### Prerequisites
- Kubernetes versions 1.19
- Kubernetes versions 1.19 or above
- Synology NAS running DSM 7.0 or above
- Go version 1.16 or above is recommended
- (Optional) Both [Volume Snapshot CRDs](https://github.com/kubernetes-csi/external-snapshotter/tree/v4.0.0/client/config/crd) and the [common snapshot controller](https://github.com/kubernetes-csi/external-snapshotter/tree/v4.0.0/deploy/kubernetes/snapshot-controller) must be installed in your Kubernetes cluster if you want to use the **Snapshot** feature
Expand Down
15 changes: 9 additions & 6 deletions deploy/kubernetes/v1.19/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csinodeinfos"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
resources: ["volumeattachments", "volumeattachments/status"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
Expand Down Expand Up @@ -85,7 +88,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: quay.io/k8scsi/csi-provisioner:v1.6.0
image: k8s.gcr.io/sig-storage/csi-provisioner:v2.2.2
args:
- --timeout=60s
- --csi-address=$(ADDRESS)
Expand All @@ -103,7 +106,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: quay.io/k8scsi/csi-attacher:v2.1.0
image: k8s.gcr.io/sig-storage/csi-attacher:v3.3.0
args:
- --v=5
- --csi-address=$(ADDRESS)
Expand All @@ -120,7 +123,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: quay.io/k8scsi/csi-resizer:v0.5.0
image: k8s.gcr.io/sig-storage/csi-resizer:v1.3.0
args:
- --v=5
- --csi-address=$(ADDRESS)
Expand All @@ -137,7 +140,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: synology/synology-csi:v1.0.0
image: synology/synology-csi:v1.0.1
args:
- --nodeid=NotUsed
- --endpoint=$(CSI_ENDPOINT)
Expand All @@ -147,7 +150,7 @@ spec:
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
Expand Down
6 changes: 3 additions & 3 deletions deploy/kubernetes/v1.19/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spec:
securityContext:
privileged: true
imagePullPolicy: Always
image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.3.0
args:
- --v=5
- --csi-address=$(ADDRESS) # the csi socket path inside the pod
Expand All @@ -85,8 +85,8 @@ spec:
- name: csi-plugin
securityContext:
privileged: true
imagePullPolicy: IfNotPresent
image: synology/synology-csi:v1.0.0
imagePullPolicy: Always
image: synology/synology-csi:v1.0.1
args:
- --nodeid=$(KUBE_NODE_NAME)
- --endpoint=$(CSI_ENDPOINT)
Expand Down
6 changes: 3 additions & 3 deletions deploy/kubernetes/v1.19/snapshotter/snapshotter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: quay.io/k8scsi/csi-snapshotter:v3.0.3
image: k8s.gcr.io/sig-storage/csi-snapshotter:v3.0.3
args:
- --v=5
- --csi-address=$(ADDRESS)
Expand All @@ -81,7 +81,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: synology/synology-csi:v1.0.0
image: synology/synology-csi:v1.0.1
args:
- --nodeid=NotUsed
- --endpoint=$(CSI_ENDPOINT)
Expand All @@ -91,7 +91,7 @@ spec:
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
Expand Down
165 changes: 165 additions & 0 deletions deploy/kubernetes/v1.20/controller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-controller-sa
namespace: synology-csi

---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: synology-csi-controller-role
rules:
- apiGroups: [""]
resources: ["events"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
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"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- 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: synology-csi-controller-role
namespace: synology-csi
subjects:
- kind: ServiceAccount
name: csi-controller-sa
namespace: synology-csi
roleRef:
kind: ClusterRole
name: synology-csi-controller-role
apiGroup: rbac.authorization.k8s.io

---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: synology-csi-controller
namespace: synology-csi
spec:
serviceName: "synology-csi-controller"
replicas: 1
selector:
matchLabels:
app: synology-csi-controller
template:
metadata:
labels:
app: synology-csi-controller
spec:
serviceAccountName: csi-controller-sa
hostNetwork: true
containers:
- name: csi-provisioner
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: k8s.gcr.io/sig-storage/csi-provisioner:v3.0.0
args:
- --timeout=60s
- --csi-address=$(ADDRESS)
- --v=5
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: Always
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-attacher
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: k8s.gcr.io/sig-storage/csi-attacher:v3.3.0
args:
- --v=5
- --csi-address=$(ADDRESS)
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: Always
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-resizer
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: k8s.gcr.io/sig-storage/csi-resizer:v1.3.0
args:
- --v=5
- --csi-address=$(ADDRESS)
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: Always
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-plugin
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: synology/synology-csi:v1.0.1
args:
- --nodeid=NotUsed
- --endpoint=$(CSI_ENDPOINT)
- --client-info
- /etc/synology/client-info.yml
- --log-level=info
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: Always
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: client-info
mountPath: /etc/synology
readOnly: true
volumes:
- name: socket-dir
emptyDir: {}
- name: client-info
secret:
secretName: client-info-secret
9 changes: 9 additions & 0 deletions deploy/kubernetes/v1.20/csi-driver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: csi.san.synology.com
spec:
attachRequired: true # Indicates the driver requires an attach operation (TODO: ControllerPublishVolume should be implemented)
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
4 changes: 4 additions & 0 deletions deploy/kubernetes/v1.20/namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: synology-csi
Loading

0 comments on commit 515bc7f

Please sign in to comment.