Kubernetes - 无法使用云提供商 openstack 启动 kubelet(从云提供商获取当前节点名称时出错)
Kubernetes - unable to start kubelet with cloud provider openstack (error fetching current node name from cloud provider)
我正在尝试在 Rackspace 中设置 Kubernetes 集群,我知道要获得持久卷支持,我需要使用 Cinder(Rackspace 支持的 Openstack)。
按照 Cloud Provider Integrations setup 指南,我设置 /etc/kubernetes/cloud-config
如下
[Global]
username=cinder
password=********
auth-url=https://identity.api.rackspacecloud.com/v2.0
tenant-name=1234567
region=LON
我在 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
中的 kubelet 启动命令中添加了以下内容
--cloud-provider=openstack --cloud-config=/etc/kubernetes/cloud-config
然后我 运行 kubeadm init --config=kubeadm.conf
其中 kubeadm.conf 是:
kind: MasterConfiguration
apiVersion: kubeadm.k8s.io/v1alpha1
cloudProvider: openstack
pod-network-cidr: 10.244.0.0/16
等待kubelet启动失败。我追踪到以下 kubelet 错误:
07:24:51.407692 21412 feature_gate.go:156] feature gates: map[]
07:24:51.407790 21412 controller.go:114] kubelet config controller: starting controller
07:24:51.407849 21412 controller.go:118] kubelet config controller: validating combination of defaults and flags
07:24:51.413973 21412 mount_linux.go:168] Detected OS with systemd
07:24:51.414065 21412 client.go:75] Connecting to docker on unix:///var/run/docker.sock
07:24:51.414137 21412 client.go:95] Start docker client with request timeout=2m0s
07:24:51.415471 21412 cni.go:196] Unable to update cni config: No networks found in /etc/cni/net.d
07:24:51.437924 21412 iptables.go:564] couldn't get iptables-restore version; assuming it doesn't support --wait
07:24:51.440245 21412 feature_gate.go:156] feature gates: map[]
07:24:52.066765 21412 server.go:301] Successfully initialized cloud provider: "openstack" from the config file: "/etc/kubernetes/cloud-config"
07:24:52.066984 21412 openstack_instances.go:39] openstack.Instances() called
07:24:52.067048 21412 openstack_instances.go:46] Claiming to support Instances
07:24:52.070870 21412 metadata.go:84] Unable to run blkid: exit status 2
07:24:52.070993 21412 metadata.go:124] Attempting to fetch metadata from http://169.254.169.254/openstack/2012-08-10/meta_data.json
07:25:22.071444 21412 metadata.go:127] Cannot read http://169.254.169.254/openstack/2012-08-10/meta_data.json: Get http://169.254.169.254/openstack/2012-08-10/meta_data.json: dial tcp 169.254.169.254:80: i/o timeout
error: failed to run Kubelet: error fetching current node name from cloud provider: Get http://169.254.169.254/openstack/2012-08-10/meta_data.json: dial tcp 169.254.169.254:80: i/o timeout
我该如何进一步调试呢?我真的不明白 IP 地址 169.254.169.254 在这个请求中是如何工作的。
现在我无法判断是 Kubernetes 问题还是 Rackspace 问题。
答案是Rackspace Cloud 不使用Openstack 元数据服务。相反,它使用 cloud-init 和 config-drive - 一个在启动时附加的只读块设备(虚拟 CD-ROM)。
配置驱动器包含云初始化数据。示例 https://developer.rackspace.com/blog/using-cloud-init-with-rackspace-cloud/
有趣的是,似乎大多数使用 Kubernetes 的 Rackspace 客户都使用支持云配置和 Openstack 配置驱动器的 CoreOS VM。当 K8s 在安装了驱动器的机器上运行时,它会尝试从那里获取元数据。
根据此 link,您需要将 cloud-config 文件放入 /etc/kubernetes/pki。我已经尝试过这种方法并且有效。
我正在尝试在 Rackspace 中设置 Kubernetes 集群,我知道要获得持久卷支持,我需要使用 Cinder(Rackspace 支持的 Openstack)。
按照 Cloud Provider Integrations setup 指南,我设置 /etc/kubernetes/cloud-config
如下
[Global]
username=cinder
password=********
auth-url=https://identity.api.rackspacecloud.com/v2.0
tenant-name=1234567
region=LON
我在 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
--cloud-provider=openstack --cloud-config=/etc/kubernetes/cloud-config
然后我 运行 kubeadm init --config=kubeadm.conf
其中 kubeadm.conf 是:
kind: MasterConfiguration
apiVersion: kubeadm.k8s.io/v1alpha1
cloudProvider: openstack
pod-network-cidr: 10.244.0.0/16
等待kubelet启动失败。我追踪到以下 kubelet 错误:
07:24:51.407692 21412 feature_gate.go:156] feature gates: map[]
07:24:51.407790 21412 controller.go:114] kubelet config controller: starting controller
07:24:51.407849 21412 controller.go:118] kubelet config controller: validating combination of defaults and flags
07:24:51.413973 21412 mount_linux.go:168] Detected OS with systemd
07:24:51.414065 21412 client.go:75] Connecting to docker on unix:///var/run/docker.sock
07:24:51.414137 21412 client.go:95] Start docker client with request timeout=2m0s
07:24:51.415471 21412 cni.go:196] Unable to update cni config: No networks found in /etc/cni/net.d
07:24:51.437924 21412 iptables.go:564] couldn't get iptables-restore version; assuming it doesn't support --wait
07:24:51.440245 21412 feature_gate.go:156] feature gates: map[]
07:24:52.066765 21412 server.go:301] Successfully initialized cloud provider: "openstack" from the config file: "/etc/kubernetes/cloud-config"
07:24:52.066984 21412 openstack_instances.go:39] openstack.Instances() called
07:24:52.067048 21412 openstack_instances.go:46] Claiming to support Instances
07:24:52.070870 21412 metadata.go:84] Unable to run blkid: exit status 2
07:24:52.070993 21412 metadata.go:124] Attempting to fetch metadata from http://169.254.169.254/openstack/2012-08-10/meta_data.json
07:25:22.071444 21412 metadata.go:127] Cannot read http://169.254.169.254/openstack/2012-08-10/meta_data.json: Get http://169.254.169.254/openstack/2012-08-10/meta_data.json: dial tcp 169.254.169.254:80: i/o timeout
error: failed to run Kubelet: error fetching current node name from cloud provider: Get http://169.254.169.254/openstack/2012-08-10/meta_data.json: dial tcp 169.254.169.254:80: i/o timeout
我该如何进一步调试呢?我真的不明白 IP 地址 169.254.169.254 在这个请求中是如何工作的。
现在我无法判断是 Kubernetes 问题还是 Rackspace 问题。
答案是Rackspace Cloud 不使用Openstack 元数据服务。相反,它使用 cloud-init 和 config-drive - 一个在启动时附加的只读块设备(虚拟 CD-ROM)。
配置驱动器包含云初始化数据。示例 https://developer.rackspace.com/blog/using-cloud-init-with-rackspace-cloud/
有趣的是,似乎大多数使用 Kubernetes 的 Rackspace 客户都使用支持云配置和 Openstack 配置驱动器的 CoreOS VM。当 K8s 在安装了驱动器的机器上运行时,它会尝试从那里获取元数据。
根据此 link,您需要将 cloud-config 文件放入 /etc/kubernetes/pki。我已经尝试过这种方法并且有效。