使用 Altinity Kubernetes Operator 在 k8s 集群上部署 ClickHouse,部署后在 clickhouse pod 中通过 clickhouse-client 可以正常连接
而在其他 pod 中用 clickhouse-client 连接却提示验证失败
Code: 516. DB::Exception: Received from chi-clickhouse-db-analytics-0-0.clickhouse:9000, 192.168.26.13. DB::Exception: admin: Authentication failed: password is incorrect, or there is no user with such name..
进入 pod 查看 clickhouse 的配置
kubectl exec -it chi-clickhouse-db-analytics-0-0-0 -n clickhouse -- /bin/bash
cat /etc/clickhouse-server/users.d/chop-generated-users.xml
发现 networks 配置中只允许本机地址访问
<yandex>
<users>
<default>
<networks>
<host_regexp>(chi-clickhouse-db-[^.]+\d+-\d+|clickhouse\-clickhouse-db)\.clickhouse\.svc\.cluster\.local$</host_regexp>
<ip>::1</ip>
<ip>127.0.0.1</ip>
<ip>192.168.26.13</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
</default>
</users>
</yandex>
在 Altinity Kubernetes Operator 的部署清单中添加 networks/ip
配置允许所有IP地址访问解决了
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
spec:
configuration:
users:
admin/networks/ip:
- 0.0.0.0/0