Skip to content

Commit

Permalink
feat: added csi support
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaser committed Oct 21, 2022
1 parent 90c2174 commit c9a2374
Show file tree
Hide file tree
Showing 8 changed files with 506 additions and 13 deletions.
17 changes: 13 additions & 4 deletions magnum_cluster_api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ def create_cluster(self, context, cluster, cluster_create_timeout):
k8s = pykube.HTTPClient(pykube.KubeConfig.from_env())

resources.Namespace(k8s).apply()

resources.CloudControllerManagerConfigMap(k8s, cluster).apply()
resources.CloudControllerManagerClusterResourceSet(k8s, cluster).apply()

if cluster.cluster_template.network_driver == "calico":
resources.CalicoConfigMap(k8s, cluster).apply()
resources.CalicoClusterResourceSet(k8s, cluster).apply()
resources.CalicoConfigMap(k8s, cluster).apply()
resources.CalicoClusterResourceSet(k8s, cluster).apply()

resources.CinderCSIConfigMap(k8s, cluster).apply()
resources.CinderCSIClusterResourceSet(k8s, cluster).apply()

credential = osc.keystone().client.application_credentials.create(
user=cluster.user_id,
Expand Down Expand Up @@ -200,7 +203,13 @@ def create_nodegroup(self, context, cluster, nodegroup, credential=None):
credential=credential,
).apply()
else:
resources.KubeadmConfigTemplate(k8s, cluster).apply()
resources.KubeadmConfigTemplate(
k8s,
cluster,
auth_url=osc.auth_url,
region_name=osc.cinder_region_name(),
credential=credential,
).apply()
resources.MachineDeployment(k8s, cluster, nodegroup).apply()

def update_nodegroup_status(self, context, cluster, nodegroup):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: csi-resizer-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: csi-resizer-role
subjects:
- kind: ServiceAccount
name: csi-cinder-controller-sa
namespace: kube-system
137 changes: 137 additions & 0 deletions magnum_cluster_api/manifests/csi/cinder-csi-controllerplugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-cinder-controller-sa
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: csi-cinder-controllerplugin
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: csi-cinder-controllerplugin
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app: csi-cinder-controllerplugin
spec:
containers:
- args:
- --csi-address=$(ADDRESS)
- --timeout=3m
- --leader-election=true
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
image: k8s.gcr.io/sig-storage/csi-attacher:v3.4.0
imagePullPolicy: IfNotPresent
name: csi-attacher
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
- args:
- --csi-address=$(ADDRESS)
- --timeout=3m
- --default-fstype=ext4
- --feature-gates=Topology=true
- --extra-create-metadata
- --leader-election=true
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
image: k8s.gcr.io/sig-storage/csi-provisioner:v3.1.0
imagePullPolicy: IfNotPresent
name: csi-provisioner
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
- args:
- --csi-address=$(ADDRESS)
- --timeout=3m
- --extra-create-metadata
- --leader-election=true
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
image: k8s.gcr.io/sig-storage/csi-snapshotter:v6.0.1
imagePullPolicy: Always
name: csi-snapshotter
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
- args:
- --csi-address=$(ADDRESS)
- --timeout=3m
- --handle-volume-inuse-error=false
- --leader-election=true
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0
imagePullPolicy: IfNotPresent
name: csi-resizer
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
- args:
- --csi-address=$(ADDRESS)
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
image: k8s.gcr.io/sig-storage/livenessprobe:v2.7.0
name: liveness-probe
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
- args:
- /bin/cinder-csi-plugin
- --endpoint=$(CSI_ENDPOINT)
- --cloud-config=$(CLOUD_CONFIG)
- --cluster=$(CLUSTER_NAME)
env:
- name: CSI_ENDPOINT
value: unix://csi/csi.sock
- name: CLOUD_CONFIG
value: /etc/config/cloud.conf
- name: CLUSTER_NAME
value: kubernetes
image: docker.io/k8scloudprovider/cinder-csi-plugin:latest
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 5
httpGet:
path: /healthz
port: healthz
initialDelaySeconds: 10
periodSeconds: 60
timeoutSeconds: 10
name: cinder-csi-plugin
ports:
- containerPort: 9808
name: healthz
protocol: TCP
volumeMounts:
- mountPath: /csi
name: socket-dir
- mountPath: /etc/config/cloud.conf
name: secret-cinderplugin
readOnly: true
securityContext:
runAsUser: 0
serviceAccount: csi-cinder-controller-sa
volumes:
- emptyDir: null
name: socket-dir
- hostPath:
path: /etc/kubernetes/cloud.conf
type: File
name: secret-cinderplugin
12 changes: 12 additions & 0 deletions magnum_cluster_api/manifests/csi/cinder-csi-nodeplugin-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: csi-nodeplugin-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: csi-nodeplugin-role
subjects:
- kind: ServiceAccount
name: csi-cinder-node-sa
namespace: kube-system
117 changes: 117 additions & 0 deletions magnum_cluster_api/manifests/csi/cinder-csi-nodeplugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-cinder-node-sa
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: csi-cinder-nodeplugin
namespace: kube-system
spec:
selector:
matchLabels:
app: csi-cinder-nodeplugin
template:
metadata:
labels:
app: csi-cinder-nodeplugin
spec:
containers:
- args:
- --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/cinder.csi.openstack.org/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.1
imagePullPolicy: IfNotPresent
name: node-driver-registrar
volumeMounts:
- mountPath: /csi
name: socket-dir
- mountPath: /registration
name: registration-dir
- args:
- --csi-address=/csi/csi.sock
image: k8s.gcr.io/sig-storage/livenessprobe:v2.7.0
name: liveness-probe
volumeMounts:
- mountPath: /csi
name: socket-dir
- args:
- /bin/cinder-csi-plugin
- --endpoint=$(CSI_ENDPOINT)
- --cloud-config=$(CLOUD_CONFIG)
env:
- name: CSI_ENDPOINT
value: unix://csi/csi.sock
- name: CLOUD_CONFIG
value: /etc/config/cloud.conf
image: docker.io/k8scloudprovider/cinder-csi-plugin:latest
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 5
httpGet:
path: /healthz
port: healthz
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 3
name: cinder-csi-plugin
ports:
- containerPort: 9808
name: healthz
protocol: TCP
securityContext:
allowPrivilegeEscalation: true
capabilities:
add:
- SYS_ADMIN
privileged: true
volumeMounts:
- mountPath: /csi
name: socket-dir
- mountPath: /var/lib/kubelet
mountPropagation: Bidirectional
name: kubelet-dir
- mountPath: /dev
mountPropagation: HostToContainer
name: pods-probe-dir
- mountPath: /etc/config/cloud.conf
name: secret-cinderplugin
readOnly: true
hostNetwork: true
securityContext:
runAsUser: 0
serviceAccount: csi-cinder-node-sa
tolerations:
- operator: Exists
volumes:
- hostPath:
path: /var/lib/kubelet/plugins/cinder.csi.openstack.org
type: DirectoryOrCreate
name: socket-dir
- hostPath:
path: /var/lib/kubelet/plugins_registry/
type: Directory
name: registration-dir
- hostPath:
path: /var/lib/kubelet
type: Directory
name: kubelet-dir
- hostPath:
path: /dev
type: Directory
name: pods-probe-dir
- hostPath:
path: /etc/kubernetes/cloud.conf
type: File
name: secret-cinderplugin
10 changes: 10 additions & 0 deletions magnum_cluster_api/manifests/csi/csi-cinder-driver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: cinder.csi.openstack.org
spec:
attachRequired: true
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
- Ephemeral
Loading

0 comments on commit c9a2374

Please sign in to comment.