How to use a docker container as a node for a cluster in Kubernetes

12/7/2021

I am trying to learn Kubernetes and I came across this command kubectl create -f node.yml where I can use this to create nodes too. According to the documentation, it looks something like this.

{
  "kind": "Node",
  "apiVersion": "v1",
  "metadata": {
    "name": "10.240.79.157",
    "labels": {
      "name": "my-first-k8s-node"
    }
  }
}

Now, here's the question, what if I wanted to add an existing machine as a node? If I simply run this file, it will create a node that has no CPU or other resources, and hence it will be practically useless.

But let's say I create a docker container running ubuntu which I wish to use as a node in the cluster. How can I achieve this?

I am using minikube for now and it gives me an option to do it by minikube start --nodes 2 -p multinode-demo but I wish to do with a YAML file.

Any help or insight is appreciated!

-- Van Wilder
kubernetes
minikube

0 Answers