Skip to content

Instantly share code, notes, and snippets.

@j-griffith
Last active June 26, 2018 23:08
Show Gist options
  • Select an option

  • Save j-griffith/3697bdd7b8bd1ed206627147e6a70d88 to your computer and use it in GitHub Desktop.

Select an option

Save j-griffith/3697bdd7b8bd1ed206627147e6a70d88 to your computer and use it in GitHub Desktop.
K8's manifest to deploy cinderlib-lvm CSI driver
# To run you'll need to create an LVM VG named cinder-volumes on the node that will run the cinderlib-lvm pod
# Make sure you enable privileged on your K8's cluster (ie if you're running hack/local-up-cluster.sh you'll need:
# `ALLOW_PRIVILEGED=true hack/local-up-cluster.sh`
# The manifest here should handle the rest, note connect/attach is a work in progress, however provisioning works
# There is a bug with provisioning however, the resultant LV's are 12M in size, even though we're requesting 1G
# There also seems to be some locking contention of LVM2, and I haven't identified exactly where that's coming from
# yet, but I haven't seen it in BlockBox
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: csi-cinderlib-lvm-sc
provisioner: csi-cinderlib-lvm
reclaimPolicy: Delete
volumeBindingMode: Immediate
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-service-account
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: csi-cluster-role
rules:
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- create
- delete
- get
- list
- watch
- update
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- apiGroups:
- ""
resources:
- persistentvolumeclaims
verbs:
- get
- list
- watch
- update
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- update
- apiGroups:
- storage.k8s.io
resources:
- volumeattachments
verbs:
- get
- list
- watch
- update
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- list
- watch
- create
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: csi-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: csi-cluster-role
subjects:
- kind: ServiceAccount
name: csi-service-account
namespace: default
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: cinderlib-driver
name: cinderlibcsi-pod
namespace: default
spec:
serviceAccount: csi-service-account
containers:
- name: external-provisioner
args:
- --v=5
- --provisioner=csi-cinderlib-lvm
- --csi-address=/csi/csi.sock
image: quay.io/k8scsi/csi-provisioner:v0.2.1
imagePullPolicy: Always
volumeMounts:
- mountPath: /csi
name: socket-dir
- name: driver-registrar
args:
- --v=5
- --csi-address=/csi/csi.sock
env:
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
image: quay.io/k8scsi/driver-registrar:v0.2.0
imagePullPolicy: Always
volumeMounts:
- mountPath: /csi
name: socket-dir
- name: external-attacher
args:
- --v=5
- --csi-address=$(ADDRESS)
env:
- name: ADDRESS
value: /csi/csi.sock
image: quay.io/k8scsi/csi-attacher:v0.2.0
imagePullPolicy: Always
volumeMounts:
- mountPath: /csi
name: socket-dir
- name: cinderlib-csi-driver
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
- name: ADDRESS
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: X_CSI_PERSISTENCE_CONFIG
value: '{"storage":"db","connection":"sqlite:////var/lib/cinder/db.sqlite"}'
- name: X_CSI_BACKEND_CONFIG
value: '{"volume_backend_name":"lvm","volume_driver":"cinder.volume.drivers.lvm.LVMVolumeDriver","volume_group":"cinder-volumes"}'
image: jgriffith/cinderlib-csi:debian
securityContext:
privileged: true
volumeMounts:
- mountPath: /lib/modules
mountPropagation: Bidirectional
name: modules-dir
- mountPath: /run
mountPropagation: Bidirectional
name: run-dir
- mountPath: /csi
name: socket-dir
- mountPath: /var/lib/cinder
mountPropagation: Bidirectional
name: cinder-meta-dir
- mountPath: /etc/iscsi
mountPropagation: Bidirectional
name: iscsi-dir
- mountPath: /mnt
mountPropagation: Bidirectional
name: mountpoint-dir
volumes:
- hostPath:
path: /var/lib/kubelet/plugins/csi-hostpath
type: DirectoryOrCreate
name: socket-dir
- hostPath:
path: /tmp/mnt
type: DirectoryOrCreate
name: mountpoint-dir
- hostPath:
path: /tmp/cinder
type: DirectoryOrCreate
name: cinder-meta-dir
- hostPath:
path: /etc/iscsi
name: iscsi-dir
- hostPath:
path: /run
name: run-dir
- hostPath:
path: /lib/modules
name: modules-dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment