Coder Social home page Coder Social logo

k8s-config-as-code's Introduction

Boiler plate for trying config as code for Helm

The problem statement was is to allow consumer to pass arbitary shell scripts to be executed against an RDBMS - such as creating DB / users etc.

Using ConfigMap as code allows to pass values as code that can be mounted as shell script in a Pod

Before you begin, download and run mysql 5.7
> helm repo add bitnami https://charts.bitnami.com/bitnami

> helm install mysql bitnami/mysql --set auth.rootPassword=nimda --set image.tag=5.7

๐Ÿ”ด Output

NAME: mysql
LAST DEPLOYED: Mon Jun  6 18:13:52 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 9.1.4
APP VERSION: 8.0.29

** Please be patient while the chart is being deployed **

Test the k8s job with default db.script in values.yaml

helm upgrade bahmni-db-setup bahmni-db-setup/ --install --wait

You can override the db.script with bahmni-db-setup/db-scripts.sh

DB_SCRIPT=$(cat bahmni-db-setup/db-scripts.sh) && helm upgrade bahmni-db-setup bahmni-db-setup/ --set db.script=$DB_SCRIPT --install --wait

Uninstall

helm uninstall bahmni-db-setup

To connect to your database:

The DB is running on Primary: mysql.default.svc.cluster.local:3306 Username: root

You can get the master password using

kubectl get secret --namespace default mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d
  1. Export root password
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d)
  1. Run a pod that you can use as a client:
  kubectl run mysql-client --rm --tty -i --restart='Never' --image  docker.io/bitnami/mysql:5.7 --namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash
  1. To connect to primary service (read/write):
  mysql -h mysql.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"

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.