Giter Site home page Giter Site logo

db-initializer's Introduction

db-initializer

This is useful if you want to initialize a bunch of databases in a single RDBMS instance (e.g. single RDS instance). This usecase is common for cost-saving measures in non-production or small to medium production environments. To create a database in postgres, mysql (or mariadb), cocroachdb, you need to:

1. Create db-initializer namespace and github pull secret

Here's the template for your convenience, don't forget to replace credentials:

---
apiVersion: v1
kind: Namespace
metadata:
  name: db-initializer
---
apiVersion: v1
kind: Secret
metadata:
  name: image-pull-secret-github
  namespace: db-initializer
type: kubernetes.io/dockerconfigjson
stringData:
  .dockerconfigjson: |
    {
      "auths": {
        "docker.pkg.github.com": {
          "username": "your-github-user",
          "password": "your-personal-access-token"
        }
      }
    }

2. Apply the manifest

kubectl apply -f https://raw.githubusercontent.com/kirillDanshin/db-initializer/master/deployment/combined.yaml

3. Create dsn secret

Here's a template:

---
apiVersion: v1
kind: Secret
metadata:
  name: some-secret-name
  namespace: some-namespace
type: Opaque
stringData:
  dsn: postgres://postgres:somepassword@hostname:5432/placeholderdb?sslmode=disable

Fill in your details, including the namespace and secret name, and move on to the next step when you're ready.

4. Try it out

To use it after setup, you need to add annotations to a namespace.

---
apiVersion: v1
kind: Namespace
metadata:
  name: example
  annotations:
    # this can be a list separated by comma without spaces between
    dbinit.k8s.danshin.pro/dbNames: test1
    # name of the secret from #3
    dbinit.k8s.danshin.pro/secretName: db-initializer-dsn
    # if secret's namespace is not 'default', you can choose it here
    dbinit.k8s.danshin.pro/secretNamespace: some-namespace

TODO

  • non-rbac deployment
  • support annotations on different CRDs

Found a bug? File a ticket!

If you want to suggest a feature or anything else, please send a PR, it's highly appreciated.

db-initializer's People

Contributors

kirilldanshin avatar

Watchers

 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.