3

我遇到了一个问题,公开在 kubernetes 集群中运行的 mysql 数据库。集群在 AWS 上使用 kops 运行。我为 nginx-ingress 使用 helm 图表: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

从集群内部,我可以通过 nginx 通过端口 5000 远程登录到数据库:

# 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 上的任何地方进行连接。

更新

当我使用端口 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 helm 图表:

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

4

0 回答 0