Home > Blockchain >  Use kubernetes with helm and provide my predefined user and password with bitnami correctly
Use kubernetes with helm and provide my predefined user and password with bitnami correctly

Time:02-21

I am using kubernetes with helm 3.

I need to create a kubernetes pod with sql - creating:

database name: my_database user: root password:12345 port: 3306

The steps: creating chart by:

helm create test

after the chart is created, change the Chart.yaml file in test folder, by adding dependencies section.

apiVersion: v2 name: test3 description: A Helm chart for Kubernetes

version: 0.1.0

appVersion: "1.16.0"

dependencies:

  • name: mysql version: 8.8.23 repository: "https://charts.bitnami.com/bitnami"

run:

helm dependencies build test

After that there is a compressed file tgz. So I extracted it and there is tar file - I extracted it too, and leave only the final extracted folder.

I presume this isn't the best approach of changing parameter in yaml for bitnami, and using also the security.yaml - I would like knowing that better approach too.

I need to change the user password, and link to database, so I changed the values.yaml directly (any better approach?), for values: auth:rootPassword and auth:my_database.

the another following steps:

helm build dependencies test
helm install test --namespace test --create-namespace

after that there are two pods created. I could check it by:

kubectl get pods -n test

and I see two pods running (maybe replication). one of the pod: test-mysql-0 (the other is with random parse).

run:

kubectl exec --stdin --tty test-mysql-0  --namespace test-mysql -- /bin/sh 

did enter the pod. run:

mysql -rroot -p12345;

and then:

show databases;

That did showing all the database, including seeing the created database: my_database, successfully.

When I tried openning the mysql database from 'mysql workbench', and test (same user: root, and password, and port: 3306, and localhost), I couldn't run test (test connection button in database properties returns: 'failed to connect to database').

  1. Why cannot I run properly 'mysql workbench', while in the pad itself - without any particular problem?
  2. Is there any better approach than extrating the tgz file as I described above, and can I pass in better way (some secured yaml) the user password? (Right now is only the root password)

Thanks.

CodePudding user response:

It sounds like you're trying to set the parameters in the dependent chart (please correct me if I'm wrong)

If this is right, all you need to do is add another section in your chart's values.yaml

name-of-dependency:
  user-name: ABC
  password: abcdef

the "name-of-dependency" is specified in your Chart.yaml file when you declare your chart. For example, here's my redis dependency from one of my own charts

dependencies:
  - name: redis
    repository: https://charts.bitnami.com/bitnami/
    version: x.x.x

Then when I install the chart, I can override the redis chart's settings by doing this in my own chart's values.yaml

redis:
  architecture: standalone
  auth:
    password: "secret-password-here"
  • Related