forked from utianayuba/kolla-ansible-aio-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cinder-csi-test.txt
129 lines (114 loc) · 3.72 KB
/
cinder-csi-test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#1. Download kubernetes cloud provider openstack repo and copy cinder-csi-plugin manifests directory
wget -c https://github.com/kubernetes/cloud-provider-openstack/archive/refs/tags/v1.20.5.zip -O cloud-provider-openstack-1.20.5.zip
unzip cloud-provider-openstack-1.20.5.zip
cp -r cloud-provider-openstack-1.20.5/manifests/cinder-csi-plugin .
#2. Copy the cloud config file from master instance and encode the content using base64
source karno-openrc.sh
openstack server list
scp core@10.14.14.1XX:/etc/kubernetes/cloud-config-occm .
base64 -w 0 cloud-config-occm
#3. Update cloud.conf configuration in csi-secret-cinderplugin.yaml file by using the result of the above command
vim cinder-csi-plugin/csi-secret-cinderplugin.yaml
...
cloud.conf: W0dsb2JhbF0KYXV0aC11cmw9aHR0cHM6Ly9leHRlcm5hbC5zdHJhdHVzLm9rOjUwMDAvdjMKdXNlci1pZD0wNGE5Y2JmZjI5MjY0NjAxYmUzOWI0MmE3ZWY2M2RjMgpwYXNzd29yZD1RcjU5eXJ3SHg4REdoS3ZZczMKdHJ1c3QtaWQ9Mzk2M2I0NzZhYThjNGM4NWE2ZjM4NzYwZGJhZDZlNzAKY2EtZmlsZT0vZXRjL2t1YmVybmV0ZXMvY2EtYnVuZGxlLmNydApyZWdpb249UmVnaW9uT25lCltMb2FkQmFsYW5jZXJdCnVzZS1vY3RhdmlhPVRydWUKc3VibmV0LWlkPTIwNzViNDRmLWRlNTctNGUwNS1hNGZiLTMxYzVkYzMyOGI5ZQpmbG9hdGluZy1uZXR3b3JrLWlkPTAzYjYwNzIzLTBmMmQtNGYwZi1hZjJhLTQ3MGY3M2E5YWFkYgpjcmVhdGUtbW9uaXRvcj15ZXMKbW9uaXRvci1kZWxheT0xbQptb25pdG9yLXRpbWVvdXQ9MzBzCm1vbml0b3ItbWF4LXJldHJpZXM9MwpbQmxvY2tTdG9yYWdlXQpicy12ZXJzaW9uPXYyCltOZXR3b3JraW5nXQppbnRlcm5hbC1uZXR3b3JrLW5hbWU9a3ViZXJuZXRlcy12MS4yMC4xMi1yYW5jaGVyMQo=
...
#4. Modify cinder-csi-controllerplugin.yaml
vim cinder-csi-plugin/cinder-csi-controllerplugin.yaml
...
- name: cinder-csi-plugin
image: docker.io/k8scloudprovider/cinder-csi-plugin:v1.20.3
...
volumeMounts:
...
- name: kubernetes-config
mountPath: /etc/kubernetes
readOnly: true
volumes:
...
- name: kubernetes-config
hostPath:
path: /etc/kubernetes
type: Directory
#5. Modify cinder-csi-nodeplugin.yaml
vim cinder-csi-plugin/cinder-csi-nodeplugin.yaml
...
- name: cinder-csi-plugin
image: docker.io/k8scloudprovider/cinder-csi-plugin:v1.20.3
...
volumeMounts:
...
- name: kubernetes-config
mountPath: /etc/kubernetes
readOnly: true
volumes:
...
- name: kubernetes-config
hostPath:
path: /etc/kubernetes
type: Directory
#6. Deploy manifests
kubectl apply -f cinder-csi-plugin/
kubectl -n kube-system get po
kubectl get csidrivers.storage.k8s.io
#7. Create a storage class for cinder
cat <<EOF > sc-cinder-csi.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: cinder-csi
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: cinder.csi.openstack.org
EOF
kubectl apply -f sc-cinder-csi.yaml
kubectl get sc
#8. Create a PVC
cat <<EOF > pvc-vol-0.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vol-0
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: cinder-csi
EOF
kubectl apply -f pvc-vol-0.yaml
kubectl get pvc
openstack volume list
#9. Create a pod with the PVC
cat <<EOF > pod-web.yaml
apiVersion: v1
kind: Pod
metadata:
name: web
spec:
containers:
- name: web
image: nginx
ports:
- name: web
containerPort: 80
hostPort: 8081
protocol: TCP
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: vol-0
volumes:
- name: vol-0
persistentVolumeClaim:
claimName: vol-0
EOF
kubectl apply -f pod-web.yaml
kubectl get po
openstack volume list
#10. Delete resources
kubectl delete po web
kubectl get po
openstack volume list
kubectl delete pvc vol-0
kubectl get pvc
openstack volume list