我遇到了一个公开在kubernetes集群中运行的mysql数据库的问题 . 群集在AWS上使用kops运行 . 我使用舵图表进行nginx-ingress:https://github.com/helm/charts/tree/master/stable/nginx-ingress

controller:
  config:
    use-proxy-protocol: "true"
  metrics:
    enabled: true
  replicaCount: 2
  service:
    annotations:
      service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*'
  stats:
    enabled: true
rbac:
  create: true
tcp:
  5000: default/cbioportal-prod-db-mysql:3306

在集群内,我可以通过端口5000通过nginx telnet到db:

# telnet eating-dingo-nginx-ingress-controller 5000
J
5.7.14
      ke_|c&tc"ui%]}mysql_native_passwordConnection closed by foreign host

但我似乎无法使用aws负载均衡器的主机名从外部连接 .

telnet xxx.us-east-1.elb.amazonaws.com 5000
Trying x.x.x.x...

当我查看aws ec2仪表板时,我看到负载均衡器的安全组允许来自端口5000上的任何地方的连接 .

UPDATE

当我使用端口3306而不是5000时,我可以连接:

tcp:
  3306: default/cbioportal-prod-db-mysql:3306

但是现在端口是打开的:

$ nmap --verbose  -Pn x.x.x.x
PORT     STATE SERVICE
21/tcp   open  ftp
80/tcp   open  http
443/tcp  open  https
3306/tcp open  mysql

我收到授权问题:

$ mysql -h x.x.x.x  -uroot -pabcdef
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 2

我可以直接连接到nginx控制器,而不会在集群中出现问题:

kubectl run -it --rm --image=mysql:5.7 --restart=Never mysql-client -- mysql -h eating-dingo-nginx-ingress-controller  -uroot -pabcdef

我正在使用这个mysql头盔图:

https://github.com/helm/charts/tree/master/stable/mysql