【问题标题】:How to join worker node in my gcp cluster如何在我的 gcp 集群中加入工作节点
【发布时间】:2021-03-19 08:18:04
【问题描述】:

我正在尝试创建自己的 k8s 集群以用于培训目的。我已经用 kubedam 安装了 kubernetes,我的主节点已经准备好了:

NAME       STATUS   ROLES    AGE   VERSION
master-1   Ready    master   54s   v1.19.4

现在我正在尝试使用 kubeadm init 末尾给出的令牌加入我的工作实例,但是当我执行命令时出现此错误:

sudo kubeadm join my-master-node-ip-here:6443 --token xxxx.xxxxxxxxxxxx \
    --discovery-token-ca-cert-hash sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

错误:

[preflight] Running pre-flight checks
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
        [WARNING SystemVerification]: missing optional cgroups: hugetlb
error execution phase preflight: couldn't validate the identity of the API Server: Get "https://my-master-node-ip-here:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s": net/http: request canceled
 while waiting for connection (Client.Timeout exceeded while awaiting headers)
To see the stack trace of this error execute with --v=5 or higher

我在 Pod 网络中使用了 Weave

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

而使用 Terraform,这两个实例位于名为 k8s-node 的同一 VPC 中

network.tf

resource "google_compute_network" "vpc_network" {
  name = "k8s-node"
}

# We create a public IP address for our google compute instance to utilize
resource "google_compute_address" "static" {
  name = "vm-public-address"
}

instance.tf

resource "google_compute_instance" "default" {
    name = var.vm_name
    machine_type = "e2-standard-2"
    zone = "europe-west1-b"

    boot_disk {
        initialize_params {
            image = "debian-cloud/debian-9"
        }
    }

    network_interface {
        network = var.network
        access_config {
            // Include this section to give the VM an external IP address
        }
    }

    metadata_startup_script = file("./scripts/bootstrap.sh")

    tags = ["node"]
}

worker 似乎无法连接到 master 实例,我的配置中是否遗漏了什么?

【问题讨论】:

  • 听起来像是内部网络错误。 This may be related.
  • @ingernet 谢谢,其实这是相关的,是防火墙问题

标签: kubernetes terraform google-kubernetes-engine terraform-provider-gcp


【解决方案1】:

为了解决这个问题,我在 teraform 中添加了防火墙规则并打开了端口6443

resource "google_compute_network" "vpc_network" {
  name = "k8s-node"
}

resource "google_compute_firewall" "default" {
  name    = "k8s-firewall"
  network = google_compute_network.vpc_network.name

  allow {
    protocol = "icmp"
  }

  allow {
    protocol = "tcp"
    ports    = ["80", "6443"]
  }

  source_tags = ["node"]
}

【讨论】:

    猜你喜欢
    • 2019-10-22
    • 2022-11-01
    • 1970-01-01
    • 2013-04-24
    • 1970-01-01
    • 2019-01-28
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    相关资源
    最近更新 更多