Skip to content

Commit cb1f91d

Browse files
authored
Merge pull request #2 from corda/master
merge with main repo
2 parents b5b602e + 3f9cf1a commit cb1f91d

File tree

12 files changed

+243
-27
lines changed

12 files changed

+243
-27
lines changed

CHECKLIST.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Corda Kubernetes Depolyment checklist
2+
3+
Tested with:
4+
5+
- Corda Enterprise version 4.0
6+
7+
Pre-requisites:
8+
9+
- Clone the repository to any local folder
10+
- Installation requires the following tools:
11+
- Docker (tested with Docker 19.03.5, API 1.40, newer versions should be fine)
12+
- Kubectl (tested with kubectl v1.12.8, newer versions should be fine)
13+
- Helm (requires Helm version 2.x, tested with Helm v2.14.3, newer v2.x versions should be fine)
14+
- Azure CLI (tested with az cli 2.1.0, newer versions should be fine)
15+
16+
Azure Cloud Setup:
17+
18+
- Azure Setup
19+
- Azure Account connected to a subscription with permissions to create resources
20+
- Azure Kubernetes Service
21+
- Azure Container Registry
22+
- Azure Service Principals
23+
- Azure Storage Account, create three new File shares for each of the following:
24+
- node, named for example node-<name>-storage, where name would match the nodes x500 name to some degree and should match values.yaml files "fileShareName" parameter as well
25+
- bridge, named for example bridge-<name>-storage, where name would match the nodes x500 name to some degree and should match values.yaml files "fileShareName" parameter as well
26+
- float, named for example float-<name>-storage, where name would match the nodes x500 name to some degree and should match values.yaml files "fileShareName" parameter as well
27+
- Public IP Addresses in the "KubernetesPlayground-NodePool" resource group
28+
- Node, to enable RPC connections from GUI, named for example node-<name>-ip
29+
- Float, to enable inbound connections from other nodes on the network, named for example float-<name>-ip
30+
- Azure Config
31+
- az login, make sure at this point that if you have many subscriptions, that the one you want to use has isDefault=true, if not use "az account list" and "az account set -s <subscription id>" to fix it
32+
- az aks get-credentials --resource-group KubernetesPlayground --name KubernetesPlaygroundAKS # KubernetesPlayground is just an example name, use your own resource names
33+
- kubectl create namespace <name> # name could be for example firstname-lastname in lowercase, if you are deploying many instances in a test environment
34+
- kubectl config set-context --current --namespace <name>
35+
36+
AWS Cloud setup:
37+
38+
- Coming soon
39+
40+
Configuration:
41+
42+
- Deployment folder (repository folder)
43+
- Binaries, jar files (the name of the jars should match the configuration)
44+
- Docker-images/bin
45+
- Corda Enterprise jar (eg. corda-ent-4.0.jar)
46+
- Health-survey-tool jar (eg. corda-tools-healthsurvey-4.0.jar)
47+
- Corda Firewall jar (eg. corda-firewall-4.0.jar)
48+
- Pki-firewall/bin
49+
- Optional on windows: Copy Key tool jar + dll to bin folder (pki-firewall/bin)
50+
- Config
51+
- docker_config.sh
52+
- Define versions so that they match what is in the values.yaml file.
53+
- Values.yaml
54+
- Config containerRegistry section.
55+
- Config storage section.
56+
- Config fileShareName for node/bridge/float
57+
- Config identityManagerAddress and networkmapAddress (without http:// prefix)
58+
- You can use any network, but please note that if you want to use Testnet, we will have to skip the initial registration step and download the full Testnet node from the dashboard
59+
- Config resourceName to reflect the x500 name of the node, please note to use lowercase letters and numbers only
60+
- Config legalName to define the x500 name of the node
61+
- Download network root truststore to ./helm/files/network with the name "networkRootTrustStore.jks"
62+
- Configure matching truststorePassword to the truststore.
63+
- Execution
64+
- Run one-time-setup.sh once, which does the following:
65+
- Creates and pushes Docker images to the container registry
66+
- Generates certificates for the Corda Firewall TLS tunnel
67+
- Performs initial registration of the node
68+
- Copies the generates certificates for the next step, which is the deployment
69+
- Deploy using deploy.sh or helm/helm_compile.sh, which does the following:
70+
- Compiles the Helm charts from templates to Kubernetes resource definition files
71+
- Applies the generated Kubernetes resources definition files to the Kubernetes cluster
72+
- Three pods should be at status ‘Runningʼ for node, bridge and float after a while
73+
- Please have a look at the logs files for the three pods to make sure they are running without errors (kubectl get pods + kubectl logs -f <pod name>)
74+
- Run delete_all.sh to remove all resources from the Kubernetes cluster if you need to start fresh
75+
76+
Useful commands:
77+
78+
- Check deployment status with: kubectl get pods, expect to see 'Running' if the pods are working normally
79+
- Check logs of running components with : kubectl logs -f <pod>
80+
- Investigate Corda Node log by gaining a shell into the running pod with: (winpty on windows) kubectl exec -it <pod> bash, then cd to folder /opt/corda/workspace/logs and look at most recent node log file

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ It is strongly recommended you review all of the documentation there before sett
3131

3232
---
3333

34-
## BINARIES
35-
36-
This deployment is targeting an Enterprise deployment, which should include a Corda Node, but also the Corda Firewall, which is an Enterprise only feature.
37-
38-
In order to execute the following scripts correctly, you will have to have access to the Corda Enterprise binaries.
39-
The files should be downloaded first and placed in the following folder: ``docker-images/bin``
40-
41-
Please see [docker-images/README.md](docker-images/README.md) for more information.
42-
43-
---
44-
4534
## Azure cloud instructions
4635

4736
Setting up the relevant cloud services is currently left to the reader, this may change in future versions of the scripts.
@@ -91,7 +80,20 @@ A guide on setting up Public IP addresses in Azure: [Create, change, or delete a
9180

9281
#### BINARIES
9382

94-
The scripts contained within require you to have the necessary binaries in place, as previously mentioned in this document.
83+
This deployment is targeting an Enterprise deployment, which should include a Corda Node, but also the Corda Firewall, which is an Enterprise only feature.
84+
85+
In order to execute the following scripts correctly, you will have to have access to the Corda Enterprise binaries.
86+
The files should be downloaded first and placed in the following folder: ``docker-images/bin``
87+
88+
Please see [docker-images/README.md](docker-images/README.md) for more information.
89+
90+
#### SETUP CHECKLIST
91+
92+
Since there are a number of prerequisites that need to be met and then a certain order of running everything, a checklist has been collated that you may find useful.
93+
94+
Please see [CHECKLIST.md](CHECKLIST.md) for more information.
95+
96+
---
9597

9698
#### CONFIGURATION VALUES
9799

corda-pki-generator/copy_certs_to_helm_files.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ ensureFileExistsAndCopy () {
5656
TO=$2
5757
if [ -f "$FROM" ]
5858
then
59-
if [ ! -f "$TO" ]
59+
if [ -f "$TO" ]
6060
then
61+
echo "Existing certificate already existed, but it is safe to replace, since this is just the Corda Firewall tunnel keys."
62+
fi
6163
cp -f $FROM $TO
6264
else
63-
echo "Existing certificate already existed, skipping copying as a safe-guard: $TO"
64-
exit 1
65-
fi
66-
else
6765
echo "File did not exist, probably an issue with certificate creation: $FROM"
6866
exit 1
6967
fi

docker-images/build_docker_images.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ then
5959
NO_CACHE=--no-cache
6060
fi
6161

62+
if [ ! -f "$DIR/bin/$CORDA_VERSION.jar" -o ! -f "$DIR/bin/corda-tools-health-survey-$HEALTH_CHECK_VERSION.jar" -o ! -f "$DIR/bin/$CORDA_FIREWALL_VERSION.jar" ]; then
63+
echo "Missing binaries, check that you have the correct files with the correct names in the following folder $DIR/bin"
64+
echo "$DIR/bin/$CORDA_VERSION.jar"
65+
echo "$DIR/bin/$CORDA_FIREWALL_VERSION.jar"
66+
echo "$DIR/bin/corda-tools-health-survey-$HEALTH_CHECK_VERSION.jar"
67+
exit 1
68+
fi
69+
6270
cp $DIR/bin/$CORDA_VERSION.jar $DIR/$CORDA_IMAGE_PATH/corda.jar
6371
cp $DIR/bin/corda-tools-health-survey-$HEALTH_CHECK_VERSION.jar $DIR/$CORDA_IMAGE_PATH/corda-tools-health-survey.jar
6472
cd $DIR/$CORDA_IMAGE_PATH

docker-images/docker_config.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
#!/bin/sh
22

3+
set -ux
4+
DIR="."
5+
function GetPathToCurrentlyExecutingScript () {
6+
# Absolute path of this script, e.g. /opt/corda/node/foo.sh
7+
ABS_PATH=$(readlink -f "$0")
8+
if [ "$?" -ne "0" ]; then
9+
echo "readlink issue workaround..."
10+
# Unfortunate MacOs issue with readlink functionality, see https://github.com/corda/corda-kubernetes-deployment/issues/4
11+
TARGET_FILE=$0
12+
13+
cd `dirname $TARGET_FILE`
14+
TARGET_FILE=`basename $TARGET_FILE`
15+
local ITERATIONS=0
16+
17+
# Iterate down a (possible) chain of symlinks
18+
while [ -L "$TARGET_FILE" ]
19+
do
20+
TARGET_FILE=`readlink $TARGET_FILE`
21+
cd `dirname $TARGET_FILE`
22+
TARGET_FILE=`basename $TARGET_FILE`
23+
((++ITERATIONS))
24+
if [ "$ITERATIONS" -gt 1000 ]; then
25+
echo "symlink loop. Critical exit."
26+
exit 1
27+
fi
28+
done
29+
30+
# Compute the canonicalized name by finding the physical path
31+
# for the directory we're in and appending the target file.
32+
PHYS_DIR=`pwd -P`
33+
ABS_PATH=$PHYS_DIR/$TARGET_FILE
34+
fi
35+
36+
# Absolute path of the directory this script is in, thus /opt/corda/node/
37+
DIR=$(dirname "$ABS_PATH")
38+
}
39+
GetPathToCurrentlyExecutingScript
340
set -eux
441

542
DOCKER_REGISTRY=""
43+
DOCKER_REGISTRY=$(grep -A 3 'containerRegistry:' $DIR/../helm/values.yaml | grep 'serverAddress: "' | cut -d '"' -f 2)
644

745
VERSION="4.0"
846
HEALTH_CHECK_VERSION="4.0"

docker-images/push_docker_images.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ set -eux
4141

4242
source $DIR/docker_config.sh
4343

44+
if [ "$DOCKER_REGISTRY" == "" ]; then
45+
echo "You must specify a valid container registry in the values.yaml file"
46+
exit 1
47+
fi
48+
4449
docker login $DOCKER_REGISTRY
4550

4651
docker tag $CORDA_IMAGE_PATH:$CORDA_DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/$CORDA_IMAGE_PATH:$CORDA_DOCKER_IMAGE_VERSION

helm/helm_compile.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ fi
5252

5353
set -eux
5454

55-
TEMPLATE_NAMESPACE="cordatest"
55+
TEMPLATE_NAMESPACE=""
56+
TEMPLATE_NAMESPACE=$(grep -A 3 'config:' $DIR/values.yaml | grep 'namespace: "' | cut -d '"' -f 2)
57+
58+
if [ "$TEMPLATE_NAMESPACE" == "" ]; then
59+
echo "Kubernetes requires a namespace to deploy resources to, no namespace is defined in values.yaml, please define one."
60+
exit 1
61+
fi
5662

5763
helm template $DIR --name $TEMPLATE_NAMESPACE --namespace $TEMPLATE_NAMESPACE --output-dir $DIR/output
5864
mv $DIR/output/corda/templates/pre-install.sh.yml $DIR/output/corda/templates/pre-install.sh

helm/initial_registration/initial_registration.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ function GetPathToCurrentlyExecutingScript () {
3939
GetPathToCurrentlyExecutingScript
4040
set -eux
4141

42-
TEMPLATE_NAMESPACE="cordatest"
4342
OUTPUT_DIR=$DIR/output
4443
SCRIPT=$OUTPUT_DIR/corda/templates/initial_registration.sh
4544
NODE_CONF=$OUTPUT_DIR/corda/templates/node.conf
4645

47-
helm template $DIR -f $DIR/../values.yaml --name $TEMPLATE_NAMESPACE --namespace $TEMPLATE_NAMESPACE --output-dir $OUTPUT_DIR --set-file node_conf=$DIR/../files/node.conf
46+
helm template $DIR -f $DIR/../values.yaml --output-dir $OUTPUT_DIR --set-file node_conf=$DIR/../files/node.conf
4847
mv $OUTPUT_DIR/corda/templates/initial_registration.sh.yml $SCRIPT
4948
mv $OUTPUT_DIR/corda/templates/node.conf.yml $NODE_CONF
5049

helm/templates/create-docker-secret.sh.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
#!/bin/sh
2-
ABS_PATH=$(readlink -f "$0")
3-
DIR=$(dirname "$ABS_PATH")
2+
set -ux
3+
DIR="."
4+
function GetPathToCurrentlyExecutingScript () {
5+
# Absolute path of this script, e.g. /opt/corda/node/foo.sh
6+
ABS_PATH=$(readlink -f "$0")
7+
if [ "$?" -ne "0" ]; then
8+
echo "readlink issue workaround..."
9+
# Unfortunate MacOs issue with readlink functionality, see https://github.com/corda/corda-kubernetes-deployment/issues/4
10+
TARGET_FILE=$0
11+
12+
cd `dirname $TARGET_FILE`
13+
TARGET_FILE=`basename $TARGET_FILE`
14+
local ITERATIONS=0
15+
16+
# Iterate down a (possible) chain of symlinks
17+
while [ -L "$TARGET_FILE" ]
18+
do
19+
TARGET_FILE=`readlink $TARGET_FILE`
20+
cd `dirname $TARGET_FILE`
21+
TARGET_FILE=`basename $TARGET_FILE`
22+
((++ITERATIONS))
23+
if [ "$ITERATIONS" -gt 1000 ]; then
24+
echo "symlink loop. Critical exit."
25+
exit 1
26+
fi
27+
done
28+
29+
# Compute the canonicalized name by finding the physical path
30+
# for the directory we're in and appending the target file.
31+
PHYS_DIR=`pwd -P`
32+
ABS_PATH=$PHYS_DIR/$TARGET_FILE
33+
fi
34+
35+
# Absolute path of the directory this script is in, thus /opt/corda/node/
36+
DIR=$(dirname "$ABS_PATH")
37+
}
38+
GetPathToCurrentlyExecutingScript
439

540
set -eux
641
kubectl create secret docker-registry --dry-run=true container-registry-secret \

helm/templates/pre-install.sh.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
#!/bin/sh
2+
set -ux
3+
DIR="."
4+
function GetPathToCurrentlyExecutingScript () {
5+
# Absolute path of this script, e.g. /opt/corda/node/foo.sh
6+
ABS_PATH=$(readlink -f "$0")
7+
if [ "$?" -ne "0" ]; then
8+
echo "readlink issue workaround..."
9+
# Unfortunate MacOs issue with readlink functionality, see https://github.com/corda/corda-kubernetes-deployment/issues/4
10+
TARGET_FILE=$0
211

3-
set -eux
12+
cd `dirname $TARGET_FILE`
13+
TARGET_FILE=`basename $TARGET_FILE`
14+
local ITERATIONS=0
15+
16+
# Iterate down a (possible) chain of symlinks
17+
while [ -L "$TARGET_FILE" ]
18+
do
19+
TARGET_FILE=`readlink $TARGET_FILE`
20+
cd `dirname $TARGET_FILE`
21+
TARGET_FILE=`basename $TARGET_FILE`
22+
((++ITERATIONS))
23+
if [ "$ITERATIONS" -gt 1000 ]; then
24+
echo "symlink loop. Critical exit."
25+
exit 1
26+
fi
27+
done
428

5-
ABS_PATH=$(readlink -f "$0")
6-
DIR=$(dirname "$ABS_PATH")
29+
# Compute the canonicalized name by finding the physical path
30+
# for the directory we're in and appending the target file.
31+
PHYS_DIR=`pwd -P`
32+
ABS_PATH=$PHYS_DIR/$TARGET_FILE
33+
fi
734

35+
# Absolute path of the directory this script is in, thus /opt/corda/node/
36+
DIR=$(dirname "$ABS_PATH")
37+
}
38+
GetPathToCurrentlyExecutingScript
39+
40+
set -eux
841
APP={{ .Values.config.resourceName }}-node
942
POD=$(kubectl get pod -l app=$APP -o jsonpath="{.items[0].metadata.name}")
1043
CORDAPPS_PATH=$(readlink -f "$DIR/../../../files/cordapps")

0 commit comments

Comments
 (0)