Skip to content

Commit eb044be

Browse files
authored
Merge pull request #145 from BitGo/WP-6632
docs(mbe): add implementation docs to IBM
2 parents 9eaf301 + a238513 commit eb044be

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

ibm-integration.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# IBM HPVS Integration
2+
3+
Master bitgo express and Advanced wallet manager is deployable on an IBM HPVS. The HPVS offers a secure environment to host the AWM, and a bus-connected HSM that is connected to the machine hosting the HPVS. Some might consider using IBM's HPVS as a part of their solution due to these stated features. This md provides a quick guide on how to integrate with IBM's environment.
4+
5+
Please note that BitGo does not provide direct support to your IBM integration. This md only gives documentation to the process and some common roadblocks that you might face during the integration process. Please contact your IBM support team for official guidance and support.
6+
7+
## Architecture Overview
8+
9+
The advanced wallet system typically comes with 3 separate applications - Master bitgo express, Advanced wallet manager, and a KMS API that interacts with the HSM.
10+
11+
Host all three of these application on HPVS via podman containers. You should request access to IBM's HSM and secure storage during your integration.
12+
13+
## Big-endian hardware
14+
Note that IBM's HPVS is run on the IBM LinuxONE Machine, which has the linux s390x architecture. Unlike other common architectures, linux s390x is a [big-endian architecture](https://en.wikipedia.org/wiki/Endianness). Keep this in mind during your integration, as not all software (especially Javascript libraries) support big-endianness.
15+
16+
## Contracts
17+
A HPVS instance is deployed via a [contract](https://www.ibm.com/docs/en/hpvs/2.1.x?topic=servers-about-contract). A contract is a yaml file that tells the machine what to do during startup, and consists of 2 major parts - workload and env.
18+
19+
### Docker images
20+
During deployment, IBM HPVS will take in your docker compose and build up the container. However, HPVS cannot build the docker image via compose directly. Instead, you will need to build the image up against the s390x architecture first and upload it to a private podman repository. You will likely be given a podman repo from IBM that the HPVS can access, alongside its certificate and login credentials. Upload the built images (against s390x) to the repo.
21+
22+
#### Building images
23+
When building podman images on s390x architecture, you might run into the following issue
24+
```bash
25+
Error relocating /bin/sh: RELRO protection failed: No error information
26+
```
27+
This is due to the SELinux protection on the IBM machine, which causes labeling issue when building the images. Add the option `--security-opt label=disable` to circumvent this issue.
28+
29+
### Workload
30+
The workload provides all necessary information to what HPVS needs to do during startup, e.g. the docker compose of MBE and AWM, the docker images, and the certificate to the private podman repo all goes into this session. Workload also includes how the volume (or the persistent storage) is setup on the HPVS as well.
31+
32+
### Env
33+
The env provides information to the cloud environment that is not known to the workload persona. It includes sections such as logging and volumes. If your solution involves the crypto-passthrough, you will have to set it up in this section as well.
34+
35+
### Contract encryption
36+
After the workload and env section is populated correctly, you will need to encrypt these sections into a hash. Together, these hashes forms the contract required for the HPVS to start up.
37+
38+
### Contract generator
39+
IBM might provide you with a script that generates the encrypted contract for you, using the docker compose as input.
40+
41+
## Deploying the contract
42+
Once you have the contract, following [this](https://www.ibm.com/docs/en/hpvs/2.1.x?topic=servers-setting-up-configuring-hyper-protect-virtual) guide to generate the ISO image required for the HPVS deployment.
43+
44+
When generating the ISO image, you will also need to specify a network configuration. Within the network configuration, you will specify the static IP of the HPVS instance as well. For example, if you network config specified the following:
45+
```yaml
46+
network:
47+
version: 2
48+
ethernets:
49+
enc7:
50+
dhcp4: true
51+
enc8:
52+
dhcp4: false
53+
addresses:
54+
- 0.0.0.0/19
55+
```
56+
Then your apps will be hosted at `http://0.0.0.0:<port of the app>`. Please note that you cannot specify this IP address to anything. Contact IBM for the correct static address for you.
57+
58+
## Setup domain XML
59+
After generating the ISO image using the contract, you will then need to create a `domain.xml` file, which specifies where the ISO image is and what hardware does the HPVS need to deploy for the app to start up correctly. Section 14 of [this](https://www.ibm.com/docs/en/hpvs/2.1.x?topic=servers-setting-up-configuring-hyper-protect-virtual) guide provides you code snippet on the `domain.xml` as reference. The xml should also define the name of the HPVS instance. We will use the name `advanced-wallet` as an example.
60+
61+
## Starting the HPVS instance
62+
Once all of the above setup is complete, you can start up the HPVS. First, you will need to run the following command once to define the HPVS instance. Once run, we can directly refer the HPVS instance as `advanced-wallet`:
63+
```bash
64+
virsh define <domain.xml>
65+
```
66+
You will need to only run the above command once, unless you change the xml file. If so, run `virsh undefine advanced-wallet` to first undefine and then the above command to re-define it.
67+
68+
Now that the HPVS instance is named and defined, we can start up the instance:
69+
```bash
70+
virsh start advanced-wallet --console
71+
```
72+
73+
To see if the HPVS instance is running, run the following. You should see the name `advanced-wallet` in the output:
74+
```bash
75+
virsh list
76+
```
77+
78+
To stop the HPVS instance, run the following command:
79+
80+
```bash
81+
virsh shutdown advanced-wallet
82+
```
83+
You do not need to undefine and redefine the domain.xml to restart the HPVS instance. Note that the data stored in the volume should be persistent even if you shutdown and re-start up the HPVS instance.
84+
85+
## Changes required on your docker compose
86+
1. Build using image sha directly instead of using Dockerfile. The contract does not support building the container image using the docker compose directly. Upload the image to a repo and add the SHA to the docker compose instead:
87+
```bash
88+
podman push localhost/advanced-wallet-manager docker://<repo-ip>/advanced-wallet-manager:latest
89+
(push build image to repo-ip)
90+
skopeo inspect docker://<repo-ip>/advanced-wallet-manager:latest
91+
(fetch the SHA of the image)
92+
```
93+
94+
```yaml
95+
services:
96+
advanced-wallet-manager:
97+
image:
98+
<repo-ip>/advanced-wallet-manager@sha256:<sha>
99+
```
100+
101+
2. Set the volume in the docker compose. Your volume address should match where you mount your disk, as specified in your contract. For example, if your workload component of your contract looks something like:
102+
```yaml
103+
volumes:
104+
data:
105+
filesystem: "ext4"
106+
mount: "/mnt/data"
107+
seed: "1234"
108+
```
109+
then you are specifying that the HPVS should keep all files under the directory `/mnt/data` to be persistent. So your bind mount on your docker compose needs to match:
110+
```yaml
111+
services:
112+
advanced-wallet-manager:
113+
volume:
114+
- "/mnt/data:/data"
115+
```
116+
Note that `/mnt/data` is the address on the HPVS while `/data` is the virtual address on the container. If set up properly, all data stored in the container address `/data` by your application will persist even if you restart the HPVS.
117+
118+
3. Set up a DNS address on MBE. You might run into issue where the MBE cannot resolve http request due to not finding a correct DNS server IP address to resolve the domain name request. If so, simply add a public DNS server to the docker compose:
119+
```yaml
120+
services:
121+
advanced-wallet-manager:
122+
dns:
123+
- 8.8.8.8
124+
```

0 commit comments

Comments
 (0)