Terraform-无法为主机设置SSH隧道



见鬼,我正试图用terraform部署rke k8s,但我无法通过ssh:连接到所需的主机

time="2022-02-28T11:17:38+01:00" level=warning msg="Failed to set up SSH tunneling for host [poc-k8s.my-domain.com]: Can't retrieve Docker Info: error during connect: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": Unable to access node with address [poc-k8s.my-domain.com:22] using SSH. Please check if you are able to SSH to the node using the specified SSH Private Key and if you have configured the correct SSH username. Error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain"

这就是我正在使用的.tf文件:

terraform {
required_providers {
rke = {
source = "rancher/rke"
version = "1.3.0"
}
}
}
provider "rke" {
log_file = "rke_debug.log"
}

resource "rke_cluster" "cluster" {
nodes {
address = "poc-k8s.my-domain.com"
user    = "root"
role    = ["controlplane", "worker", "etcd"]
ssh_key = file("~/.ssh/root_key")
}
nodes {
address = "poc-k8s.my-domain.com"
user    = "root"
role    = ["worker", "etcd"]
ssh_key = file("~/.ssh/root_key")
}
addons_include = [
"https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml",
"https://gist.githubusercontent.com/superseb/499f2caa2637c404af41cfb7e5f4a938/raw/930841ac00653fdff8beca61dab9a20bb8983782/k8s-dashboard-user.yml",
]
}
resource "local_file" "kube_cluster_yaml" {
filename = "~/.kube/kube_config_cluster.yml"
sensitive_content  = "rke_cluster.cluster.kube_config_yaml"
}

如果密钥当然正确,并且我能够连接到所需的主机:

ssh -i ~/.ssh/root_key root@poc-k8s.my-domain.com

我在这里错过了什么?

[更新]

群集资源具有可用于的delay_on_creation属性

resource "rke_cluster" "cluster" {
delay_on_creation = 180     
(...)
}

我也面临类似的问题。在第二次运行terrafor应用程序时,它工作正常。在我的案例中,问题是docker对RKE提供商来说不够快。

我从城市网络找到了以下解决方法/城市云示例:

resource "rke_cluster" "cluster" {     
(...)
depends_on = [null_resource.wait-for-docker]
}
resource "null_resource" "wait-for-docker" {
provisioner "local-exec" {
command = "sleep 180"
}
depends_on = [
# list of servers docker being installed on
(...) 
]
}

它等待180年代,但这并不理想。

相关内容

  • 没有找到相关文章

最新更新