Spring Cloud Config docker化到Kubernetes的一些坑

最近将Config docker化,部署到Kubernetes的过程中,遇到配置文件拿不到的问题。发现如果是github可以拿到,但是换成私有的仓库gitlab.xxx.com就拿不到。

通过将git url直接写成ip地址,避免host映射出现错误;还有将SSH的配置挂载到镜像里,还是拿不到配置文件。最后通过搜索发现官方文档里有这样一句话:

It is important that an entry for the Git server be present in the ~/.ssh/known_hosts file and that it is in ssh-rsa format. Other formats (like ecdsa-sha2-nistp256) are not supported.

通过查看known_hosts文件,发现连接github用的是ssh_rsa, 而gitlab.xxx.com是ecdsa-sha2-nistp256。所以为了强制将连接gitlab.xxx.com的签名类型换成ssh-rsa,首先删掉known_hosts对应的记录,在~/.ssh/config和/etc/ssh/ssh_config中添加:

Host 192.168.58.6
 RSAAuthentication yes
 HostKeyAlgorithms ssh-rsa
 Hostname 192.168.58.6
 Port 2222
 User xxx
 IdentityFile /root/.ssh/id_rsa

尝试ssh -T git@192.168.58.6后,连接类型就变成ssh-rsa。配置文件就拿到了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容