一起來讀 Kubernetes
的 Source Code
印章
2021/12/29
一次 CSI Bug 排查紀實
印章 (seal.tw ),不是海豹
本名 吳易璋
社群打雜:
Gitlab Taiwan
Cloud Native Taiwan User Group
支援 NFS 、 iSCSI 、 Fiber Channel (FC) 等多種介面
支援 NFS Quota、Multipath、Dynamic Provision (PVC)
CSI Spec 支援 Resize 、 Snapshot (可選)
快速的 Release 週期 (擺脫 in-tree 的繁瑣程序,及 golang限制)
原廠提供的專業 support
(Nutanix、NetApp、VMWare、AWS GP2 也都有類似的機制)
支援 NFS 、 iSCSI 、 Fiber Channel (FC) 等多種介面
支援 NFS Quota、Multipath、
https://dell.github.io/csm-docs/docs/csidriver/
{
"storageArrayList": [
{
"username": "user",
"password": "password",
"restGateway": "https://10.1.1.1",
"arrayId": "APM00******1",
"insecure": true,
"isDefaultArray": true
},
{
"username": "user",
"password": "password",
"restGateway": "https://10.1.1.2",
"arrayId": "APM00******2",
"insecure": true
}
]
}
apiVersion: storage.dell.com/v1
kind: CSIUnity
metadata:
name: test-unity
namespace: test-unity
spec:
driver:
common:
image: "dellemc/csi-unity:v1.5.0"
sideCars:
- name: provisioner
args:
- "--volume-name-prefix=csiunity"
storageClass:
- name: virt2017****-iscsi
reclaimPolicy: "Delete"
allowVolumeExpansion: true
parameters:
storagePool: pool_1
arrayId: "APM00******1"
protocol: "iSCSI"
- name: virt2017****-nfs
parameters:
storagePool: pool_1
arrayId: "APM00******2"
protocol: "NFS"
https://github.com/container-storage-interface/spec/blob/master/spec.md
external
provisioner
external
attacher
driver
registrar
https://github.com/container-storage-interface/spec/blob/master/spec.md
CSI
Controller
CSI Node
(Driver)
/var/lib/kubelet/plugins/kubernetes.io/ csi/pv/pvc-xxx/globalmount
/var/lib/kubelet/plugins/ kubernetes.io~csi-unity.dellemc.com /pvc-xxx/globalmount
csi-unity.dellemc.com^csiunity-**********-iSCSI-APM00******1-sv_42
csi-unity.dellemc.com
csiunity-**********-iSCSI-APM00******1-sv_42
csiunity-**********
iSCSI
APM00******1
sv_42
round_trippers.go:420]
DELETE https://api-int.my-cluster.ocp:6443
/apis/storage.k8s.io/v1/volumeattachments/
csi-unity.dellemc.com%5Ecsiunity-**********-iSCSI-**************-sv_42
round_trippers.go:446]
Response Status: 404 Not Found in 8 milliseconds
csi_attacher.go:411]
kubernetes.io/csi: VolumeAttachment object [csi-unity.dellemc.com^csiunity-**********-iSCSI-**************-sv_42]
for volume [csi-unity.dellemc.com^csiunity-**********-iSCSI-**************-sv_42]
not found, object deleted
operation_generator.go:472]
DetachVolume.Detach succeeded for volume "csiunity-**********"
(UniqueName: "csi-unity.dellemc.com^csiunity-**********-iSCSI-**************-sv_42")
on node "worker01.my-cluster.ocp"
// getAttachmentName returns
// csi-<sha256(volName,csiDriverName,NodeName)>
func getAttachmentName(volName, csiDriverName, nodeName string) string {
result := sha256.Sum256([]byte(fmt.Sprintf("%s%s%s", volName, csiDriverName, nodeName)))
return fmt.Sprintf("csi-%x", result)
}
// isAttachmentName returns true
// if the string given is of the form of an Attach ID
// and false otherwise
func isAttachmentName(unknownString string) bool {
// 68 == "csi-" + len(sha256hash)
return strings.HasPrefix(unknownString, "csi-") && len(unknownString) == 68
}
kind: CSIUnity
metadata:
namespace: unity
name: openshift-unity
spec:
driver:
common:
image: dellemc/csi-unity:v1.4.0.000R
configVersion: v3
sideCars:
- args:
- --volume-name-prefix=csiunity-openshift
image: k8s.gcr.io/sig-storage/csi-provisioner:v2.0.2
imagePullPolicy: IfNotPresent
name: provisioner
其實直接 telegram 扔我CV比較快 (X