This is where the code for the Medicines API lives.
You should have rust
installed, ideally rustup
.
If you're using homebrew, you should be able to install rustup
by running:
brew install rustup-init
rustup-init
and following the instructions
You may be able to install rustup
through your chosen package manager, if you use one.
Otherwise, visit rust-lang's rustup
installation guide, which has instructions for your operating system.
For installing
You should also have installed:
- Docker
- Kubernetes
kubectl
to manage the Kubernetes cluster. - Kubernetes
stern
- Navigate to this directory (
/medicines/api
) - Run
make get-env
to get a copy of environment variables - Run
make
to build and run the server - Once compiled, open a browser tab and go to http://127.0.0.1:8000/healthz
- You should see OK rendered on the page
To see the GraphQL explorer, go to http://127.0.0.1:8000.
- Navigate to this directory (
/medicines/api
) - Run
DOCKER_BUILDKIT=1 docker build . -t api
- Run
docker run -p 8080:8000 --env-file .env api
- Open the browser and go to
http://localhost:8080/healthz
- You should see an Ok and a server log in your terminal
To see the GraphQL explorer, go to http://127.0.0.1:8080.
-
Navigate to this directory (
/medicines/api
) -
Source environmental variables from the corresponding environment
source ./infrastructure/non-prod/.env
-
Create Kubernetes secret for API Pod to consume
kubectl create secret generic azure-search-secrets \ --from-literal=AZURE_SEARCH_KEY="$AZURE_SEARCH_KEY" \ --from-literal=AZURE_SEARCH_INDEX="$AZURE_SEARCH_INDEX" \ --from-literal=AZURE_SEARCH_SERVICE="$AZURE_SEARCH_SERVICE" \
-
Create Kubernetes Service
kubectl apply -f ./infrastructure/non-prod/service.yml
-
Deploy Kubernetes pod by applying a deployment
kubectl apply -f ./infrastructure/non-prod/deployment.yml
-
Check if the pods are running
stern api
-
You should receive a health server log like this
api-558646c969-9mdxp api [2020-01-20T15:02:57Z INFO actix_web::middleware::logger] 10.244.1.1:51524 "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.14" 0.000059
To create a new release and deployment to production, create and push a new tag of the form medicinesapi.vX.X.X
(e.g. medicinesapi.v1.3.0
) at the commit you want to release, incrementing as required from the most recent version. The medicines-api-release
workflow will then pull the image from the non-prod
container registry (created as part of the master branch workflow), push the image to the production
container registry in Azure and then update the commit SHA in the production overlay in deployments repo. ArgoCD will identify this change, pull the linked image from the container registry and deploy it to the cluster.