Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Chaincode #20

Open
jchai002 opened this issue Aug 7, 2019 · 2 comments
Open

Install Chaincode #20

jchai002 opened this issue Aug 7, 2019 · 2 comments

Comments

@jchai002
Copy link

jchai002 commented Aug 7, 2019

How do we install chaincode after setting up the network in this manner? The official hyperledger documentation uses a docker CLI container that can access the peers. But I don't see an equivalent pod in this kubernetes setup.

@Comonut
Copy link

Comonut commented Aug 15, 2019

Hey, I'm facing the same issue. Can you please share if you find a solution?

@NeoMotsumi
Copy link

NeoMotsumi commented Nov 1, 2019

Hi
@Comonut & @jchai002

I know this might be late, I hope you can still find this useful; but you can setup a fabric tools POD

apiVersion: v1
kind: Pod
metadata:
name: fabric-tools
spec:
volumes:

  • name: fabricfiles
    persistentVolumeClaim:
    claimName: your-pvc
  • name: dockersocket
    hostPath:
    path: /var/run/docker.sock
    containers:
    • name: fabrictools
      image: hyperledger/fabric-tools:amd64-1.3.0
      imagePullPolicy: Always
      command: ["sh", "-c", "sleep 48h"]
      env:
      • name: FABRIC_CFG_PATH
        value: "/fabric"
        volumeMounts:
        • mountPath: /fabric
          name: fabricfiles
        • mountPath: /host/var/run/docker.sock
          name: dockersocket

1)Apply kubectl apply -f kubernetes/fabric-tools.yaml

  1. Then copy your chaincode into your desired folder into the pod; copy your MSP folders too.

  2. Install Chaincode
    kubectl exec -it fabric-tools -- /bin/bash
    cp -r /chaincode-folder $GOPATH/src/

export MY_CHAINCODE_NAME="my-chaincode"
export CHAINCODE_VERSION="1.0"
export FABRIC_CFG_PATH="/etc/hyperledger/fabric"
export CORE_PEER_MSPCONFIGPATH="/Path-to-msp"
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_ADDRESS="peer-address:7051"

peer chaincode install -n ${MY_CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p path-to-chaincode

  1. Instantiate Chaincode (After install chaincode on all your peers)
    export ORDERER_URL="orderer-address:7050"
    export MY_CHANNEL_NAME="mychannel"

  2. peer chaincode instantiate -o ${ORDERER_URL} -C ${MY_CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -c '{"Args":["Init"]}''

**you can add -P if you wanna setup endorsement policies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants