Skip to content
sample notes API server
Go Dockerfile
Branch: master
Clone or download
Latest commit 95a33c1 May 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
kubernetes cleanup (#4) May 19, 2019
vendor JWT Authn flow (#2) May 19, 2019
.gitignore README / cleanup (#3) May 19, 2019
Dockerfile cleanup (#4) May 19, 2019
Gopkg.lock JWT Authn flow (#2) May 19, 2019
Gopkg.toml init (#1) May 14, 2019
README.md
main.go

README.md

📝 notes

A minimal Notes server for storing text-only thoughts, etc. Uses Google Cloud Firestore.

All requests must have a valid JWT (or cookie) which can be obtained by POST /login, using valid creds.

NOTE: This server is only for demo purposes. JWTs alone are not a secure choice for end-user authentication in production.

Endpoints

  • Create note: (POST /notes)
  • Get all notes (GET /notes)
  • Get random note (GET /notes/random)

Running in Google Kubernetes Engine

Prerequisites

  • GCP project with billing enabled
  • A running GKE cluster in your project
  • Firestore API enabled for your project, with a database, notesdb, and an empty collection in that DB, called notes
  • A domain (to serve managed SSL certs)

Steps

  1. Fork or clone this repo
  2. Build Docker image from source:
docker build -t <your-repo>:<tag> .
  1. Push the docker image:
docker push <your-repo>:<tag>
  1. Update kubernetes/deployment.yaml's image (line 24) with your Docker image
  2. Follow instructions here to create a GCP static IP address named example-ip-address.
  3. Update kubernetes/managed-cert.yaml with domains: <your-domain-name>
  4. Get a service account private key for Firestore: go to the Google Cloud Platform Console > IAM & Admin > Service Accounts. Generate a private key, then download it as JSON, service-account.json
  5. Create a Kubernetes secret, firestore-key, from the service account JSON:
kubectl create secret generic firestore-key --from-file=./service-account.json
  1. Create a second Kubernetes secret with your desired Notes Server credentials:
kubectl create secret generic notes-secret --from-literal=username=<YOUR_USERNAME> --from-literal=password=<YOUR_PASSWORD> --from-literal=signkey=<YOUR_JWT_SIGN_KEY>
  1. Apply Kubernetes manifests to the cluster. This will create the SSL managed certs for your domain name, an Ingress (for the static IP you created), and a Service/Deployment for the notes server.
kubectl apply -f kubernetes/
You can’t perform that action at this time.