Addresses Issue #548 by providing a simple guide for running Java chaincode as a service with a local debugger.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
This commit is contained in:
Josh Kneubuhl 2022-03-17 18:09:42 -04:00
parent bb57b3cf8f
commit f0808196c8
21 changed files with 735 additions and 346 deletions

View file

@ -0,0 +1,2 @@
.idea/
.gradle/

View file

@ -0,0 +1,164 @@
## Basic asset transfer
This project demonstrates the use of the Java SDK, running a basic asset transfer contract using the "chaincode as a service"
pattern.
## Setup
In this sample we will employ the [Kubernetes Test Network](../../test-network-k8s) to illustrate a scenario of
building, running, and debugging chaincode on a development workstation.
This project is also compatible with the legacy chaincode builder pipeline and the compose based test-network.
For additional details, see the [End-to-end with the test-network](../../test-network/CHAINCODE_AS_A_SERVICE_TUTORIAL.md#end-to-end-with-the-the-test-network)
documentation.
## [Quickstart](../../test-network-k8s#quickstart)
```shell
export PATH=${PWD}/../../test-network-k8s:$PATH
network kind
network up
network channel create
```
```shell
network chaincode deploy ${PWD}
network chaincode invoke asset-transfer-basic '{"Args":["InitLedger"]}'
network chaincode query asset-transfer-basic '{"Args":["ReadAsset","asset1"]}' | jq
```
## Detailed Guide
```shell
network down
network up
network channel create
```
```shell
# Build the chaincode docker image
docker build -t hyperledger/fabric-samples/asset-transfer-basic/chaincode-java .
# Load the docker image directly to the KIND control plane.
# (Alternately, build/tag/push the image to a remote container registry, e.g. localhost:5000)
kind load docker-image hyperledger/fabric-samples/asset-transfer-basic/chaincode-java
```
```shell
# Assemble the chaincode package archive
network chaincode package $PWD/ccpackage/ $PWD/build/asset-transfer.tgz
# Determine the ID for the chaincode package
CORE_CHAINCODE_ID_NAME=$(network chaincode id $PWD/build/asset-transfer.tgz)
# Launch the chaincode in k8s as Deployment + Service
network chaincode launch $PWD/build/asset-transfer.tgz
# Complete the chaincode lifecycle
network chaincode install $PWD/build/asset-transfer.tgz
network chaincode approve asset-transfer-basic $CORE_CHAINCODE_ID_NAME
network chaincode commit asset-transfer-basic
```
```shell
# execute the smart contract by name
network chaincode invoke asset-transfer-basic '{"Args":["InitLedger"]}'
network chaincode query asset-transfer-basic '{"Args":["ReadAsset","asset1"]}'
```
```shell
kubectl -n test-network logs -f deployment/org1peer1-cc-asset-transfer-basic
```
## Debugging
### Build
```shell
./gradlew shadowJar
```
or
```shell
docker build -t fabric-samples/asset-transfer-basic/chaincode-java .
```
### Package
By instructing the peer to connect to chaincode at the Docker host alias `host.docker.internal`, pods running in
Kubernetes will access the local process via a special loopback interface established by KIND.
Set the "address" attribute in the project's [ccpackage/connection.json](ccpackage/connection.json) descriptor and assemble the chaincode package:
```json
{
"address": "host.docker.internal:9999",
}
```
```shell
network chaincode package $PWD/ccpackage/ $PWD/build/asset-transfer-debug.tgz
```
### Launch
When chaincode is launched locally, it must declare the package ID in the enviroment as if the process had been managed
by the peer's chaincode lifecycle manager. Calculate the package ID and start the chaincode, binding to port 9999
on the local system:
```shell
export CHAINCODE_SERVER_ADDRESS=0.0.0.0:9999
export CORE_CHAINCODE_ID_NAME=$(network chaincode id $PWD/build/asset-transfer-debug.tgz)
java -jar build/libs/chaincode.jar
```
Or using the editor/debugger/IDE of your choice, create a launch target for `ContractMain.main()`, specifying the
environment as above.
Or launch the chaincode in a Docker container, binding to port 9999 on the host system:
```shell
docker run \
--rm \
--name basic_1.0 \
-p 9999:9999 \
-e CHAINCODE_SERVER_ADDRESS \
-e CORE_CHAINCODE_ID_NAME \
fabric-samples/asset-transfer-basic/chaincode-java
```
### Approve, Invoke, and Query
After the contract main has launched, install, approve, commit, and invoke the chaincode:
```shell
# Complete the chaincode lifecycle
export CORE_CHAINCODE_ID_NAME=$(network chaincode id $PWD/build/asset-transfer-debug.tgz)
network chaincode install $PWD/build/asset-transfer-debug.tgz
network chaincode approve asset-transfer-debug $CORE_CHAINCODE_ID_NAME
network chaincode commit asset-transfer-debug
```
```shell
# execute the smart contract by name
network chaincode invoke asset-transfer-debug '{"Args":["InitLedger"]}'
network chaincode query asset-transfer-debug '{"Args":["ReadAsset","asset1"]}'
```
## Tear Down
```shell
network down
```
or
```shell
network unkind
```

View file

@ -0,0 +1,49 @@
# Scratch notes - Ignore - ... `fabric-cli` redux
`fabric [options] peer <group> <command> [parameters]`
```
fabric => network
peer => implicit (from env/context)
channel => implicit (from env/context)
group => chaincode
[params] => --param=value or NETWORK_$GROUP_$COMMAND_$PARAM=value from env
```
```shell
network chaincode package <folder-path> <bundle-path>
network chaincode id <bundle-path>
network chaincode install <bundle-path>
network chaincode approve <name> <id>
network chainocde commit <name>
```
```shell
network chaincode list
network chaincode delete <name>
network chaincode describe <name>
network chaincode invoke <name> <payload>
network chaincode query <name> <payload>
```
meta / fictitious targets:
```
network chaincode launch <name> <CC_IMAGE>
network chaincode deploy <name> <folder-path> # package, install, LAUNCH, approve, commit
```
ordinal position args vs. named parameters vs. env overrides
```shell
network chaincode package asset-transfer my-chaincode.tar.gz
network cc package --name=asset-transfer (or NETWORK_CHAINCODE_PACKAGE_NAME=asset-transfer)
network cc package --name= (or NETWORK_${GROUP}_${COMMAND}_${PARAM}=<value>)
```

View file

@ -0,0 +1,4 @@
{
"name": "asset-transfer-basic",
"image": "hyperledger/fabric-samples/asset-transfer-basic/chaincode-java:latest"
}

View file

@ -0,0 +1,5 @@
{
"address": "{{.peername}}-cc-asset-transfer-basic:9999",
"dial_timeout": "10s",
"tls_required": false
}

View file

@ -0,0 +1,4 @@
{
"type": "ccaas",
"label": "basic_1.0"
}

View file

@ -7,10 +7,10 @@ set -euo pipefail
: ${DEBUG:="false"}
if [ "${DEBUG,,}" = "true" ]; then
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000 -jar /chaincode.jar
exec java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000 -jar /chaincode.jar
elif [ "${CORE_PEER_TLS_ENABLED,,}" = "true" ]; then
java -jar /chaincode.jar # todo
exec java -jar /chaincode.jar # todo
else
java -jar /chaincode.jar
exec java -jar /chaincode.jar
fi

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,78 +17,113 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -105,84 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View file

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View file

@ -0,0 +1,23 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.samples.assettransfer;
import org.hyperledger.fabric.contract.ContractRouter;
public final class ContractMain {
private ContractMain() {
}
public static void main(final String[] args) throws Exception {
if (!System.getenv().containsKey("CHAINCODE_SERVER_ADDRESS")) {
throw new IllegalArgumentException("Missing required 'CHAINCODE_SERVER_ADDRESS' parameter from env");
} else if (!System.getenv().containsKey("CORE_CHAINCODE_ID_NAME")) {
throw new IllegalArgumentException("Missing required 'CORE_CHAINCODE_ID_NAME' parameter from env");
}
ContractRouter.main(args);
}
}

View file

@ -130,12 +130,12 @@ jobs:
displayName: Run Test Network Basic Chaincode
- job: KubeTestNetworkBasic
displayName: Kube Test Network Basic
displayName: Kube Test Network
pool:
vmImage: ubuntu-20.04
strategy:
matrix:
Docker-Typescript:
Typescript:
CLIENT_LANGUAGE: typescript
steps:
- template: templates/install-k8s-deps.yml

View file

@ -19,9 +19,10 @@ export TEST_NETWORK_FABRIC_CA_VERSION=amd64-${FABRIC_VERSION}-stable
# test-network-k8s parameters
export TEST_TAG=$(git describe)
export TEST_NETWORK_KIND_CLUSTER_NAME=${TEST_NETWORK_KIND_CLUSTER_NAME:-kind}
# asset-transfer-basic chaincode target
export TEST_NETWORK_CHAINCODE_NAME=${TEST_NETWORK_CHAINCODE_NAME:-asset-transfer-basic}
export TEST_NETWORK_CHAINCODE_IMAGE=${TEST_NETWORK_CHAINCODE_NAME}:${TEST_TAG}
export TEST_NETWORK_CHAINCODE_PATH=${TEST_NETWORK_CHAINCODE_PATH:-../asset-transfer-basic/chaincode-external}
export TEST_NETWORK_CHAINCODE_PATH=${TEST_NETWORK_CHAINCODE_PATH:-$PWD/../asset-transfer-basic/chaincode-java}
# gateway client application parameters
export GATEWAY_CLIENT_APPLICATION_PATH=${GATEWAY_CLIENT_APPLICATION_PATH:-../asset-transfer-basic/application-gateway-${CLIENT_LANGUAGE}}
@ -44,12 +45,10 @@ function print() {
function touteSuite() {
createCluster
buildChaincodeImage
}
function quitterLaScene() {
destroyCluster
scrubCCImages
}
function createCluster() {
@ -62,19 +61,6 @@ function destroyCluster() {
./network unkind
}
function buildChaincodeImage() {
print "Building chaincode image $TEST_NETWORK_CHAINCODE_IMAGE"
${CONTAINER_CLI} build -t $TEST_NETWORK_CHAINCODE_IMAGE $TEST_NETWORK_CHAINCODE_PATH
# todo: work with local reg, or k3s, or KIND, or ...
kind load docker-image $TEST_NETWORK_CHAINCODE_IMAGE
}
function scrubCCImages() {
print "Scrubbing chaincode images"
${CONTAINER_CLI} rmi $TEST_NETWORK_CHAINCODE_IMAGE
}
function createNetwork() {
print "Launching network"
./network up
@ -84,7 +70,7 @@ function createNetwork() {
kubectl -n test-network port-forward svc/org1-peer1 7051:7051 &
print "Deploying chaincode"
./network chaincode deploy
./network chaincode deploy $TEST_NETWORK_CHAINCODE_PATH
print "Extracting certificates"
kubectl \
@ -109,13 +95,12 @@ function stopNetwork() {
touteSuite
trap "quitterLaScene" EXIT
# invoke / query
createNetwork
print "Inserting and querying assets"
( ./network chaincode invoke '{"Args":["InitLedger"]}' \
( ./network chaincode invoke $CHAINCODE_NAME '{"Args":["InitLedger"]}' \
&& sleep 5 \
&& ./network chaincode query '{"Args":["ReadAsset","asset1"]}' )
&& ./network chaincode query $CHAINCODE_NAME '{"Args":["ReadAsset","asset1"]}' )
print "OK"
print "Running rest-easy test"

View file

@ -33,17 +33,18 @@ Launch the network, create a channel, and deploy the [basic-asset-transfer](../a
```shell
./network up
./network channel create
./network chaincode deploy
./network chaincode deploy $PWD/../asset-transfer-basic/chaincode-java
```
Invoke and query chaincode:
```shell
./network chaincode invoke '{"Args":["CreateAsset","1","blue","35","tom","1000"]}'
./network chaincode query '{"Args":["ReadAsset","1"]}'
./network chaincode invoke asset-transfer-basic '{"Args":["CreateAsset","1","blue","35","tom","1000"]}'
./network chaincode query asset-transfer-basic '{"Args":["ReadAsset","1"]}'
```
Access the blockchain with a [REST API](https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-basic/rest-api-typescript):
```
```shell
./network rest-easy
```
@ -60,7 +61,7 @@ Tear down the cluster:
## [Detailed Guides](docs/README.md)
- [`./network`](docs/NETWORK.md)
- [`network`](docs/NETWORK.md)
- [Working with Kubernetes](docs/KUBERNETES.md)
- [Certificate Authorities](docs/CA.md)
- [Launching the Test Network](docs/TEST_NETWORK.md)

View file

@ -1,4 +1,4 @@
{
"type": "external",
"type": "ccaas",
"label": "basic_1.0"
}
}

View file

@ -21,12 +21,13 @@ spec:
containers:
- name: main
image: {{CHAINCODE_IMAGE}}
imagePullPolicy: IfNotPresent
env:
- name: CHAINCODE_SERVER_ADDRESS
value: 0.0.0.0:9999
# todo: load with an envFrom and a dynamic config map with the ID.
- name: CHAINCODE_ID
- name: CORE_CHAINCODE_ID_NAME
value: {{CHAINCODE_ID}}
ports:
- containerPort: 9999

View file

@ -9,16 +9,17 @@ set -o errexit
# todo: better handling for input parameters.
# todo: skip storage volume init if deploying to a remote / cloud cluster (ICP IKS ROKS etc...)
# todo: for logging, set up a stack and allow multi-line status output codes
# todo: refactor - lots of for-org-in-0-to-2-...
# todo: find a better technique for passing input commands to a remote kube exec
# todo: register tls csr.hosts w/ kube DNS domain .NS.svc.cluster.local
# todo: user:pass auth for tls and ecert bootstrap admins. here and in the server-config.yaml
# todo: set tls.certfiles= ... arg in deployment env / yaml
# todo: refactor chaincode install to support other chaincode routines
# todo: consider using templates for boilerplate network nodes (orderers, peers, ...)
# todo: allow the user to specify the chaincode name (hardcoded as 'basic') both in install and invoke/query
# todo: track down a nasty bug whereby the CA service endpoints (kube services) will occasionally reject TCP connections after network down/up. This is patched by introducing a 10s sleep after the deployments are up...
# todo: refactor query/invoke to specify chaincode name (-n param)
# todo: allow relative paths for input arguments.
cd "$(dirname "$0")"
CONTAINER_CLI=${CONTAINER_CLI:-docker}
FABRIC_VERSION=${TEST_NETWORK_FABRIC_VERSION:-2.4}
@ -35,15 +36,15 @@ LOCAL_REGISTRY_PORT=${TEST_NETWORK_LOCAL_REGISTRY_PORT:-5000}
STAGE_DOCKER_IMAGES=${TEST_NETWORK_STAGE_DOCKER_IMAGES:-false}
NGINX_HTTP_PORT=${TEST_NETWORK_INGRESS_HTTP_PORT:-80}
NGINX_HTTPS_PORT=${TEST_NETWORK_INGRESS_HTTPS_PORT:-443}
CHAINCODE_NAME=${TEST_NETWORK_CHAINCODE_NAME:-asset-transfer-basic}
CHAINCODE_IMAGE=${TEST_NETWORK_CHAINCODE_IMAGE:-ghcr.io/hyperledgendary/fabric-ccaas-asset-transfer-basic:latest}
CHAINCODE_LABEL=${TEST_NETWORK_CHAINCODE_LABEL:-basic_1.0}
# todo: more complicated config, as these bleed into the yaml descriptors (sed? kustomize? helm (no)? tkn? ansible?...) or other script locations
TLSADMIN_AUTH=tlsadmin:tlsadminpw
RCAADMIN_AUTH=rcaadmin:rcaadminpw
function print_help() {
set +x
log
log "--- Fabric Information"
log "Fabric Version \t\t: ${FABRIC_VERSION}"
@ -52,11 +53,6 @@ function print_help() {
log "Network name \t\t: ${NETWORK_NAME}"
log "Channel name \t\t: ${CHANNEL_NAME}"
log
log "--- Chaincode Information"
log "Chaincode name \t\t: ${CHAINCODE_NAME}"
log "Chaincode image \t: ${CHAINCODE_IMAGE}"
log "Chaincode label \t: ${CHAINCODE_LABEL}"
log
log "--- Cluster Information"
log "Cluster name \t\t: ${CLUSTER_NAME}"
log "Cluster namespace \t: ${NS}"
@ -71,8 +67,6 @@ function print_help() {
log "Debug log file \t\t: ${DEBUG_FILE}"
log
echo todo: help output, parse mode, flags, env, etc.
}
@ -102,8 +96,6 @@ else
shift
fi
if [ "${MODE}" == "kind" ]; then
log "Initializing KIND cluster \"${CLUSTER_NAME}\":"
kind_init
@ -130,10 +122,10 @@ elif [ "${MODE}" == "down" ]; then
log "🏁 - Fabric network is down."
elif [ "${MODE}" == "channel" ]; then
ACTION=$1
COMMAND=$1
shift
if [ "${ACTION}" == "create" ]; then
if [ "${COMMAND}" == "create" ]; then
log "Creating channel \"${CHANNEL_NAME}\":"
channel_up
log "🏁 - Channel is ready."
@ -143,37 +135,41 @@ elif [ "${MODE}" == "channel" ]; then
exit 1
fi
elif [ "${MODE}" == "chaincode" ]; then
ACTION=$1
shift
elif [[ "${MODE}" == "chaincode" || "${MODE}" == "cc" ]]; then
cc_command_group $@
if [ "${ACTION}" == "deploy" ]; then
log "Deploying chaincode \"${CHAINCODE_NAME}\":"
deploy_chaincode
log "🏁 - Chaincode is ready."
elif [ "${ACTION}" == "install" ]; then
log "Installing chaincode \"${CHAINCODE_NAME}\":"
install_chaincode
log "🏁 - Chaincode is installed with CHAINCODE_ID=${CHAINCODE_ID}"
elif [ "${ACTION}" == "activate" ]; then
log "Activating chaincode \"${CHAINCODE_NAME}\":"
activate_chaincode
log "🏁 - Chaincode is activated with CHAINCODE_ID=${CHAINCODE_ID}"
elif [ "${ACTION}" == "invoke" ]; then
invoke_chaincode $@ 2>> ${LOG_FILE}
elif [ "${ACTION}" == "query" ]; then
query_chaincode $@ >> ${LOG_FILE}
elif [ "${ACTION}" == "metadata" ]; then
query_chaincode_metadata >> ${LOG_FILE}
else
print_help
exit 1
fi
#elif [ "${MODE}" == "chaincode" ]; then
# COMMAND=$1
# shift
#
# if [ "${COMMAND}" == "deploy" ]; then
# log "Deploying chaincode \"${CHAINCODE_NAME}\":"
# deploy_chaincode
# log "🏁 - Chaincode is ready."
#
# elif [ "${COMMAND}" == "install" ]; then
# log "Installing chaincode \"${CHAINCODE_NAME}\":"
# install_chaincode
# log "🏁 - Chaincode is installed with CHAINCODE_ID=${CHAINCODE_ID}"
#
# elif [ "${COMMAND}" == "activate" ]; then
# log "Activating chaincode \"${CHAINCODE_NAME}\":"
# activate_chaincode
# log "🏁 - Chaincode is activated with CHAINCODE_ID=${CHAINCODE_ID}"
#
# elif [ "${COMMAND}" == "invoke" ]; then
# invoke_chaincode $@ 2>> ${LOG_FILE}
#
# elif [ "${COMMAND}" == "query" ]; then
# query_chaincode $@ >> ${LOG_FILE}
#
# elif [ "${COMMAND}" == "metadata" ]; then
# query_chaincode_metadata >> ${LOG_FILE}
#
# else
# print_help
# exit 1
# fi
elif [ "${MODE}" == "anchor" ]; then
update_anchor_peers $@

View file

@ -5,16 +5,99 @@
# SPDX-License-Identifier: Apache-2.0
#
function package_chaincode_for() {
local org=$1
local cc_folder="chaincode/${CHAINCODE_NAME}"
local build_folder="build/chaincode"
local cc_archive="${build_folder}/${CHAINCODE_NAME}.tgz"
push_fn "Packaging chaincode folder ${cc_folder}"
# Convenience routine to "do everything" required to bring up a sample CC.
function deploy_chaincode() {
local cc_folder=$1
local build_folder=${cc_folder}/build
local cc_package=${build_folder}/chaincode.tgz
build_chaincode_image ${cc_folder}
mkdir -p ${build_folder}
tar -C ${cc_folder} -zcf ${cc_folder}/code.tar.gz connection.json
package_chaincode ${cc_folder}/ccpackage ${cc_package}
extract_chaincode_image ${cc_package}
extract_chaincode_name ${cc_package}
launch_chaincode ${cc_package}
install_chaincode ${cc_package}
approve_chaincode ${CHAINCODE_NAME} ${CHAINCODE_ID}
commit_chaincode ${CHAINCODE_NAME}
}
function query_chaincode() {
local cc_name=$1
shift
set -x
# todo: mangle additional $@ parameters with bash escape quotations
echo '
export CORE_PEER_ADDRESS=org1-peer1:7051
peer chaincode query -n '${cc_name}' -C '${CHANNEL_NAME}' -c '"'$@'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
}
function query_chaincode_metadata() {
local cc_name=$1
shift
set -x
local args='{"Args":["org.hyperledger.fabric:GetMetadata"]}'
# todo: mangle additional $@ parameters with bash escape quotations
log 'Org1-Peer1:'
echo '
export CORE_PEER_ADDRESS=org1-peer1:7051
peer chaincode query -n '${cc_name}' -C '${CHANNEL_NAME}' -c '"'$args'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
log ''
log 'Org1-Peer2:'
echo '
export CORE_PEER_ADDRESS=org1-peer2:7051
peer chaincode query -n '${cc_name}' -C '${CHANNEL_NAME}' -c '"'$args'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
}
function invoke_chaincode() {
local cc_name=$1
shift
# set -x
# todo: mangle additional $@ parameters with bash escape quotations
echo '
export CORE_PEER_ADDRESS=org1-peer1:7051
peer chaincode \
invoke \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem \
-n '${cc_name}' \
-C '${CHANNEL_NAME}' \
-c '"'$@'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
sleep 2
}
function build_chaincode_image() {
local cc_folder=$1
local cc_image=$(jq -r .image ${cc_folder}/ccpackage/ccaas.json)
push_fn "Building chaincode image ${cc_image}"
docker build -t ${cc_image} ${cc_folder}
kind load docker-image ${cc_image}
pop_fn
}
function package_chaincode() {
local cc_folder=$1
local cc_archive=$2
local archive_name=$(basename $cc_archive)
push_fn "Packaging chaincode ${archive_name}"
tar -C ${cc_folder} -zcf ${cc_folder}/code.tar.gz connection.json ccaas.json
tar -C ${cc_folder} -zcf ${cc_archive} code.tar.gz metadata.json
rm ${cc_folder}/code.tar.gz
@ -22,32 +105,6 @@ function package_chaincode_for() {
pop_fn
}
# Copy the chaincode archive from the local host to the org admin
function transfer_chaincode_archive_for() {
local org=$1
local cc_archive="build/chaincode/${CHAINCODE_NAME}.tgz"
push_fn "Transferring chaincode archive to ${org}"
# Like kubectl cp, but targeted to a deployment rather than an individual pod.
tar cf - ${cc_archive} | kubectl -n $NS exec -i deploy/${org}-admin-cli -c main -- tar xvf -
pop_fn
}
function install_chaincode_for() {
local org=$1
local peer=$2
push_fn "Installing chaincode for org ${org} peer ${peer}"
# Install the chaincode
echo 'set -x
export CORE_PEER_ADDRESS='${org}'-'${peer}':7051
peer lifecycle chaincode install build/chaincode/'${CHAINCODE_NAME}'.tgz
' | exec kubectl -n $NS exec deploy/${org}-admin-cli -c main -i -- /bin/bash
pop_fn
}
function launch_chaincode_service() {
local org=$1
local cc_id=$2
@ -70,120 +127,177 @@ function launch_chaincode_service() {
pop_fn
}
function activate_chaincode_for() {
# Copy the chaincode archive from the local host to the org admin
function transfer_chaincode_archive_for() {
local org=$1
local cc_id=$2
push_fn "Activating chaincode ${CHAINCODE_ID}"
local cc_archive=$2
local dirname=$(dirname $cc_archive)
local filename=$(basename $cc_archive)
echo 'set -x
export CORE_PEER_ADDRESS='${org}'-peer1:7051
peer lifecycle \
chaincode approveformyorg \
--channelID '${CHANNEL_NAME}' \
--name '${CHAINCODE_NAME}' \
--version 1 \
--package-id '${cc_id}' \
--sequence 1 \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem
peer lifecycle \
chaincode commit \
--channelID '${CHANNEL_NAME}' \
--name '${CHAINCODE_NAME}' \
--version 1 \
--sequence 1 \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem
push_fn "Transferring chaincode archive to ${org}"
# Like kubectl cp, but targeted to a deployment rather than an individual pod.
tar cf - -C ${dirname} ${filename} | kubectl -n $NS exec -i deploy/${org}-admin-cli -c main -- tar xvf -
pop_fn
}
function install_chaincode_for() {
local org=$1
local package_name=$2
local peer=$3
push_fn "Installing chaincode for ${org} ${peer}"
# Install the chaincode
echo 'set -x
export CORE_PEER_ADDRESS='${org}'-'${peer}':7051
peer lifecycle chaincode install '${package_name}'
' | exec kubectl -n $NS exec deploy/${org}-admin-cli -c main -i -- /bin/bash
pop_fn
}
function query_chaincode() {
set -x
# todo: mangle additional $@ parameters with bash escape quotations
echo '
export CORE_PEER_ADDRESS=org1-peer1:7051
peer chaincode query -n '${CHAINCODE_NAME}' -C '${CHANNEL_NAME}' -c '"'$@'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
}
function query_chaincode_metadata() {
set -x
local args='{"Args":["org.hyperledger.fabric:GetMetadata"]}'
# todo: mangle additional $@ parameters with bash escape quotations
log 'Org1-Peer1:'
echo '
export CORE_PEER_ADDRESS=org1-peer1:7051
peer chaincode query -n '${CHAINCODE_NAME}' -C '${CHANNEL_NAME}' -c '"'$args'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
log ''
log 'Org1-Peer2:'
echo '
export CORE_PEER_ADDRESS=org1-peer2:7051
peer chaincode query -n '${CHAINCODE_NAME}' -C '${CHANNEL_NAME}' -c '"'$args'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
}
function invoke_chaincode() {
# set -x
# todo: mangle additional $@ parameters with bash escape quotations
echo '
export CORE_PEER_ADDRESS=org1-peer1:7051
peer chaincode \
invoke \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem \
-n '${CHAINCODE_NAME}' \
-C '${CHANNEL_NAME}' \
-c '"'$@'"'
' | exec kubectl -n $NS exec deploy/org1-admin-cli -c main -i -- /bin/bash
sleep 2
}
# Normally the chaincode ID is emitted by the peer install command. In this case, we'll generate the
# package ID as the sha-256 checksum of the chaincode archive.
function set_chaincode_id() {
local cc_package=build/chaincode/${CHAINCODE_NAME}.tgz
cc_sha256=$(shasum -a 256 ${cc_package} | tr -s ' ' | cut -d ' ' -f 1)
label=$( jq -r '.label' chaincode/${CHAINCODE_NAME}/metadata.json)
CHAINCODE_ID=${label}:${cc_sha256}
}
# Package and install the chaincode, but do not activate.
# Install the chaincode package to an org peer
function install_chaincode() {
local org=org1
local cc_package=$1
local package_name=$(basename $cc_package)
package_chaincode_for ${org}
transfer_chaincode_archive_for ${org}
install_chaincode_for ${org} peer1
install_chaincode_for ${org} peer2
set_chaincode_id
transfer_chaincode_archive_for ${org} ${cc_package}
install_chaincode_for ${org} ${package_name} peer1
install_chaincode_for ${org} ${package_name} peer2
}
# Activate the installed chaincode but do not package/install a new archive.
function activate_chaincode() {
set -x
# approve the chaincode package for an org and assign a name
function approve_chaincode() {
local org=org1
local cc_name=$1
local cc_id=$2
push_fn "Approving chaincode ${cc_name} with ID ${cc_id}"
set_chaincode_id
activate_chaincode_for org1 $CHAINCODE_ID
echo 'set -x
export CORE_PEER_ADDRESS='${org}'-peer1:7051
peer lifecycle \
chaincode approveformyorg \
--channelID '${CHANNEL_NAME}' \
--name '${cc_name}' \
--version 1 \
--package-id '${cc_id}' \
--sequence 1 \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem
' | exec kubectl -n $NS exec deploy/${org}-admin-cli -c main -i -- /bin/bash
pop_fn
}
# Install, launch, and activate the chaincode
function deploy_chaincode() {
set -x
# commit the named chaincode for an org
function commit_chaincode() {
local org=org1
local cc_name=$1
push_fn "Committing chaincode ${cc_name}"
echo 'set -x
export CORE_PEER_ADDRESS='${org}'-peer1:7051
peer lifecycle \
chaincode commit \
--channelID '${CHANNEL_NAME}' \
--name '${cc_name}' \
--version 1 \
--sequence 1 \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem
' | exec kubectl -n $NS exec deploy/${org}-admin-cli -c main -i -- /bin/bash
pop_fn
}
# The chaincode docker image is stored in the code.tar.gz ccaas.json
function extract_chaincode_image() {
CHAINCODE_IMAGE=$(tar zxfO $1 code.tar.gz | tar zxfO - ccaas.json | jq -r .image)
}
function extract_chaincode_name() {
CHAINCODE_NAME=$(tar zxfO $1 code.tar.gz | tar zxfO - ccaas.json | jq -r .name)
}
function launch_chaincode() {
local cc_package=$1
id_chaincode ${cc_package}
extract_chaincode_image ${cc_package}
extract_chaincode_name ${cc_package}
install_chaincode
launch_chaincode_service org1 $CHAINCODE_ID $CHAINCODE_IMAGE peer1
launch_chaincode_service org1 $CHAINCODE_ID $CHAINCODE_IMAGE peer2
activate_chaincode
}
function id_chaincode() {
local cc_package=$1
cc_sha256=$(shasum -a 256 ${cc_package} | tr -s ' ' | cut -d ' ' -f 1)
cc_label=$(tar zxfO ${cc_package} metadata.json | jq -r '.label')
CHAINCODE_ID=${cc_label}:${cc_sha256}
}
# chaincode "group" commands. Like "main" for chaincode sub-command group.
function cc_command_group() {
#set -x
COMMAND=$1
shift
if [ "${COMMAND}" == "deploy" ]; then
log "Deploying chaincode"
deploy_chaincode $@
log "🏁 - Chaincode is ready."
elif [ "${COMMAND}" == "package" ]; then
log "Packaging chaincode"
package_chaincode $@
log "🏁 - Chaincode package is ready."
elif [ "${COMMAND}" == "id" ]; then
id_chaincode $@
log $CHAINCODE_ID
elif [ "${COMMAND}" == "launch" ]; then
log "Launching chaincode services"
launch_chaincode $@
log "🏁 - Chaincode services are ready"
elif [ "${COMMAND}" == "install" ]; then
log "Installing chaincode for org1"
install_chaincode $@
log "🏁 - Chaincode is installed"
elif [ "${COMMAND}" == "approve" ]; then
log "Approving chaincode for org1"
approve_chaincode $@
log "🏁 - Chaincode is approved"
elif [ "${COMMAND}" == "commit" ]; then
log "Committing chaincode for org1"
commit_chaincode $@
log "🏁 - Chaincode is committed"
elif [ "${COMMAND}" == "invoke" ]; then
invoke_chaincode $@ 2>> ${LOG_FILE}
elif [ "${COMMAND}" == "query" ]; then
query_chaincode $@ >> ${LOG_FILE}
elif [ "${COMMAND}" == "metadata" ]; then
query_chaincode_metadata $@ >> ${LOG_FILE}
# todo: maybe...
# elif [ "${COMMAND}" == "activate" ]; then
else
print_help
exit 1
fi
}

View file

@ -87,8 +87,8 @@ nodes:
- containerPort: 443
hostPort: ${ingress_https_port}
protocol: TCP
networking:
kubeProxyMode: "ipvs"
#networking:
# kubeProxyMode: "ipvs"
# create a cluster with the local registry enabled in containerd
containerdConfigPatches:
@ -98,6 +98,11 @@ containerdConfigPatches:
EOF
for node in $(kind get nodes);
do
docker exec "$node" sysctl net.ipv4.conf.all.route_localnet=1;
done
pop_fn
}
@ -162,4 +167,4 @@ function kind_init() {
function kind_unkind() {
kind_delete
}
}

View file

@ -24,6 +24,7 @@ function logging_init() {
function exit_fn() {
rc=$?
set +x
# Write an error icon to the current logging statement.
if [ "0" -ne $rc ]; then