无论是ubuntu还是centos,都一样的。
目前使用3个机子来部署, 一个master, 两个node
首先要解决的是访问google的网络问题。
按照该篇文章 依次发布
里面有几个坑的是:
在第4步,不需要重启kubelet, 因为在kubeadm init中会自己创建/var/lib/kubelet/config.yaml配置文件等等相关的信息,并且在kubeadm init时会自动启动该服务。
在第5步,也不需要建立自己的配置文件。
在ubuntu系统中的启动配置文件/etc/systemd/system/kubelet.service.d/10-kubeadm.conf的内容应该如下:
# Note: This dropin only works with kubeadm and kubelet v1.11+ [Service] Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs" Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --fail-swap-on=false" # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. EnvironmentFile=-/etc/default/kubelet ExecStart= ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS $KUBELET_CGROUP_ARGS $KUBELET_SWAP_ARGS $KUBELET_SYSTEM_PODS_ARGS
然后就可以在master上进行:# kubeadm init
我使用的是默认的最新版本的k8s, 在发布flannel网络的时候使用如下的命令:
sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
在node上按照init成功的提示执行:
sudo kubeadm join --token TOKEN MASTER_IP:6443