我目前正在尝试通过创建一个Vagrant / Ansible项目来学习Kubernetes,这个项目允许我调出一个主节点和节点,并且我遇到了一些问题。我目前正在使用kubeadm
来运行init
和join
功能。对于init
,我正在解析命令行输出以获取令牌(我知道这很糟糕;是否有更标准的方法来执行此操作?):
---
- command: kubeadm init
args:
creates: /etc/kubernetes/kubelet.conf
register: kube_init
- local_action: copy content={{ kube_init.stdout_lines[-1].split()[-2] }} dest=../kube.token
when: kube_init is defined
- local_action: copy content={{ kube_init.stdout_lines[-1].split()[-1] }} dest=../kube.master_ip
when: kube_init is defined
但它有效。麻烦的是,我无法连接节点:
TASK: [node | command kubeadm join --token=1a3131.637de46bfdebadd4 10.0.2.15] ***
failed: [node1] => {"changed": true, "cmd": ["kubeadm", "join", "--token=1a3131.637de46bfdebadd4", "10.0.2.15"], "delta": "0:00:00.079545", "end": "2016-10-25 01:54:51.858545", "rc": 1, "start": "2016-10-25 01:54:51.779000", "warnings": []}
stderr: error: <node/discovery> failed to request cluster info [Get http://10.0.2.15:9898/cluster-info/v1/?token-id=1a3131: dial tcp 10.0.2.15:9898: getsockopt: connection refused]
stdout: <util/tokens> validating provided token
<node/discovery> created cluster info discovery client, requesting info from "http://10.0.2.15:9898/cluster-info/v1/?token-id=1a3131"
FATAL: all hosts have already failed -- aborting
我可以从节点VM ping我的主VM,我甚至可以ssh到它。似乎kubernetes服务也在主服务器上运行:
$ systemctl status kubelet.service
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: active (running) since Tue 2016-10-25 01:51:35 UTC; 13h ago
Docs: http://kubernetes.io/docs/
Main PID: 5726 (kubelet)
Tasks: 15
Memory: 45.5M
CPU: 11min 37.179s
CGroup: /system.slice/kubelet.service
├─5726 /usr/bin/kubelet --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin --cluster-
└─5740 journalctl -k -f
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532171 5726 factory.go:108] Factory "systemd" can handle container "/system.slice/var-lib-kubelet-pods-9d0e93cd\\x2d9a55\\x2d11e6\\x2db2dd\\x2d02558d159192-volumes-kubernetes.io\\x7esecret-default\\
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532175 5726 manager.go:843] ignoring container "/system.slice/var-lib-kubelet-pods-9d0e93cd\\x2d9a55\\x2d11e6\\x2db2dd\\x2d02558d159192-volumes-kubernetes.io\\x7esecret-default\\x2dtoken\\x2ddn3r9.m
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532184 5726 factory.go:104] Error trying to work out if we can handle /system.slice/run-docker-netns-default.mount: invalid container name
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532187 5726 factory.go:115] Factory "docker" was unable to handle container "/system.slice/run-docker-netns-default.mount"
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532190 5726 factory.go:108] Factory "systemd" can handle container "/system.slice/run-docker-netns-default.mount", but ignoring.
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532194 5726 manager.go:843] ignoring container "/system.slice/run-docker-netns-default.mount"
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532316 5726 factory.go:104] Error trying to work out if we can handle /system.slice/var-lib-docker-overlay-6d625f0d241bc6ae9eb243b430a71f078912a76147fc51e41e8e6e5f3226c6e9-merged.mount: error inspec
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532321 5726 factory.go:115] Factory "docker" was unable to handle container "/system.slice/var-lib-docker-overlay-6d625f0d241bc6ae9eb243b430a71f078912a76147fc51e41e8e6e5f3226c6e9-merged.mount"
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532325 5726 factory.go:108] Factory "systemd" can handle container "/system.slice/var-lib-docker-overlay-6d625f0d241bc6ae9eb243b430a71f078912a76147fc51e41e8e6e5f3226c6e9-merged.mount", but ignoring.
Oct 25 15:43:35 ubuntu-xenial kubelet[5726]: I1025 15:43:35.532330 5726 manager.go:843] ignoring container "/system.slice/var-lib-docker-overlay-6d625f0d241bc6ae9eb243b430a71f078912a76147fc51e41e8e6e5f3226c6e9-merged.mount"
为什么我的主人不听连接?这是我正在使用的确切提交:
https://gitlab.com/djsumdog/skube/tree/0e25fca668e1067a8aa4af59b019411303838e86
如果你安装了ansible和vagrant,你应该可以运行vagrant up
并获得相同的结果。
答案 0 :(得分:2)
事实证明这是由于我的Vagrant设置。两个虚拟机都获得了相同的IP地址。我需要在我的Vagrantfile中指定:private_network
和ip:
:
...
config.vm.define "master" do |master|
master.vm.network :private_network, ip: 10.10.30.10
...
...
config.vm.define "node1" do |node1|
node1.vm.network :private_network, :ip: 10.10.30.50
...
答案 1 :(得分:-1)
尝试在 kubeadm init 之后和 kubeadm join 之前执行以下命令
<select >
<?php
$args = array( 'post_type'=>'post');
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<option value="<?php the_ID();?>"><?php the_title(); ?></option>
<?php endforeach;
wp_reset_postdata();?>
</select>
请参阅此页http://kubernetes.io/docs/getting-started-guides/kubeadm/