Skip to content

askmeegs/notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📝 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/

About

sample notes API server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published