Mictract (MICro-serviced smart conTRACT), focus on applying traditional DevOps tools to the smart contract development process, based on Hyperledger / Fabric.
WIP now.
-
install
nfs-utils
-
expose the data directory, which will be used for storing networks. Note: this path is corresponds to
config.NFS_EXPOSED_PATH
in the source code./var/mictract *(rw,all_squash,fsid=0,anonuid=0,anongid=0,insecure)
-
run it.
systemctl enable --now nfs-server
-
configure database:
-
start your mysql database. For example, use mysql on docker:
docker run --name mic-mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql:8
-
expose external database service into k8s. Edit
k8s/mysql-svc.yaml
andk apply -f k8s/mysql-svc.yaml
.
-
-
put your k8s config and
template/configtx.yaml.tpl
andtemplate/channel.yaml.tpl
andscripts
onconfig.NFS_EXPOSED_PATH
, yourkube-config.yaml
should be like this:Note: the
certificate-authority-data
andclient-key-data
are base64 encoded.apiVersion: v1 clusters: - cluster: certificate-authority-data: LS0tL...UZJQ0FURS0tLS0tCg== extensions: server: https://kubernetes:443 name: minikube contexts: - context: cluster: minikube namespace: default user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate-data: LS0tL...CBDRVJUSUZJQ0FURS0tLS0tCg== client-key-data: LS0tL...FJTQSBQUklWQVRFIEtFWS0tLS0tCg==
-
check your network directory, which should be like this:
mictract ├── configtx.yaml.tpl ├── channel.yaml.tpl ├── kube-config.yaml └── scripts
We use Prometheus for network monitoring.
-
Add prometheus to your k8s. (If you have one, you should ensure your prometheus can monitor k8s cAdvisor)
kubectl apply -k k8s/prometheus
-
Check if prometheus is running.
kubectl get pod kubectl get svc
If it's correct, you can see the
prometheus
pod and service running.NAME READY STATUS RESTARTS AGE ... prometheus-7dddd47bcf-7w8td 1/1 Running 0 2s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ... prometheus NodePort 10.109.131.55 <none> 9090:30500/TCP 2s
-
setup minikube.
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube minikube start
Then you can use
minikube ip
as kubernetes api-server ip. -
edit
dev-deploy.yaml
, and run mictract-dev env, where the dlv and sftp is deployed.k apply -k k8s/dev
-
use sftp to sync your code.
-
[optional] change shell.
chsh -s /bin/zsh
-
configure mysql and nfs
export NFS_SERVER_URL=x.x.x.x export DB_SERVER_URL=x.x.x.x export DB_PW=YourDatabasePassword
-
run dlv when you need to debug.
dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient // Or you just want simplest unit test on a function: cd src/test go test * -test.run TestListNetworks -v
Or, when you need to run it,
go run main.go
via ssh terminal directly.