title: How to access MySql hosted with Nginx Ingress+Kubernetes from client
body: <p>I am new to Kubernetes and Nginx Ingress tools and now i am trying to host MySql service using VHost in Nginx Ingress on AWS. I have created a file something like :</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: mysql
    labels:
      app: mysql
  spec:
    type: NodePort
    ports:
      - port: 3306
        protocol: TCP
    selector:
      app: mysql
  ---
  apiVersion: apps/v1beta2
  kind: Deployment
  metadata:
    name: mysql
    labels:
      app: mysql
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: mysql
    template:
      metadata:
        labels:
          app: mysql
      spec:
        containers:
          - name: mysql
            image: mysql
            imagePullPolicy: IfNotPresent
            env:
              - name: MYSQL_ROOT_PASSWORD
                value: password
            ports:
              - name: http
                containerPort: 3306
                protocol: TCP
  ---
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: mysql
    labels:
      app: mysql
    annotations:
      kubernetes.io/ingress.class: "nginx"
  spec:
    rules:
      - host: mysql.example.com
        http:
          paths:
            - path: /
              backend:
                serviceName: mysql
                servicePort: 3306
  </code></pre>
  
  <p>My LoadBalancer (created by Nginx Ingress) port configuration looks like :</p>
  
  <pre><code>80 (TCP) forwarding to 32078 (TCP)
  Stickiness options not available for TCP protocols
  
  443 (TCP) forwarding to 31480 (TCP)
  Stickiness options not available for TCP protocols
  </code></pre>
  
  <p><strong>mysql.example.com</strong> is pointing to my ELB.</p>
  
  <p>I was expecting something like, from my local box i can connect to MySql if try something like :</p>
  
  <pre><code>mysql -h mysql.example.com -u root -P 80 -p
  </code></pre>
  
  <p>Which is not working out. Instead of <strong>NodePort</strong> if i try with <strong>LoadBalancer</strong>, its creating a new ELB for me which is working as expected. </p>
  
  <p>I am not sure if this is right approach for what i want to achieve here. Please help me out if there is a way for achieving same using the Ingress with NodePort. </p>