I tried to create a separate channel and instantiate separate chaincodes onto the channel. I was able to create separate channels but when I instantiate the chaincode onto the cahnnels, both the chaincodes are being instantiated on both the channels created.
Even though I have set the environment variable for CHANNEL_NAME: "channel2" and CHAINCODE_NAME: "arm2", both the chaincodes are instantiated on both channels.
Here is the yaml code for chaincode instantiation of instantiating chaincode "arm2" on the channel "channel2".
---
apiVersion: batch/v1
kind: Job
metadata:
name: chaincodeinstantiate2
spec:
backoffLimit: 1
template:
metadata:
name: chaincodeinstantiate2
spec:
restartPolicy: "Never"
volumes:
- name: nfs
nfs:
server: %NFS_CLUSTER_IP%
path: /
containers:
- name: chaincodeinstantiate2
image: hyperledger/fabric-tools:x86_64-1.0.4
imagePullPolicy: Always
command: ["sh", "-c", "peer chaincode instantiate -o blockchain-orderer:31010 -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -c '{\"Args\":[\"init\",\"a\",\"100\",\"b\",\"200\"]}'"]
env:
- name: CHANNEL_NAME
value: channel2
- name: CHAINCODE_NAME
value: "arm2"
- name: CHAINCODE_VERSION
value: "1.0"
- name: FABRIC_CFG_PATH
value: /etc/hyperledger/fabric
- name: CORE_PEER_MSPCONFIGPATH
value: /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
- name: CORE_PEER_LOCALMSPID
value: Org1MSP
- name: CORE_PEER_ADDRESS
value: blockchain-org1peer1:30110
- name: GODEBUG
value: "netdns=go"
volumeMounts:
- mountPath: /shared
name: nfs
The image attached shows the chaincodes database which contains four rows consisting of chaincodes "arm1" and "arm2" on both channels "channel1" and "channel2".
How do I instantiate the chaincode "arm1" onto only channel "channel1" and chaincode "arm2" onto only channel "channel2"?