Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying bitnami/mysql helm chart with an existing Persistence Volume Claim

I'm trying to deploy bitnami/mysql chart inside my minikube. I'm using Kubernetes v1.19, Minikube v1.17.1 and Helm 3

I've created a PVC and PV as follow:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mysql-pvc
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
  selector:
    matchLabels:
      id: mysql-pv
----
kind: PersistentVolume
apiVersion: v1
metadata:
  name: mysql-pv
  labels:
    type: local
    id: mysql-pv
spec:
  storageClassName: standard
  capacity:
    storage: 8Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /var/lib/mysql

I've created the directory /var/lib/mysql by doing sudo mkdir -p /var/lib/mysql And this is how I create my PVC and PC:

kubectl apply -f mysql-pv-dev.yaml
kubectl apply -f mysql-pvc-dev.yaml

Which seems to work:

NAME       STATUS   VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
mysql-pvc  Bound    mysql-pv   8Gi        RWO            standard          59s

I am deploying my mysql with: helm upgrade --install dev-mysql -f mysql-dev.yaml bitnami/mysql

Custom value file - mysql-dev.yaml:

auth:
  database: dev_db
  username: dev_user
  password: passworddev
  rootPassword: rootpass
image:
  debug: true
primary:
  persistence:
    existingClaim: mysql-pvc
  extraVolumeMounts: |
      - name: init
        mountPath: /docker-entrypoint-initdb.d
  extraVolumes: |
      - name: init
        hostPath:
          path: /home/dev/init_db_scripts/
          type: Directory
volumePermissions:
  enabled: true

The deployement works:

NAME         READY   STATUS    RESTARTS   AGE
dev-mysql-0  0/1     Running   0          8s 

the problem is that the pod never gets ready because:

  Warning  Unhealthy  0s (x2 over 10s)  kubelet            Readiness probe failed: mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

mysqld is running inside the pod but for some reasons the root password isn't properly set because when I exec to the pod and try to connect to mysql I get:

$ kubectl exec -ti dev-mysql bash
I have no name!@dev-mysql-0:/$ mysql -u root -prootpass
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I have no name!@dev-mysql-0:/$

Instead it's using the default values so if I try: mysql -u root -p without password it works great.

Thanks

like image 625
Jérémy Octeau Avatar asked Feb 24 '21 04:02

Jérémy Octeau


People also ask

Can Helm create persistent volume?

To access the PersistentVolumes (PVs) on your cluster, the HCL Digital Experience 9.5 Kubernetes or OpenShift deployment using Helm creates PersistentVolumeClaims (PVCs) that binds the PVs to the corresponding pods.

Can a Helm chart have multiple deployments?

Take Your Helm Charts to the Next Level With Helm, you can deploy packaged applications as a collection of versioned, pre-configured Kubernetes resources. Let's assume you're deploying a database with Kubernetes—including multiple deployments, containers, secrets, volumes, and services.


1 Answers

A bitnami engineer here, I was able to reproduce the issue, I'm going to create an internal task to resolve this. We will update this thread when we have more information.

like image 94
Ibone Avatar answered Sep 17 '22 18:09

Ibone