diff --git a/test-network-k8s/network b/test-network-k8s/network index 08df4c98..447f2d48 100755 --- a/test-network-k8s/network +++ b/test-network-k8s/network @@ -42,6 +42,33 @@ TLSADMIN_AUTH=tlsadmin:tlsadminpw RCAADMIN_AUTH=rcaadmin:rcaadminpw function print_help() { + log + log "--- Fabric Information" + log "Fabric Version is \t ${FABRIC_VERSION}" + log "Fabric CA Version is \t ${FABRIC_CA_VERSION}" + log "Container Registry is \t ${FABRIC_CONTAINER_REGISTRY}" + log "Network name is \t ${NETWORK_NAME}" + log "Channel name is \t ${CHANNEL_NAME}" + log + log "--- Targetted Chaincode Information" + log "Chaincode name is \t ${CHAINCODE_NAME}" + log "Chaincode image is \t ${CHAINCODE_IMAGE}" + log "Chaincode lavel is \t ${CHAINCODE_LABEL}" + log + log "--- Cluster Information" + log "Cluster name is \t ${CLUSTER_NAME}" + log "Cluster namespace is \t ${NS}" + log "Local Registry is \t ${LOCAL_REGISTRY_NAME}" + log "Local Registry port is \t ${LOCAL_REGISTRY_PORT}" + log "nginx http port is \t ${NGINX_HTTP_PORT}" + log "nginx https port is \t ${NGINX_HTTP2_PORT}" + log + log "--- Script Information" + log "Log file written to \t ${LOG_FILE}" + log "Debug log written to \t ${DEBUG_FILE}" + log + + echo todo: help output, parse mode, flags, env, etc. } @@ -59,6 +86,9 @@ function print_help() { # check for kind, kubectl, etc. check_prereqs +# Initialize the logging system - control output to 'network.log' and everything else to 'network-debug.log' +logging_init + ## Parse mode if [[ $# -lt 1 ]] ; then print_help @@ -68,8 +98,7 @@ else shift fi -# Initialize the logging system - control output to 'network.log' and everything else to 'network-debug.log' -logging_init + if [ "${MODE}" == "kind" ]; then log "Initializing KIND cluster \"${CLUSTER_NAME}\":" @@ -148,7 +177,7 @@ elif [ "${MODE}" == "rest-easy" ]; then elif [ "${MODE}" == "application" ]; then log "Getting application connection information:" application_connection - log "🏁 - Output in...xxx" + log "🏁 - Application connection information ready." else print_help diff --git a/test-network-k8s/scripts/application_connection.sh b/test-network-k8s/scripts/application_connection.sh index 3f73dd20..9563b128 100755 --- a/test-network-k8s/scripts/application_connection.sh +++ b/test-network-k8s/scripts/application_connection.sh @@ -57,7 +57,11 @@ function construct_application_configmap() { ca_pem=build/msp/organizations/peerOrganizations/org2.example.com/msp/cacerts/org2-ecert-ca.pem echo "$(json_ccp 2 $peer_pem $ca_pem)" > build/application/gateways/org2_ccp.json - + + pop_fn + + push_fn "Getting Application Identities" + local cert=build/msp/organizations/peerOrganizations/org1.example.com/users/Admin\@org1.example.com/msp/signcerts/cert.pem local pk=build/msp/organizations/peerOrganizations/org1.example.com/users/Admin\@org1.example.com/msp/keystore/server.key @@ -68,14 +72,24 @@ function construct_application_configmap() { echo "$(app_id Org2MSP $cert $pk)" > build/application/wallet/appuser_org2.id - kubectl -n $NS delete configmap app-fabric-tls-v1-map || log "app-fabric-tls-v1-map not present" + pop_fn + + push_fn "Creating ConfigMap \"app-fabric-tls-v1-map\" with TLS certificates for the application" + kubectl -n $NS delete configmap app-fabric-tls-v1-map || true kubectl -n $NS create configmap app-fabric-tls-v1-map --from-file=./build/msp/organizations/peerOrganizations/org1.example.com/msp/tlscacerts + pop_fn - kubectl -n $NS delete configmap app-fabric-ids-v1-map || log "app-fabric-id-v1-map not present" + push_fn "Creating ConfigMap \"app-fabric-ids-v1-map\" with identities for the application" + kubectl -n $NS delete configmap app-fabric-ids-v1-map || true kubectl -n $NS create configmap app-fabric-ids-v1-map --from-file=./build/application/wallet + pop_fn - kubectl -n $NS delete configmap app-fabric-ccp-v1-map || log "app-fabric-id-v1-map not present" + push_fn "Creating ConfigMap \"app-fabric-ccp-v1-map\" with ConnectionProfile for the application" + kubectl -n $NS delete configmap app-fabric-ccp-v1-map || true kubectl -n $NS create configmap app-fabric-ccp-v1-map --from-file=./build/application/gateways + pop_fn + + push_fn "Creating ConfigMap \"app-fabric-org1-v1-map\" with Organization 1 information for the application" cat < build/app-fabric-org1-v1-map.yaml apiVersion: v1 @@ -104,11 +118,16 @@ function application_connection() { construct_application_configmap - log "" +log + log "For k8s applications:" log "Config Maps created for the application" log "To deploy your application updated the image name and issue these commands" log "" log "kubectl -n $NS apply -f kube/application-deployment.yaml" log "kubectl -n $NS rollout status deploy/application-deployment" - + log + log "For non-k8s applications:" + log "ConnectionPrfiles are in ${PWD}/build/application/gateways" + log "Identities are in ${PWD}/build/application/wallets" + log } \ No newline at end of file diff --git a/test-network-k8s/scripts/utils.sh b/test-network-k8s/scripts/utils.sh index a1631aa4..b00802e3 100644 --- a/test-network-k8s/scripts/utils.sh +++ b/test-network-k8s/scripts/utils.sh @@ -17,6 +17,10 @@ function logging_init() { # Send stdout and stderr from child programs to the debug log file exec 1>>${DEBUG_FILE} 2>>${DEBUG_FILE} + + # There can be a race between the tail starting and the next log statement + # write nothing to the file to kill a (very small) bit of time + echo -ne >>${LOG_FILE} } function exit_fn() {