Search code examples
kuberneteskubectl

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


I'm trying to setup Kubernetes locally.

I've just run kubeadm init, and it's provided me with a join command, however it seems I can't join the cluster on the same machine. As running the provided join command results in:

[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=...`

Is this possible? If so how?

This is for production purposes, I'm aware of minikube but I'd like to investigate if this is possible without it (less overhead of needing to run a VM also I'd imagine).


Solution

  • I found this project: https://github.com/vtuson/k8single

    https://github.com/vtuson/k8single/blob/e92132a7221930f160959f50f836fa3e7348d36e/kubeform_adm.sh this script along with:

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

    I managed to solve this with the above.