Deploying Kubernetes on bare metal machines


What is Kubernetes?

Kubernetes is an open-source container orchestration system for automating application deployment, scaling, and management.
More about kubernetes can be found out on its website.

In this blog, we will deploy kubernetes on a 4 node cluster using ansible scripts from the gcs repository. For this blog, we are considering only bare metal machines and not VMs.

Cluster:

Total number of nodes : 4 {Node1: kube1, Node2: kube2, Node3: kube3, Node4: kube4}
Master nodes : 1 {kube1}
Kube nodes: 4

Steps to install kubernetes:


  1. Install ansible on master node: $ yum install ansible PS: ansible can be installed on any system/node even outside the cluster but for this post
          we will be installing it on the master node.
  2. To ensure ansible is able to ssh into the nodes, add public key of master node{kube1}as authorized key in other kube nodes $ cat ~/.ssh/id_rsa.pub | ssh root@kube2 'cat >> ~/.ssh/authorized_keys
  3. Stop firewalld on all machines $ systemctl stop firewalld
  4. We will install kubernetes via the deploy-k8s script in the GCS repository. Clone GCS repository in master node(kube1) $ git clone --recurse-submodulesgit@github.com:gluster/gcs.git
  5. To install kubernetes we need create an inventory file mentioning the kubernetes nodes.
    Template for kubernetes inventory file can be found under deploy directory in gcs
    repository: https://github.com/gluster/gcs/blob/master/deploy/examples/inventory-gcs-kubespray.example Provide ip of nodes in the inventory file. As we are deploying just kubernetes we can remove the gcs-node section and we won’t need to mention gcs_disks so we can remove that part as well.
    Your inventory file should look like:
  6. To deploy kubernetes we need to execute deploy-k8s.yml file using ansible and provide inventory file created in Step 5.
    The deploy-k8s.yml file is present under deploy directory in gcs repository. $ ansible-playbook -i <path to inventory file>/<name of inventory file> <path to deploy-k8s.yml file>/deploy-k8s.yml
  7. Check whether all the nodes are in ready state. $ kubectl get nodes PS: The status of all the nodes should be in READY state.

Remove kubernetes cluster



To remove the kubernetes cluster setup, run:
$ ansible-playbook -i <path to inventory file>/<name of inventory file> <path to deploy directory>/deploy/kubespray/reset.yml


Comments

Popular posts from this blog

Deploying GCS on kubernetes cluster