Welcome to the Linux Foundation Forum!

firstdb: unable to connect using service name

iraciciracic Posts: 7
edited December 2020 in LFS258 Class Forum

Hi,

In Helm lab, trying to connect to MariaDB from client instance:
mysql -h firstdb-mariadb.default.svc.cluster.local -uroot -p my_database

Unable to connect: ERROR 2005 (HY000): Unknown MySQL server host 'firstdb-mariadb.default.svc.cluster.local' (-3)

kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
firstdb-mariadb ClusterIP 10.101.197.5 3306/TCP 28m
firstdb-mariadb-slave ClusterIP 10.98.65.180 3306/TCP 28m

kubectl get ep
NAME ENDPOINTS AGE
firstdb-mariadb 172.31.223.34:3306 28m
firstdb-mariadb-slave 28m

Tried to change to NodePort:
kubectl edit ep firstdb-mariadb

  • check with:
    kubectl describe svc firstdb-mariadb | grep Type:
    Type: NodePort

But did not help

Connecting with ep IP works:
mysql -h 172.31.223.34 -uroot -p my_database
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
[...]

What did I miss ?

Thank you,
Igor

Comments

  • Hi @iracic,

    Since you are running on AWS, chances are it is related to how the AWS infrastructure sets up the networking and routing between your EC2 instances, through IPtables, resolv.conf, hosts files, and possibly other specific config files. Also SG configs of your VPC may also impact Service resolution from Pods running on different nodes of your cluster.

    The change to a NodePort type Service does not help with intra-cluster traffic routing.

    Regards,
    -Chris

  • Hi Chris,

    Thank you for reply.
    I do not find the solution in this moment.
    As it is not blocking to continue further, I will not pass more time on it (I can add more information if something comes up)

    Regards,
    Igor

Sign In or Register to comment.