kuberneteskind

Can not create the most simple kubernetes cluster because of incorrect apiVersion for kind


I am following this guide to create a simple kubernetes cluster on my machine: https://www.appvia.io/blog/tutorial-deploy-kubernetes-cluster

When trying to run kind create cluster --name mycluster --config config/kind.config.yaml --wait 5m

I am always getting error:

Creating cluster "kind" ...

ERROR: failed to create cluster: could not determine kind / apiVersion for config: yaml: line 4: did not find expected key

I have tried so many different apiVersion for kind:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
 extraPortMappings:
 - containerPort: 30080
   hostPort: 80
   listenAddress: "0.0.0.0"
   protocol: TCP

And still nothing. What is the correct apiVersion for kind ? How to start it?

[root@grpc-collector config]# kind version kind v0.8.1 go1.14.2 linux/amd64


Solution

  • The error message is kinda misleading here, you just didn't intend your YAML file properly.

    This is a common issue and happens quite easily when writing k8s YAML files without IDE support. Try with this correctly intended version

    kind: Cluster
    apiVersion: kind.x-k8s.io/v1alpha4
    nodes:
      - role: control-plane
        extraPortMappings:
          - containerPort: 30080
            hostPort: 80
            listenAddress: "0.0.0.0"
            protocol: TCP