我正在尝试使用terraform部署“硬方式”来部署k8s。请在这里找到回购:https://github.com/aidanSoles/kubernetes-the-hard-way-terraform
它是使用Terraform0.11编写的,所以我选择不将代码升级到0.12。
这个部署创建了Google平台虚拟机,并尝试在它们上运行脚本。
应用配置时收到的错误消息是:
Error: Error applying plan:
2 errors occurred:
* google_compute_instance.k8s_worker: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
* google_compute_instance.k8s_controller: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain下面是google_compute_instance提供程序的一个片段:
resource "google_compute_instance" "k8s_controller" {
boot_disk {
auto_delete = true
initialize_params {
image = "${var.controller_image}"
size = "${var.controller_size}"
}
}
can_ip_forward = true
count = "${var.controller_count}"
machine_type = "${var.controller_type}"
name = "k8s-controller${count.index}"
network_interface {
access_config = {}
subnetwork = "${google_compute_subnetwork.k8s_subnet.name}"
}
metadata {
creator = "${var.user}"
}
provisioner "file" {
connection {
private_key = "${file(var.ssh_path)}"
user = "${var.user}"
type = "ssh"
}
destination = "add-ssh-keys.sh"
source = "${var.scripts_path}/add-ssh-keys.sh"
}
}您可以在这里找到完整的脚本:https://github.com/aidanSoles/kubernetes-the-hard-way-terraform/blob/master/compute.tf
我通过执行user和ssh_path变量值来确保ssh -i是正确的。我还尝试将agent = false参数添加到文件提供程序中,但没有结果。
你知道这个问题的根源是什么吗?非常感谢。
发布于 2019-12-02 12:11:16
关于文档的:
我已经遵循了指南,并确认它是有效的。
我已经用terraform-0.11.14尝试过了。目前看来,配置文件与terraform 0.12不兼容。
关于错误的:
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain请检查以下内容:
<username>@<hostname>组合与您在第5步中提供的公钥中的组合相匹配,请创建一个服务帐户。您可以通过hostname和whoami命令获得这些信息。
$ whoami &主机名超人my_pc $ cat ~/..ssh/tform_rsa.PUB\ awk '{print $3}‘superman@my_pc
只有在输入我粘贴在GCP上的元数据/SSH键下的公钥时,我才能成功地再现完全相同的症状。这就是为什么您在variables.tf中指定的私钥与上传到GCP的公钥之间存在错误或不匹配的原因。希望这有帮助:)
https://stackoverflow.com/questions/58972470
复制相似问题