Making use of your Kubernetes-ready Ubuntu Server

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.

  1. 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.
    1. In this example we're going to be using the Flannel overlay network which requires the network addressing scheme shown here.

      kubeadm init --pod-network-cidr=

      Make note of the output of this command. It will contain some information on how to join worker nodes to the cluster.

  2. 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.
    1. As root, create the kadmin user password and then descend to the kadmin user account in preparation for creating a Kubernetes configuration.

      Run the following as the ROOT user:
      passwd kadmin
      su -s /bin/bash - kadmin
    2. Now you will be running as the kadmin user and you can execute the following to create a configuration file.

      Execute these commands as the user KADMIN:
      mkdir -p $HOME/.kube
      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
      sudo chown $(id -u):$(id -g) $HOME/.kube/config
  3. Now create the network as the root user.

    Execute this as the ROOT user:
    kubectl apply -f

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):

Run the following as the ROOT user:
kubeadm join $ip:port --token $token --discovery-token-ca-cert-hash $cert-hash

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.