Coder Social home page Coder Social logo

k8s-configs's Introduction

Postgres Clusters with Kubernetes

Pre-Requisites

  • CloundativePG K8s operator
  • K8s cluster containing AWS secrets
kubectl create secret generic aws-creds \
  --from-literal=ACCESS_KEY_ID=<access key here> \
  --from-literal=ACCESS_SECRET_KEY=<secret key here>
  • Set kubeconfig env variable to path of kubeconfig file (attached in 1 password)

How to create a database cluster

  • See postgres-cluster.yaml for reference yaml
  • Edit database name, make sure it's unique within cluster
  • Run kubectl apply -f <pg-cluster-config-file-you-created.yaml>

How to create a backup

  • See backup.yaml for reference
  • Simply change cluster name in the config file u create to targeta databse

How to recover from a backup

  • See recover-cluster.yaml file for reference

How to view database credentials

  • Enter kubectl get secrets. Add -n option if database was applied to a namespace
  • From the list secrets. Locate -app secret
  • Run kubectl get secrets <secretname with -app> -o yaml. Example : kubectl get secrets cluster-ai-app -n pg-clusters -o yaml
  • Decode password and username using base64 decode manually

How to connect locally

  • For the database name you selected , run : kubectl port-forward service/<dbname>-rw 5432:5432. If database was created in a namespace, run : kubectl port-forward service/<db-name>-rw 5432:5432 -n <namespace>
  • Get database credentials from secrets
  • Should be able to connect on localhost:5432

How to connect with app deployed in k8s cluster

https://cloudnative-pg.io/documentation/1.20/applications/#connecting-from-an-application

k8s-configs's People

Contributors

dineshpabbi10 avatar

Watchers

 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.