In this article you will learn how to prepare your Kubernetes server for use.
This article assumes your HostDime Cloud virtual machine or bare-metal server was deployed with one of our Kubernetes-ready images.
Some commands below will need to be run as the root user, others will need to be run as the kadmin user. Each block of commands to be run will note which user should run those commands.
You may want to execute the whoami command before running anything below to be certain you're active as the correct user.
Deploying the Master Node
If you're creating a brand new Kubernetes cluster you need to initialize at least one Kubernetes master node.
This can be accomplished by running the following commands on the VM or bare-metal server you wish to use as the master.
- Use kubeadm to initalize the master node and create the internal network used by the worker nodes and pods to communicate with the master node.
In this example we're going to be using the Flannel overlay network which requires the network addressing scheme shown here.
Make note of the output of this command. It will contain some information on how to join worker nodes to the cluster.
- This step is optional if you plan to administer this cluster remotely with kubectl. You should now create a password for the kadmin user and then create a Kubernetes config file for the user.
As root, create the kadmin user password and then descend to the kadmin user account in preparation for creating a Kubernetes configuration.
Now you will be running as the kadmin user and you can execute the following to create a configuration file.
Now create the network as the root user.
Joining a Worker Node to the Cluster
Now that you have your Kubernetes master created, it's time to join a worker node to the master to create your cluster.
This is as simple as running the command below and replace the
$token, $ip:port and
$cert-hash sections with the information provided to you from the output of kubeadm init when you created your master node (step 1a):
You can run
kubectl get nodes on the Kubernetes master node (if you configured kubectl for the kadmin user) or any workstation you have the kubectl context pointed to this cluster to watch the progress of the node(s) joining your cluster.