如何运行一个单机为主节点的Kubernetes集群?

How can I run a Kubernetes cluster with a single machine as a master and node?

我正在尝试在本地设置 Kubernetes。

我刚刚 运行 kubeadm init,它为我提供了一个 join 命令,但我似乎无法加入同一台机器上的集群。由于 运行ning 提供的加入命令导致:

[preflight] Running pre-flight checks.
    [WARNING FileExisting-crictl]: crictl not found in system path
[preflight] Some fatal errors occurred:
    [ERROR Port-10250]: Port 10250 is in use
    [ERROR DirAvailable--etc-kubernetes-manifests]: /etc/kubernetes/manifests is not empty
    [ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
    [ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

这可能吗?如果有怎么办?

这是出于生产目的,我知道 minikube,但我想调查一下如果没有它是否可行(我想 运行 虚拟机的开销会更少)。

我找到了这个项目:https://github.com/vtuson/k8single

https://github.com/vtuson/k8single/blob/e92132a7221930f160959f50f836fa3e7348d36e/kubeform_adm.sh 此脚本以及:

kubectl get no -w   --> wait until the master node is ready
kubectl get po --all-namespaces --> check that all pods have come up ok

我设法用上面的方法解决了这个问题。

我建议使用 kubeadm 来配置主服务器,然后删除导致主服务器无法为正常工作负载安排的污点。如果您需要,可以为您的未来扩展提供极大的灵活性,并且它是 kube comuunity 中成熟的工具。