Develop with Kind on MacOS
Requirements
- kind (version > v0.10.0)
- docker
- MacOS
csi-driver
and node-driver-registrar
(sidecar) need to communicate with kubelet,
so run them in kind container
Set up steps
1. download go source code
In order to run csi-driver
and node-driver-registrar
code in kind container
download it from go1.16.3.linux-amd64.tar.gz
decompress it and put it in ~/go/local/
directory
~/go
|__bin
|__pkg
|__src
| |__ github.com
| |__ sigs.k8s.io
| |__ k8s.io
|__local
| |__go
2. create kind cluster
$ kind create cluster --config=cluster.yaml
# cluster.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: fluid-dev
nodes:
- role: control-plane
image: kindest/node:v1.16.1
extraMounts:
- hostPath: /your/Mac/go/path # GOPATH value on Mac
containerPath: /home/work/go
# check kind cluster node
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
fluid-dev-control-plane Ready master 74s v1.16.15
3. create fluid crds and csi driver to kind cluster
- alluxioruntimes.data.fluid.io
- databackups.data.fluid.io
- dataloads.data.fluid.io
- datasets.data.fluid.io
- jindoruntimes.data.fluid.io
- fuse.csi.fluid.io
$ cd ~/go/src/github.com/fluid-cloudnative/fluid
$ kustomize build config/crd/ | kubectl apply -f -
customresourcedefinition.apiextensions.k8s.io/alluxioruntimes.data.fluid.io created
customresourcedefinition.apiextensions.k8s.io/databackups.data.fluid.io created
customresourcedefinition.apiextensions.k8s.io/dataloads.data.fluid.io created
customresourcedefinition.apiextensions.k8s.io/datasets.data.fluid.io created
customresourcedefinition.apiextensions.k8s.io/jindoruntimes.data.fluid.io created
$ kubectl apply -f ./csi/deploy/csi-fluid-driver.yaml
$ kubectl get csidriver
NAME CREATED AT
fuse.csi.fluid.io 2021-04-24T15:30:38Z
4. download helm and create soft link charts
# download helm to ~/tmp/ unpack it and move to ~/go/bin
$ cd ~/tmp/ && curl https://get.helm.sh/helm-v3.6.2-darwin-amd64.tar.gz -o helm-v3.6.2-darwin-amd64.tar.gz
$ tar xzvf helm-v3.6.2-darwin-amd64.tar.gz && cp darwin-amd64/helm ~/go/bin/ddc-helm
# create charts soft link
$ ln -s ~/go/src/github.com/fluid-cloudnative/fluid/charts ~/charts
5. run csi-driver and node-driver-registrar code in kind node container
start fluid csi driver
docker exec -ti fluid-dev-control-plane /bin/bash
cd /home/work/go/src/github.com/fluid-cloudnative/fluid/cmd/csi && sh start.sh
#! /bin/bash
set -x
export TMPDIR=/root/go/tmp
export GO111MODULE=on
export GOMODCACHE=/root/go/pkg/mod
export GOPROXY=https://goproxy.io
export GOPATH=/home/work/go
export GOROOT=/home/work/go/local/go
export GOBIN=/home/work/go/bin
export PATH=$PATH:$GOBIN:$GOROOT/bin
if [ ! -d $TMPDIR ]; then
mkdir -p $TMPDIR
fi
rm -f /var/lib/kubelet/csi-plugins/fuse.csi.fluid.io/csi.sock
mkdir -p /var/lib/kubelet/csi-plugins/fuse.csi.fluid.io
cp /home/work/go/src/github.com/allenhaozi/fluid/csi/shell/check_mount.sh /usr/local/bin/check_mount.sh && chmod +x /usr/local/bin/check_mount.sh
/home/work/go/local/go/bin/go run main.go start \
--endpoint="unix://var/lib/kubelet/csi-plugins/fuse.csi.fluid.io/csi.sock" \
--nodeid="fluid-dev-control-plane" \
--kubeconfig=/etc/kubernetes/kubelet.conf \
--v=5
start node-driver-registrar
I made a small change to node-driver-registrar based on v1.3.0,
It can be downloaded from fluid-dev-v1.3.0
The only change is to allow passingreg-path
in arguments
Does not affect the csi-driver online
docker exec -ti fluid-dev-control-plane /bin/bash
$ cd /home/work/go/src/github.com/allenhaozi/node-driver-registrar/cmd/csi-node-driver-registrar && sh start.sh