Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 26f7617

Browse files
committed
Merge branch 'master' of file:///Users/dims/go/src/github.com/kubernetes-csi/drivers into add-support-for-csi
2 parents 692c16e + 9299230 commit 26f7617

24 files changed

Lines changed: 2307 additions & 0 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Based on centos
2+
FROM centos:7.4.1708
3+
LABEL maintainers="Kubernetes Authors"
4+
LABEL description="Cinder CSI Plugin"
5+
6+
# Copy cinderplugin from build directory
7+
COPY cinderplugin /cinderplugin
8+
9+
# Install e4fsprogs for format
10+
RUN yum -y install e4fsprogs
11+
12+
# Define default command
13+
ENTRYPOINT ["/cinderplugin"]

cmd/cinder-plugin/main.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"flag"
21+
"fmt"
22+
"os"
23+
24+
"github.com/kubernetes-csi/drivers/pkg/cinder"
25+
"github.com/spf13/cobra"
26+
)
27+
28+
var (
29+
endpoint string
30+
nodeID string
31+
cloudconfig string
32+
)
33+
34+
func init() {
35+
flag.Set("logtostderr", "true")
36+
}
37+
38+
func main() {
39+
40+
flag.CommandLine.Parse([]string{})
41+
42+
cmd := &cobra.Command{
43+
Use: "Cinder",
44+
Short: "CSI based Cinder driver",
45+
Run: func(cmd *cobra.Command, args []string) {
46+
handle()
47+
},
48+
}
49+
50+
cmd.Flags().AddGoFlagSet(flag.CommandLine)
51+
52+
cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "node id")
53+
cmd.MarkPersistentFlagRequired("nodeid")
54+
55+
cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "", "CSI endpoint")
56+
cmd.MarkPersistentFlagRequired("endpoint")
57+
58+
cmd.PersistentFlags().StringVar(&cloudconfig, "cloud-config", "", "CSI driver cloud config")
59+
cmd.MarkPersistentFlagRequired("cloud-config")
60+
61+
if err := cmd.Execute(); err != nil {
62+
fmt.Fprintf(os.Stderr, "%s", err.Error())
63+
os.Exit(1)
64+
}
65+
66+
os.Exit(0)
67+
}
68+
69+
func handle() {
70+
d := cinder.NewDriver(nodeID, endpoint, cloudconfig)
71+
d.Run()
72+
}

docs/using-cinder-csi-plugin.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# CSI Cinder driver
2+
3+
## Kubernetes
4+
5+
### Requirements
6+
7+
The following feature gates and runtime config have to be enabled to deploy the driver.
8+
9+
```
10+
FEATURE_GATES=CSIPersistentVolume=true,MountPropagation=true
11+
RUNTIME_CONFIG="storage.k8s.io/v1alpha1=true"
12+
```
13+
14+
Mountprogpation requires support for privileged containers. So, make sure privileged containers are enabled in the cluster.
15+
16+
### Example local-up-cluster.sh
17+
18+
```ALLOW_PRIVILEGED=true FEATURE_GATES=CSIPersistentVolume=true,MountPropagation=true RUNTIME_CONFIG="storage.k8s.io/v1alpha1=true" LOG_LEVEL=5 hack/local-up-cluster.sh```
19+
20+
### Deploy
21+
22+
Encode your ```cloud.conf``` file content using base64.
23+
24+
```base64 -w 0 cloud.conf```
25+
26+
Update ```cloud.conf``` configuration in ```deploy/kubernetes/csi-secret-cinderplugin.yaml``` file
27+
by using the result of the above command.
28+
29+
```kubectl -f deploy/kubernetes create```
30+
31+
### Example Nginx application
32+
33+
```kubectl -f examples/kubernetes/nginx.yaml create```
34+
35+
## Using CSC tool
36+
37+
### Start Cinder driver
38+
```
39+
$ sudo ./_output/cinderplugin --endpoint tcp://127.0.0.1:10000 --cloud-config /etc/cloud.conf --nodeid CSINodeID
40+
```
41+
42+
### Test using csc
43+
Get ```csc``` tool from https://github.com/thecodeteam/gocsi/tree/master/csc
44+
45+
#### Get plugin info
46+
```
47+
$ csc identity plugin-info --endpoint tcp://127.0.0.1:10000
48+
"csi-cinderplugin" "0.1.0"
49+
```
50+
51+
#### Get supported versions
52+
```
53+
$ csc identity supported-versions --endpoint tcp://127.0.0.1:10000
54+
0.1.0
55+
```
56+
57+
#### Create a volume
58+
```
59+
$ csc controller new --endpoint tcp://127.0.0.1:10000 CSIVolumeName
60+
CSIVolumeID
61+
```
62+
63+
#### Delete a volume
64+
```
65+
$ csc controller del --endpoint tcp://127.0.0.1:10000 CSIVolumeID
66+
CSIVolumeID
67+
```
68+
69+
#### ControllerPublish a volume
70+
```
71+
$ csc controller publish --endpoint tcp://127.0.0.1:10000 --node-id=CSINodeID CSIVolumeID
72+
CSIVolumeID "DevicePath"="/dev/xxx"
73+
```
74+
75+
#### ControllerUnpublish a volume
76+
```
77+
$ csc controller unpublish --endpoint tcp://127.0.0.1:10000 --node-id=CSINodeID CSIVolumeID
78+
CSIVolumeID
79+
```
80+
81+
#### NodePublish a volume
82+
```
83+
$ csc node publish --endpoint tcp://127.0.0.1:10000 --target-path /mnt/cinder --pub-info DevicePath="/dev/xxx" CSIVolumeID
84+
CSIVolumeID
85+
```
86+
87+
#### NodeUnpublish a volume
88+
```
89+
$ csc node unpublish --endpoint tcp://127.0.0.1:10000 --target-path /mnt/cinder CSIVolumeID
90+
CSIVolumeID
91+
```
92+
93+
#### Get NodeID
94+
```
95+
$ csc node get-id --endpoint tcp://127.0.0.1:10000
96+
CSINodeID
97+
```

examples/cinder-plugin/nginx.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This YAML file contains nginx & csi cinder driver objects,
2+
# which are necessary to run nginx with csi cinder driver.
3+
4+
apiVersion: storage.k8s.io/v1
5+
kind: StorageClass
6+
metadata:
7+
name: csi-sc-cinderplugin
8+
provisioner: csi-cinderplugin
9+
parameters:
10+
11+
---
12+
apiVersion: v1
13+
kind: PersistentVolumeClaim
14+
metadata:
15+
name: csi-pvc-cinderplugin
16+
spec:
17+
accessModes:
18+
- ReadWriteOnce
19+
resources:
20+
requests:
21+
storage: 1Gi
22+
storageClassName: csi-sc-cinderplugin
23+
24+
---
25+
apiVersion: v1
26+
kind: Pod
27+
metadata:
28+
name: nginx
29+
spec:
30+
containers:
31+
- image: nginx
32+
imagePullPolicy: IfNotPresent
33+
name: nginx
34+
ports:
35+
- containerPort: 80
36+
protocol: TCP
37+
volumeMounts:
38+
- mountPath: /var/lib/www/html
39+
name: csi-data-cinderplugin
40+
volumes:
41+
- name: csi-data-cinderplugin
42+
persistentVolumeClaim:
43+
claimName: csi-pvc-cinderplugin
44+
readOnly: false
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This YAML file contains attacher & csi driver API objects,
2+
# which are necessary to run external csi attacher for cinder.
3+
4+
kind: Service
5+
apiVersion: v1
6+
metadata:
7+
name: csi-attacher-cinderplugin
8+
labels:
9+
app: csi-attacher-cinderplugin
10+
spec:
11+
selector:
12+
app: csi-attacher-cinderplugin
13+
ports:
14+
- name: dummy
15+
port: 12345
16+
17+
---
18+
kind: StatefulSet
19+
apiVersion: apps/v1beta1
20+
metadata:
21+
name: csi-attacher-cinderplugin
22+
spec:
23+
serviceName: "csi-attacher-cinderplugin"
24+
replicas: 1
25+
template:
26+
metadata:
27+
labels:
28+
app: csi-attacher-cinderplugin
29+
spec:
30+
serviceAccount: csi-attacher
31+
containers:
32+
- name: csi-attacher
33+
image: docker.io/k8scsi/csi-attacher
34+
args:
35+
- "--v=5"
36+
- "--csi-address=$(ADDRESS)"
37+
env:
38+
- name: ADDRESS
39+
value: /var/lib/csi/sockets/pluginproxy/csi.sock
40+
imagePullPolicy: "IfNotPresent"
41+
volumeMounts:
42+
- name: socket-dir
43+
mountPath: /var/lib/csi/sockets/pluginproxy/
44+
- name: cinder
45+
image: docker.io/k8scsi/cinderplugin
46+
args :
47+
- "--nodeid=$(NODE_ID)"
48+
- "--endpoint=$(CSI_ENDPOINT)"
49+
- "--cloud-config=$(CLOUD_CONFIG)"
50+
env:
51+
- name: NODE_ID
52+
valueFrom:
53+
fieldRef:
54+
fieldPath: spec.nodeName
55+
- name: CSI_ENDPOINT
56+
value: unix://plugin/csi.sock
57+
- name: CLOUD_CONFIG
58+
value: /etc/config/cloud.conf
59+
imagePullPolicy: "IfNotPresent"
60+
volumeMounts:
61+
- name: socket-dir
62+
mountPath: /plugin
63+
- name: secret-cinderplugin
64+
mountPath: /etc/config
65+
readOnly: true
66+
volumes:
67+
- name: socket-dir
68+
emptyDir:
69+
- name: secret-cinderplugin
70+
secret:
71+
secretName: csi-secret-cinderplugin
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This YAML file contains RBAC API objects,
2+
# which are necessary to run external csi attacher for cinder.
3+
4+
apiVersion: v1
5+
kind: ServiceAccount
6+
metadata:
7+
name: csi-attacher
8+
9+
---
10+
kind: ClusterRole
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
metadata:
13+
name: external-attacher-runner
14+
rules:
15+
- apiGroups: [""]
16+
resources: ["persistentvolumes"]
17+
verbs: ["get", "list", "watch", "update"]
18+
- apiGroups: [""]
19+
resources: ["nodes"]
20+
verbs: ["get", "list", "watch"]
21+
- apiGroups: ["storage.k8s.io"]
22+
resources: ["volumeattachments"]
23+
verbs: ["get", "list", "watch", "update"]
24+
25+
---
26+
kind: ClusterRoleBinding
27+
apiVersion: rbac.authorization.k8s.io/v1
28+
metadata:
29+
name: csi-attacher-role
30+
subjects:
31+
- kind: ServiceAccount
32+
name: csi-attacher
33+
namespace: default
34+
roleRef:
35+
kind: ClusterRole
36+
name: external-attacher-runner
37+
apiGroup: rbac.authorization.k8s.io

0 commit comments

Comments
 (0)