Creating the Cluster Configuration File

RKE uses a cluster configuration file, referred to as cluster.yml to determine what nodes will be in the cluster and how to deploy Kubernetes. There are many configuration options that can be set in the cluster.yml. In our example, we will be assuming the minimum of one node for your Kubernetes cluster.

Using rke config

Run rke config to create a new cluster.yml in the current directory. This command will prompt you for all the information needed to build a cluster. See cluster configuration options for details on the various options.

rke config --name cluster.yml

Creating an Empty cluster.yml

You can create an empty template cluster.yml file by specifying the --empty flag.

rke config --empty --name cluster.yml

Printing the cluster.yml

Instead of creating a file, you can print the generated configuration to stdout using the --print flag.

rke config --print

High Availability

RKE is HA ready, you can specify more than one controlplane node in the cluster.yml file. RKE will deploy master components on all of these nodes and the kubelets are configured to connect to 127.0.0.1:6443 by default which is the address of nginx-proxy service that proxy requests to all master nodes.

To create an HA cluster, specify more than one host with role controlplane.

Deploying Kubernetes with RKE

After you’ve created your cluster.yml, you can deploy your cluster with a simple command. This command assumes the cluster.yml file is in the same directory as where you are running the command.

The last line should read Finished building Kubernetes cluster successfully to indicate that your cluster is ready to use. As part of the Kubernetes creation process, a kubeconfig file has been created and written at kube_config_cluster.yml, which can be used to start interacting with your Kubernetes cluster.

Note: If you have used a different file name from cluster.yml, then the kube config file will be named kube_config_<FILE_NAME>.yml.

Interacting with your Kubernetes cluster

In order to start interacting with your Kubernetes cluster, you will use a different binary called kubectl. You will need to install kubectl on your local machine. You can connect to the RKE created cluster by using the kube_config_cluster.yml that was generated when you deployed Kubernetes.

Confirm that kubectl is working by checking the version of your Kubernetes cluster

The client and server version are reported, indicating that you have a local kubectl client and are able to request the server version from the newly built cluster. Now, you can issue any kubectl command to your cluster, like requesting the nodes that are in the cluster.