Mysql helm chart not working when we delete existing helm chart and try installing again

2/19/2020

I have added stable/mysql chart in requirements.yaml

dependencies:
  - name: mysql
    version: 1.4.0
    repository: https://kubernetes-charts.storage.googleapis.com
    condition: global.install_mysql

Created a PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-azure-managed-disk
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium
  resources:
    requests:
      storage: 5Gi

And added persistence in mycharts values.yaml

mysql:
  persistence:
    enabled: false
    storageClass: managed-premium
    existingClaim: mysql-azure-managed-disk
    accessMode: ReadWriteOnce
    size: 1Gi
    annotations: {}

When I install mychart helm install --name mychart . the chart gets installed successfully and my other pod is also able to connect to the mysql pod with password from secrets.

But when I delete the chart and install again new pod is not able to connect to the mysql pod.

Has anyone faces this issue?

This is the first time log

C02XF0N6JG5M:mychart komal$ k logs -f mychart-mysql-6f5f77445f-d2sld 
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/posix/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/right/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.


MySQL init process done. Ready for start up.

Secrets created for first time

k get secrets mychart-mysql -o yaml
apiVersion: v1
data:
  mysql-password: dmY3NjIybU9FTA==
  mysql-root-password: WWRCVHo4MDFNcQ==
kind: Secret
metadata:
  creationTimestamp: "2020-03-06T07:51:01Z"
  labels:
    app: mychart-mysql
    chart: mysql-1.4.0
    heritage: Tiller
    release: reancore
  name: reancore-mysql
  namespace: default
  resourceVersion: "2450905"
  selfLink: /api/v1/namespaces/default/secrets/reancore-mysql
  uid: a1ec1f81-8986-4aad-b952-af2dad1fab5a
type: Opaque

When I am trying to get thee logs second time, it doesn't give me anything in logs, but the pod is started and running.

This is the describe output

k describe pods mychart-mysql-6f5f77445f-fv4rj
Name:           mychart-mysql-6f5f77445f-fv4rj
Namespace:      default
Priority:       0
Node:           aks-agentpool-16017342-vmss000000/10.240.0.4
Start Time:     Fri, 06 Mar 2020 14:09:12 +0530
Labels:         app=mychart-mysql
                pod-template-hash=6f5f77445f
                release=mychart
Annotations:    <none>
Status:         Running
IP:             10.244.0.139
IPs:            <none>
Controlled By:  ReplicaSet/mychart-mysql-6f5f77445f
Init Containers:
  remove-lost-found:
    Container ID:  docker://e8791c6acbac6ac6a37c0e9bf039015a84330feee5a4ad52e98ca530b71df804
    Image:         busybox:1.29.3
    Image ID:      docker-pullable://busybox@sha256:8ccbac733d19c0dd4d70b4f0c1e12245b5fa3ad24758a11035ee505c629c0796
    Port:          <none>
    Host Port:     <none>
    Command:
      rm
      -fr
      /var/lib/mysql/lost+found
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Fri, 06 Mar 2020 14:09:34 +0530
      Finished:     Fri, 06 Mar 2020 14:09:34 +0530
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:        10m
      memory:     10Mi
    Environment:  <none>
    Mounts:
      /var/lib/mysql from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-gdgms (ro)
Containers:
  mychart-mysql:
    Container ID:   docker://54e5dc22543fcc028ab000eda1fe08569ed65b31c2072b74068eb861eb4ce119
    Image:          mysql:5.7.14
    Image ID:       docker-pullable://mysql@sha256:c8f03238ca1783d25af320877f063a36dbfce0daa56a7b4955e6c6e05ab5c70b
    Port:           3306/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 06 Mar 2020 14:09:34 +0530
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:      100m
      memory:   256Mi
    Liveness:   exec [sh -c mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}] delay=30s timeout=5s period=10s #success=1 #failure=3
    Readiness:  exec [sh -c mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}] delay=5s timeout=1s period=10s #success=1 #failure=3
    Environment:
      MYSQL_ROOT_PASSWORD:  <set to the key 'mysql-root-password' in secret 'mychart-mysql'>  Optional: false
      MYSQL_PASSWORD:       <set to the key 'mysql-password' in secret 'mychart-mysql'>       Optional: true
      MYSQL_USER:           
      MYSQL_DATABASE:       
    Mounts:
      /var/lib/mysql from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-gdgms (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mysql-azure-managed-disk2
    ReadOnly:   false
  default-token-gdgms:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-gdgms
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age    From                                        Message
  ----    ------     ----   ----                                        -------
  Normal  Scheduled  3m4s   default-scheduler                           Successfully assigned default/mychart-mysql-6f5f77445f-fv4rj to aks-agentpool-16017342-vmss000000
  Normal  Pulled     2m43s  kubelet, aks-agentpool-16017342-vmss000000  Container image "busybox:1.29.3" already present on machine
  Normal  Created    2m43s  kubelet, aks-agentpool-16017342-vmss000000  Created container remove-lost-found
  Normal  Started    2m42s  kubelet, aks-agentpool-16017342-vmss000000  Started container remove-lost-found
  Normal  Pulled     2m42s  kubelet, aks-agentpool-16017342-vmss000000  Container image "mysql:5.7.14" already present on machine
  Normal  Created    2m42s  kubelet, aks-agentpool-16017342-vmss000000  Created container mychart-mysql
  Normal  Started    2m41s  kubelet, aks-agentpool-16017342-vmss000000  Started container mychart-mysql

Somehow second time my applications pod is not able to connect to the mysql's pod

-- Komal Kadam
kubernetes-helm

1 Answer

3/6/2020

When I add mysqlRootPassword in values.yaml, even when I delete the chart and install new again. It connects to mysql pod every time.

mysql:
  mysqlRootPassword: root1
  persistence:
    enabled: false
    storageClass: managed-premium
    existingClaim: mysql-azure-managed-disk
    accessMode: ReadWriteOnce
    size: 1Gi
    annotations: {}
-- Komal Kadam
Source: StackOverflow