Azure Blob Storage CSI driver development guide
July 7, 2021 ยท View on GitHub
- Clone repo
$ mkdir -p $GOPATH/src/sigs.k8s.io
$ git clone https://github.com/kubernetes-sigs/blob-csi-driver $GOPATH/src/sigs.k8s.io/blob-csi-driver
- Build Blob Storage CSI driver
$ cd $GOPATH/src/sigs.k8s.io/blob-csi-driver
$ make blob
- Run verification before sending PR
$ make verify
- If there is config file changed under
chartsdirectory, run following command to update chart file.
helm package charts/latest/blob-csi-driver -d charts/latest/
- Build container image and push to dockerhub
export REGISTRY_NAME=<dockerhub-alias>
make push-latest
Test locally using csc tool
Install csc tool according to https://github.com/rexray/gocsi/tree/master/csc:
$ mkdir -p $GOPATH/src/github.com
$ cd $GOPATH/src/github.com
$ git clone https://github.com/rexray/gocsi.git
$ cd rexray/gocsi/csc
$ make build
Start CSI driver locally
$ cd $GOPATH/src/sigs.k8s.io/blob-csi-driver
$ ./_output/blobplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode -v=5 &
Before running CSI driver, create "/etc/kubernetes/azure.json" file under testing server(it's better copy
azure.jsonfile from a k8s cluster with service principle configured correctly) and setAZURE_CREDENTIAL_FILEas following:
export set AZURE_CREDENTIAL_FILE=/etc/kubernetes/azure.json
1. Get plugin info
$ csc identity plugin-info --endpoint tcp://127.0.0.1:10000
"blob.csi.azure.com" "v0.7.0"
2. Create an blobfuse volume
$ csc controller new --endpoint tcp://127.0.0.1:10000 --cap 1,block CSIVolumeName --req-bytes 2147483648 --params skuname=Standard_LRS
"andy-mg1160alpha3#fuse4ef4b1d0c53d41bc88f#csivolumename" 2147483648 "skuname"="Standard_LRS"
3. Stage volume
mkdir /tmp/staging-target-path
csc node stage --endpoint tcp://127.0.0.1:10000 --cap 1,block --staging-target-path /tmp/staging-target-path "andy-mg1160alpha3#fuse4ef4b1d0c53d41bc88f#csivolumename"
4. Publish volume
mkdir /tmp/target-path
csc node publish --endpoint tcp://127.0.0.1:10000 --cap 1,block --staging-target-path /tmp/staging-target-path --target-path /tmp/target-path "andy-mg1160alpha3#fuse4ef4b1d0c53d41bc88f#csivolumename"
5. Unpublish volume
csc node unpublish --endpoint tcp://127.0.0.1:10000 --target-path /tmp/target-path "andy-mg1160alpha3#fuse4ef4b1d0c53d41bc88f#csivolumename"
6. Unstage volume
csc node unstage --endpoint tcp://127.0.0.1:10000 --staging-target-path /tmp/staging-target-path "andy-mg1160alpha3#fuse4ef4b1d0c53d41bc88f#csivolumename"
7. Delete blobfuse volume
$ csc controller del --endpoint tcp://127.0.0.1:10000 CSIVolumeID
CSIVolumeID
8. Validate volume capabilities
$ csc controller validate-volume-capabilities --endpoint tcp://127.0.0.1:10000 --cap 1,block CSIVolumeID
CSIVolumeID true
9. Get NodeID
$ csc node get-info --endpoint tcp://127.0.0.1:10000
CSINode
10. Create snapshot
$ csc controller create-snapshot
11. Delete snapshot
$ csc controller delete-snapshot
How to update chart index
helm repo index charts --url=https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/charts
How to debug Dockerfile config
- create
blob.Dockerfilefile
FROM us.gcr.io/k8s-artifacts-prod/build-image/debian-base-amd64:v2.1.0
RUN apt-get update && clean-install ca-certificates pkg-config libfuse-dev cmake libcurl4-gnutls-dev libgnutls28-dev uuid-dev libgcrypt20-dev wget
RUN wget -O /tmp/packages-microsoft-prod.deb https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb && dpkg -i /tmp/packages-microsoft-prod.deb && apt-get update && apt install blobfuse fuse -y && rm -f /tmp/packages-microsoft-prod.deb
RUN apt remove wget -y
# this is a workaround to install nfs-common & nfs-kernel-server and don't quit with error
RUN apt update && apt install nfs-common nfs-kernel-server -y || true
LABEL maintainers="andyzhangx"
LABEL description="Azure Blob Storage CSI driver"
- build image from
blob.Dockerfile
docker build --no-cache -t andyzhangx/blobnfs:v1 -f ./blob.Dockerfile .
docker run --network host -it andyzhangx/blobnfs:v1 sh