https://github.com/blankdots/minimal-kube-app
https://github.com/blankdots/minimal-kube-app
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/blankdots/minimal-kube-app
- Owner: blankdots
- License: apache-2.0
- Created: 2025-02-03T15:33:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-02T22:07:49.000Z (4 months ago)
- Last Synced: 2026-03-03T00:38:54.260Z (4 months ago)
- Language: Go
- Size: 12.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## kube-app
Small Go service that tracks **npm package metadata** (name, version, dependencies) in a PostgreSQL database. A cron job fetches data from the [npm Registry](https://registry.npmjs.org) and stores it; an HTTP API lets you query it by package name (e.g. `/query?package=express`). Intended as a minimal example for running an API + cron job on Kubernetes with Helm, kind, and Tilt.
### Local Development
The Makefile is primarily designed to be an aid during development work.
Start setup:
```bash
make bootstrap
```
#### kind + Tilt (recommended)
Local Kubernetes in Docker with live reload. Requires [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation), [Tilt](https://docs.tilt.dev/install.html), and the [CloudNative PG](https://cloudnative-pg.io/) operator (for the database).
```bash
# One-time: create cluster, install CNPG operator, fetch Helm chart dependencies
make kind-create
helm repo add cnpg https://cloudnative-pg.github.io/charts
helm install cnpg cnpg/cloudnative-pg -n cnpg-system --create-namespace
make helm-deps
# Start Tilt (builds image, loads into kind, deploys via Helm; port-forwards API to 5005)
make tilt-up
```
Then open the Tilt UI (default http://localhost:10350). Once the API is ready:
```bash
curl -v -H "Authorization: Bearer test" "http://localhost:5005/query?package=express"
# or: curl -v -H "X-API-Key: test" "http://localhost:5005/query?package=express"
```
Stop:
```bash
make tilt-down
make kind-delete # when you want to remove the cluster
```
#### Build container only
```bash
make build
```
#### Unit Testing
Using [golangci-lint](https://golangci-lint.run/usage/install/) and Go tests:
```bash
make lint
make test
```
### K8s Deployment (production or manual)
Requires a Kubernetes cluster (e.g. [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)), `helm`, and `kubectl`.
#### Install and test Helm chart
```bash
make helm-deps
make helm
kubectl port-forward deployment/kube-app-api 5005:5005
curl -v -H "Authorization: Bearer test" "http://localhost:5005/query?package=express"
# or: curl -v -H "X-API-Key: test" "http://localhost:5005/query?package=express"
```