无法从主机连接到无根 mariadb pod

问题描述 投票:0回答:1

我有以下 mariadb-kube.yaml

apiVersion: v1
kind: Pod
metadata:
  name: mariadb-pod
  labels:
    app: mariadb
spec:
  containers:
    - name: test-mariadb
      image: mariadb:latest
      env:
        - name: MYSQL_ROOT_PASSWORD
          value: testpwd
      ports:
        - containerPort: 3306
        - hostPort: 33066
podman play kube mariadb-kube.yaml

然后我尝试从容器内部进行连接:

podman exec -it mariadb-pod-test-mariadb bash -c 'mariadb -h127.0.0.1 -uroot -p'

效果很好:

MariaDB [(none)]> select user, host FROM mysql.user;
+-------------+-----------+
| User        | Host      |
+-------------+-----------+
| root        | %         |
| healthcheck | 127.0.0.1 |
| healthcheck | ::1       |
| healthcheck | localhost |
| mariadb.sys | localhost |
| root        | localhost |
+-------------+-----------+

root@mariadb-pod:/# ss -tuln
Netid             State              Recv-Q             Send-Q                         Local Address:Port                         Peer Address:Port             Process             
tcp               LISTEN             0                  0                                    0.0.0.0:3306                              0.0.0.0:*                                    
tcp               LISTEN             0                  0                                          *:3306                                    *:* 

33066也已开通:

nmap -p 33066 127.0.0.1
Starting Nmap 7.92 ( https://nmap.org ) at 2024-10-08 05:13 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00029s latency).

PORT      STATE SERVICE
33066/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.02 seconds

但是,如果我尝试从主机连接,它会显示:

mysql -vvv -h127.0.0.1 -uroot -P33066 -p
Enter password: 
ERROR 2013 (HY000): Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 11
mariadb podman
1个回答
0
投票

啊,愚蠢的错误:

- hostPort: 33066

额外

-
使其成为不同的项目...

© www.soinside.com 2019 - 2024. All rights reserved.