This document describes how to develop and add features to the Bank of Anthos application in your local environment.
- A GCP project, connected to your billing account.
- A GKE cluster in your project. We recommend 4 nodes, machine type:
e2-standard-4
.
You can use MacOS or Linux as your dev environment - all these languages and tools support both.
- Docker Desktop
- kubectl (can be installed separately or via gcloud)
- skaffold
- JDK 14 (newer versions might cause issues)
- Maven 3.6 (newer versions might cause issues)
- Python3
- piptools
If you're adding a new feature that requires a new external Python package in one or more services (frontend
, contacts
, userservice
), you must regenerate the requirements.txt
file using piptools
. This is what the Python Dockerfiles use to install external packages inside the containers.
To add a package:
-
Add the package name to
requirements.in
within thesrc/<service>
directory: -
From inside that directory, run:
python3 -m pip install pip-tools
python3 -m piptools compile --output-file=requirements.txt requirements.in
- Re-run
skaffold dev
orskaffold run
to trigger a Docker build using the updatedrequirements.txt
.
If you're adding a new feature to one or more of the Java services (ledgerwriter
, transactionhistory
, balancereader
) and require a new third-party package, do the following:
- Add the package to the
pom.xml
file in thesrc/<service>
directory, under<dependencies>
. You can find specific package info in Maven Central (example). Example:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
- Re-run
skaffold dev
orskaffold run
to trigger a Jib container build using Maven and the updated pom file.
The extras directory provides the RSA key/pair secret used for demos. To create your own:
openssl genrsa -out jwtRS256.key 4096
openssl rsa -in jwtRS256.key -outform PEM -pubout -out jwtRS256.key.pub
kubectl create secret generic jwt-key --from-file=./jwtRS256.key --from-file=./jwtRS256.key.pub
We recommend you test and build directly on Kubernetes, from your local environment. This is because there are seven services and for the app to fully function, all the services need to be running. All the services have dependencies, environment variables, and secrets and that are built into the Kubernetes environment / manifests, so testing directly on Kubernetes is the fastest way to see your code changes in action.
You can use the skaffold
tool to build and deploy your code to the GKE cluster in your project.
Make sure that you export PROJECT_ID
as an environment variable (or add to your .bashrc
before running either of these commands)
The skaffold dev
command watches your local code, and continuously builds and deploys container images to your GKE cluster anytime you save a file. Skaffold uses Docker Desktop to build the Python images, then Jib (installed via Maven) to build the Java images.
skaffold dev --default-repo=gcr.io/${PROJECT_ID}/bank-of-anthos
The skaffold run
command build and deploys the services to your GKE cluster one time, then exits.
skaffold run --default-repo=gcr.io/${PROJECT_ID}/bank-of-anthos
When you're ready to create a Pull Request for your branch, you will notice that the Github Actions CI workflows run on your branch. This includes both code and deploy tests into a separate GKE cluster owned by the maintainers. The GitHub Actions CI workflows are described here.