Skip to content

bryanSolares/simple-api-with-database-into-kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API with ConfigMap and Secrets

Prerequisites

  • Minikube
  • Docker
  • Node.js

Objectives

  • Create a ConfigMap and Secrets
  • Create a Pod that uses the ConfigMap and Secrets
  • Create simple API with Node.js and Express with PostgreSQL

change docker env into minikube

Doc minikube docker-env

eval $(minikube docker-env)

build image into minikube

docker build -t backend:0.1.0 .

encode credentials for user, password and database

echo -n "ultrasecret" | base64

create and apply manifests (do twice to see the changes)

cd /deployment
kubectl apply -f .

if use minikube, you can see the api service

minikube service api-service --url

use api

curl http://<ip-minikube>:30001/api/v1/health
curl http://<ip-minikube>:30001/api/v1/users
curl -X POST http://<ip-minikube>:30001/api/v1/users -H "Content-Type: application/json" -d '{"name": "John", "email": "john@example.com"}'

About

API - PostgreSQL - Kubernetes

Topics

Resources

Stars

Watchers

Forks