<p>I got 3 node on aws eks.</p>
<p>I want to use mysql client and access the database via Nginx Ingress.</p>
<p>this is my yaml.</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: ext-nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: ext-nginx-ingress
  namespace: ext-nginx-ingress
spec:
  rules:
    - host: mysql.***********.com
      http:
        paths:
          - backend:
              serviceName: mysql-svc
              servicePort: 3306
            path: /
            pathType: ImplementationSpecific
          - backend:
              serviceName: nginx-svc
              servicePort: 80
            path: /nginx
            pathType: ImplementationSpecific
</code></pre>
<p><strong>describe my ingress service</strong></p>
<pre><code>tes.io/name=ingress-nginx
Type:                     LoadBalancer
IP:                       172.20.209.228
LoadBalancer Ingress:     ************.elb.ap-northeast-2.amazonaws.com
Port:                     http  80/TCP
TargetPort:               http/TCP
NodePort:                 http  31218/TCP
Endpoints:                10.11.53.243:80
Port:                     https  443/TCP
TargetPort:               https/TCP
NodePort:                 https  31308/TCP
Endpoints:                10.11.53.243:443
Port:                     proxie-tcp-mysql  3306/TCP
TargetPort:               mysql/TCP
NodePort:                 proxie-tcp-mysql  32514/TCP
Endpoints:                
Session Affinity:         None
External Traffic Policy:  Cluster
</code></pre>
<p><strong>configmap</strong></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ext-nginx-ingress
data:
  3306: ext-nginx-ingress/mysql-svc:3306
</code></pre>
<p>Accessible by telnet 80 port but not by mysql client.</p>
<pre><code>telnet mysql.*****.com 80                          
Trying 3.******...
Connected to mysql.******.com.
</code></pre>
<p><strong>Of the target groups associated with nlb, the node port associated with 3306 ports is in the unhealthy state.</strong></p>
<pre><code>Port:                     proxie-tcp-mysql  3306/TCP
TargetPort:               mysql/TCP
NodePort:                 proxie-tcp-mysql  32514/TCP
</code></pre>
<p>Thank you for reading.
MYSQL Pod and Service create well endpoint.</p>

loanshark
<blockquote>
<p>I want to use mysql client and access the database via Nginx Ingress.</p>
</blockquote>
<p>You can't.  Nginx is an HTTP server, but MySQL speaks its own binary protocol over TCP.</p>
<p>Typically you wouldn't want your database to be published outside the cluster at all, since anyone who can access the database can bypass basically all checks and restrictions in your applications.  Set up a ClusterIP Service for the database, and if you do need to connect to it as an operator, use <code>kubectl port-forward</code> to connect to it.</p>
<p>If you really do need it published outside the cluster, you need to use a NodePort or LoadBalancer Service.  Since it's not an HTTP service it can't use the Kubernetes ingress system.</p>
