Helm Kubernetes connect to mysql chart from my nodejs chart inside same cluster

2/7/2019

I'm trying to deploy my NodeJS application using helm chart inside an AKS cluster and within the same cluster, I want to install MYSQL helm chart and connect it from my NodeJS application.

Here's what I have done so far:

1): First, I have installed the mysql chart on my cluster using the command below:

helm install --name mysql --set mysqlRootPassword=rootpassword,mysqlUser=mysql,mysqlPassword=my-password,mysqlDatabase=mydatabase,persistence.existingClaim=mysql-pvc stable/mysql

2): After that, I have installed my nodejs application chart and here how I'm using the mysql chart in my application:

  connections: {
    mysqlDB: {
        adapter: 'mysqlAdapt',
        host: process.env.default.svc.cluster.local,
        database: 'mydatabase',
        user:'root',
        password:'my-password',
        port: 3306,
        supportBigNumbers:true, //true/false
        debug:['ComQueryPacket'], //false or array of node-mysql debug options
        trace:true //true/false
    } 
  }
};

but when I run my application service from kubernetes cluster and my pod becomes 'CrashLoopBackOff` and return the error below:

Error (E_UNKNOWN) :: Encountered an unexpected error
: Could not connect to MySQL:
Error: connect ECONNREFUSED 127.0.0.1:3306

I'm new to helm and kubernetes, how can I connect to MySQL helm chart from my nodejs application? and I'm using the right approach to use a SQL database?

Thanks in advance!

-- Abdul Rehman
docker
kubernetes
kubernetes-helm
mysql
node.js

0 Answers