| api | ||
| bin | ||
| cmd/run | ||
| config | ||
| internal | ||
| manifests | ||
| test | ||
| .gitignore | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| README.md | ||
wwest-stock-ticker
A demo app exposing a simple API that averages stock close prices.
Deploy Environment
- docker
- GNU make
- kubectl authenticated to a vanilla-ish cluster + an ingress installed (e.g. Traefik)
Deployment
Steps
You may want to set some environment variables:
# Set this to whatever your preferred OCI repo is. These instructions
# assume you're autenticated to this server already.
export OCI_BASE=oci-repo.local
# Set this to your Alphavantage API key value.
# A free key should work fine.
export APIKEY=xyx
At this point, as long as your local docker environment is working and your OCI/container repo is available, this step should build, tag and push the image:
make release
Next you'll probably want to do a few things with the manifests/ directory:
- Edit
manifests/deployment.yamlto change the image URL to match your OCI_BASE - Run the secrets shim to load your APIKEY from the env into a secret:
bash manifests/secrets.sh
Finally, you should be able to deploy, assuming your kubectl environment is authenticated to a cluster endpoint:
make deploy
Verification
Check the logs:
kubectl logs deploy/wwest-stock-ticker -f
...you should see structured JSON logs.
Check the endpoint:
k get ingress/wwest-stock-ticker
...since there is no host field, you should be able to hit the IP address directly
from curl or a browser. You'll get a 200 if it's working, and a 500 if there is
some problem connecting with the 3rd party API. Be sure to poke egress rules if you
have a default-deny networking setup in your cluster.
Check metrics:
curl http://[ingress ip]/metrics
...you should see some Prometheus/OpenMetrics-style data.
Dev Environment
- Go 1.25+
- GNU make
Build/Test
make build
make test
...this should show you the integration test results and code coverage, and any issues detected by go vet or the race condition detector.