|
| 1 | +## Contract generation example for the Daytrader sample application |
| 2 | + |
| 3 | +This sample creates an encrypted and signed contract and stores it locally in a file. You can later use the contract to provision a HPVS for VPC instance. |
| 4 | +The contract will define the container image, the container registry and the credentials for pulling your workload container image. |
| 5 | + |
| 6 | +### Build the daytrader sample application |
| 7 | +On LinuxONE, e.g. a virtual server for VPC with s390x architecture, build the container image for the DayTrader sample application. |
| 8 | + |
| 9 | +To do so, clone or [download](https://github.com/OpenLiberty/sample.daytrader8/archive/master.zip) this [repository](https://github.com/OpenLiberty/sample.daytrader8/). |
| 10 | + |
| 11 | +From inside the sample.daytrader8 directory, build the application with the following commands: |
| 12 | +``` |
| 13 | +mvn clean package |
| 14 | +docker build . -t daytrader:s390x |
| 15 | +``` |
| 16 | + |
| 17 | +Then tag and push the resulting container image to your container registry. |
| 18 | + |
| 19 | +### Prerequisite |
| 20 | + |
| 21 | +Prepare your local environment according to [these steps](../README.md) |
| 22 | + |
| 23 | +### Define your settings |
| 24 | + |
| 25 | +Define your settings: |
| 26 | +- logdna_ingestion_hostname: The ingestion host name of your Log instance which you provisioned previously |
| 27 | +- logdna_ingestion_key: The ingestion key of your Log instance |
| 28 | +- registry: The container registry where the workload container image is pulled from, e.g. `us.icr.io` |
| 29 | +- pull_username: The container registry username for pulling your workload container image |
| 30 | +- pull_password: The container registry password for pulling your workload container image |
| 31 | + |
| 32 | +The settings are defined in form of Terraform variables. |
| 33 | + |
| 34 | +Define the variables in a template file: |
| 35 | + |
| 36 | +1. `cp my-settings.auto.tfvars-template my-settings.auto.tfvars` |
| 37 | +2. Fill the values in `my-settings.auto.tfvars` |
| 38 | + |
| 39 | +### Define your workload |
| 40 | + |
| 41 | +Create the file `compose\pod.yml` for your workload. Adapt the value for `image` to reference your container registry and your container image including the digest, e.g.: |
| 42 | + |
| 43 | +``` |
| 44 | +apiVersion: v1 |
| 45 | +kind: Pod |
| 46 | +metadata: |
| 47 | + name: daytrader |
| 48 | +spec: |
| 49 | + containers: |
| 50 | + - name: daytrader |
| 51 | + image: us.icr.io/sample/daytrader@sha256:5f4f20aee41e27858a8ed320faed6c2eb8b62dd4bf3e1737f54575a756c7a5da |
| 52 | + ports: |
| 53 | + - containerPort: 9080 |
| 54 | + hostPort: 9080 |
| 55 | + protocol: tcp |
| 56 | +``` |
| 57 | + |
| 58 | +### Create the contract |
| 59 | + |
| 60 | +```bash |
| 61 | +terraform init |
| 62 | +terraform apply |
| 63 | +``` |
| 64 | + |
| 65 | +### Further steps |
| 66 | + |
| 67 | +The contract will be written to the file `build/contract.yml` and can now be used for e.g. provisining a HPVS for VPC instance. |
| 68 | + |
| 69 | +Note that you will need to create a public gateway in your VPC before creating the HPVS for VPC instance. This is necessary to allow the HPVS for VPC instance to reach your Log instance through the public gateway. Also assign a floating IP to your HPVS for VPC instance. |
| 70 | + |
| 71 | +Once the instance is started, you can access the application at: `http://<floatingip>:9080/daytrader` |
| 72 | + |
| 73 | +After provisioning the HPVS for VPC instance you can use JMeter to test your daytrader application. To do so follow [these instructions](https://github.com/OpenLiberty/sample.daytrader8/blob/main/README_LOAD_TEST.md). |
0 commit comments