Giter Club home page Giter Club logo

pgtest's Introduction

PostgreSQL test application

This is a sample application that uses a PostgreSQL database and consumes the DB configuration via a Kubernetes ConfigMap and Secret.

This allows the configuration to be changed easily based on environment the application is deployed in.

For example, the ConfigMap and Secret when using an AWS RDS instance are as follows

apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    kasten.io/config: dataservice
  name: dbconfig
data:
  dataservice.type: postgres
  postgres.manager: awsrds
  postgres.host: dbendpoint.adsadasa.us-west-2.rds.amazonaws.com
  postgres.databases: mypgsqldb
  postgres.user: postgres
  postgres.secret: dbcreds # name of K8s secret in the same namespace

---

apiVersion: v1
kind: Secret
metadata:
  name: dbcreds
type: Opaque
data:
  password: <BASE64 encoded password>

Build/Package application

make clean
make container
make push

Deployment into Kubernetes

# Set namespace to deploy into
export NAMESPACE=pgtestrds
kubectl create namespace ${NAMESPACE}
kubectl apply -f deploy/. --namespace ${NAMESPACE}

Testing the application

Use kubectl proxy to connect to the service in the cluster

kubectl proxy&

Get Service and Database Information

http://127.0.0.1:8001/api/v1/namespaces/pgtestrds/services/pgtestapp:8080/proxy/

Count rows

http://127.0.0.1:8001/api/v1/namespaces/pgtestrds/services/pgtestapp:8080/proxy/count

Insert a new row

http://127.0.0.1:8001/api/v1/namespaces/pgtestrds/services/pgtestapp:8080/proxy/insert

pgtest's People

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.