|
| 1 | +# Chaincode job |
| 2 | + |
| 3 | +The k8s builder runs chaincode images using a long running [Kubernetes job](https://kubernetes.io/docs/concepts/workloads/controllers/job/). Using jobs instead of bare pods [enables Kubernetes to clean up chaincode pods automatically](https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/). |
| 4 | + |
| 5 | +The k8s builder uses labels and annotations to help identify the Kubernetes objects it creates. |
| 6 | + |
| 7 | +## Labels |
| 8 | + |
| 9 | +Kubernetes objects created by the k8s builder have the following labels. |
| 10 | + |
| 11 | +app.kubernetes.io/name[^1] |
| 12 | + |
| 13 | +: The name of the application, `hyperledger-fabric` |
| 14 | + |
| 15 | +app.kubernetes.io/component[^1] |
| 16 | + |
| 17 | +: The application component, `chaincode` |
| 18 | + |
| 19 | +app.kubernetes.io/created-by[^1] |
| 20 | + |
| 21 | +: The tool that created the object, `fabric-builder-k8s` |
| 22 | + |
| 23 | +app.kubernetes.io/managed-by[^1] |
| 24 | + |
| 25 | +: The tool used to manage the application, `fabric-builder-k8s` |
| 26 | + |
| 27 | +fabric-builder-k8s-cclabel |
| 28 | + |
| 29 | +: The chaincode label, e.g. `mycc` |
| 30 | + |
| 31 | +fabric-builder-k8s-cchash |
| 32 | + |
| 33 | +: Base32 encoded chaincode hash, e.g. `U7FELJ6MQXY5RHEQLN3VSIBWD3IITI3E4EVJW3KVXJ24SZO522UQ` |
| 34 | + |
| 35 | + The chaincode hash is base32 encoded so that it fits in the maximum number of characters allowed for a Kubernetes label value. For example, if you have the chaincode package ID, use the following commands to base32 encode the chaincode hash. |
| 36 | + |
| 37 | + ```shell |
| 38 | + echo $PACKAGE_ID | cut -d':' -f2 | xxd -r -p | base32 | tr -d '=' |
| 39 | + ``` |
| 40 | + |
| 41 | +[^1]: |
| 42 | + Kubernetes defines [recommended labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/) to describe applications and instances of applications. |
| 43 | + |
| 44 | +## Annotations |
| 45 | + |
| 46 | +Kubernetes objects created by the k8s builder have the following annotations. |
| 47 | + |
| 48 | +fabric-builder-k8s-ccid |
| 49 | + |
| 50 | +: The full chaincode package ID, e.g. `mycc:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9` |
| 51 | + |
| 52 | +fabric-builder-k8s-mspid |
| 53 | + |
| 54 | +: The membership service provider ID, e.g. `DigiBank` |
| 55 | + |
| 56 | +fabric-builder-k8s-peeraddress |
| 57 | + |
| 58 | +: The peer address, e.g. `peer0.digibank.example.com` |
| 59 | + |
| 60 | +fabric-builder-k8s-peerid |
| 61 | + |
| 62 | +: The peer ID, e.g. `peer0` |
| 63 | + |
0 commit comments