Skip to content

javaskrskr/express-psql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-psql

Express & psql With K8s

test

  • Using test.rest with rest client on extension to test req

ENV

POSTGRES_USER=<POSTGRES_USER>
POSTGRES_DB=<POSTGRES_DB>
POSTGRES_PASSWORD=<POSTGRES_PASSWORD>
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
NODE_PORT=5000

PACKAGE

  • npm install

START LOCALLY

  • On term nvm use 20
  • On term npm install
  • Build the container from the ./root directory: docker-compose up -d
  • Access http://localhost:5000/
  • Clean up docker container: docker-compose down

K8S IMPLEMENTATION LOCALLY

  • Download kind: brew install kind

  • Downlaod kubectl:

  • Download docker and ensure it is running on the background

  • Build the docker image: docker build . -t <YOUR_USER_NAME>/express-psql-api -f ./Dockerfile.dev

  • Push the image to docker hub: docker push <YOUR_USER_NAME>/express-psql-api

  • On cli, docker login

  • Build the container from the ./root directory: docker-compose up -d

  • Create kind cluster: kind create cluster

  • Assign docker config credentials for k8s: kubectl create secret generic regcred --from-file=.dockerconfigjson=~/.docker/config.json --type=kubernetes.io/dockerconfigjson

  • If assignment of docker config json is not working, use it instead: kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=<YOUR_USER_NAME> --docker-password=<YOUR_USER_PASSWORD> --docker-email=<YOUR_EMAIL_ON_DOCKER_HUB>

  • Confirm the secret is ready: kubectl get secrets

  • Add ingress controller on the cluster: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.46.0/deploy/static/provider/cloud/deploy.yaml

  • Apply the deployment yml file: kubect apply -f ./k8s

  • Access http://localhost:3050/ can show the base route on the backend side, response as ok

  • Clean up the k8s: kubectl delete all --all

  • Clean up docker container: docker-compose down

About

express and psql with k8s

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published