Skip to content

Commit be467d4

Browse files
committed
Add chaincode job concept to doc
Also documents removing vm.endpoint from core.yaml and other minor updates See #229 and #223 Signed-off-by: James Taylor <[email protected]>
1 parent 32e03ab commit be467d4

File tree

7 files changed

+96
-20
lines changed

7 files changed

+96
-20
lines changed

docs/concepts/chaincode-job.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+

docs/configuring/overview.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,33 @@ Fabric peers must be configured to use the k8s external builder, and to propagat
66

77
External builders are configured in the `core.yaml` file, for example:
88

9+
```yaml
10+
externalBuilders:
11+
- name: k8s_builder
12+
path: /opt/hyperledger/k8s_builder
13+
propagateEnvironment:
14+
- CORE_PEER_ID
15+
- FABRIC_K8S_BUILDER_DEBUG
16+
- FABRIC_K8S_BUILDER_NAMESPACE
17+
- FABRIC_K8S_BUILDER_NODE_ROLE
18+
- FABRIC_K8S_BUILDER_OBJECT_NAME_PREFIX
19+
- FABRIC_K8S_BUILDER_SERVICE_ACCOUNT
20+
- FABRIC_K8S_BUILDER_START_TIMEOUT
21+
- KUBERNETES_SERVICE_HOST
22+
- KUBERNETES_SERVICE_PORT
923
```
10-
externalBuilders:
11-
- name: k8s_builder
12-
path: /opt/hyperledger/k8s_builder
13-
propagateEnvironment:
14-
- CORE_PEER_ID
15-
- FABRIC_K8S_BUILDER_DEBUG
16-
- FABRIC_K8S_BUILDER_NAMESPACE
17-
- FABRIC_K8S_BUILDER_NODE_ROLE
18-
- FABRIC_K8S_BUILDER_OBJECT_NAME_PREFIX
19-
- FABRIC_K8S_BUILDER_SERVICE_ACCOUNT
20-
- FABRIC_K8S_BUILDER_START_TIMEOUT
21-
- KUBERNETES_SERVICE_HOST
22-
- KUBERNETES_SERVICE_PORT
24+
25+
If you are only planning to use the k8s builder and do not need to fallback to the legacy Docker build process for any chaincode, check your `core.yaml` file for the `vm.endpoint` Docker endpoint configuration shown below and remove it if necessary.
26+
27+
```yaml
28+
vm:
29+
# Endpoint of the vm management system. For docker can be one of the following in general
30+
# unix:///var/run/docker.sock
31+
# http://localhost:2375
32+
# https://localhost:2376
33+
# If you utilize external chaincode builders and don't need the default Docker chaincode builder,
34+
# the endpoint should be unconfigured so that the peer's Docker health checker doesn't get registered.
35+
endpoint: unix:///var/run/docker.sock
2336
```
2437

2538
For more information, see [Configuring external builders and launchers](https://hyperledger-fabric.readthedocs.io/en/latest/cc_launcher.html#configuring-external-builders-and-launchers) in the Fabric documentation.

docs/getting-started/demo.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Download the sample Kubernetes test network (fabric-samples isn't tagged so we'l
1919
export FABRIC_SAMPLES_COMMIT=1058f9ffe16add583d1a11342deb5a9df3e5b72c
2020
curl -sSL "https://github.com/hyperledger/fabric-samples/archive/${FABRIC_SAMPLES_COMMIT}.tar.gz" | \
2121
tar -xzf - --strip-components=1 \
22-
fabric-samples-${FABRIC_SAMPLES_COMMIT}/test-network-k8s \
23-
fabric-samples-${FABRIC_SAMPLES_COMMIT}/asset-transfer-basic/chaincode-java
22+
fabric-samples-${FABRIC_SAMPLES_COMMIT}/test-network-k8s
2423
```
2524

2625
## Configure the Kubernetes test network
@@ -59,10 +58,10 @@ You can query the chaincode metadata to confirm that the sample was deployed suc
5958
./network chaincode query sample-contract '{"Args":["org.hyperledger.fabric:GetMetadata"]}'
6059
```
6160

62-
Use the `kubectl` command to inspect chaincode pods.
61+
Use the `kubectl` command to inspect chaincode jobs.
6362

6463
```shell
65-
kubectl -n test-network describe pods -l app.kubernetes.io/created-by=fabric-builder-k8s
64+
kubectl -n test-network describe jobs -l app.kubernetes.io/created-by=fabric-builder-k8s
6665
```
6766

6867
## Running transactions

docs/getting-started/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Prebuilt binaries are available to download from the [releases page](https://git
1616

1717
To install from source in `/opt/hyperledger/k8s_builder`, use the `go install` command.
1818

19-
```
19+
```shell
2020
mkdir -p /opt/hyperledger/k8s_builder/bin
2121
cd /opt/hyperledger/k8s_builder/bin
2222
GOBIN="${PWD}" go install github.com/hyperledger-labs/fabric-builder-k8s/cmd/[email protected]

docs/tutorials/bevel-operator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ kubectl hlf chaincode install --path=./go-contract-v0.7.2.tgz \
126126

127127
Get the chaincode's PACKAGE_ID
128128

129-
```
129+
```shell
130130
export PACKAGE_ID=$(kubectl hlf chaincode calculatepackageid --path=./go-contract-v0.7.2.tgz --language=golang --label=$CHAINCODE_LABEL) && echo $PACKAGE_ID
131131
```
132132

docs/tutorials/package-chaincode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ IMAGEJSON-EOF
1515
The k8s builder uses digests because these are immutable, unlike tags.
1616
The docker inspect command can be used to find the digest if required.
1717

18-
```
18+
```shell
1919
docker pull ghcr.io/hyperledger-labs/go-contract:v0.7.2
2020
docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/hyperledger-labs/go-contract:v0.7.2 | cut -d'@' -f2
2121
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ nav:
101101
- Chaincode builder: concepts/chaincode-builder.md
102102
- Chaincode image: concepts/chaincode-image.md
103103
- Chaincode package: concepts/chaincode-package.md
104+
- Chaincode job: concepts/chaincode-job.md
104105
- Configuring:
105106
- Configuration overview: configuring/overview.md
106107
- Kubernetes permissions: configuring/kubernetes-permissions.md

0 commit comments

Comments
 (0)