Difference between revisions of "Installing Kubernetes with Ansible on AWS"

From PKC
Jump to navigation Jump to search
Line 40: Line 40:
#<code>--key-file</code> for the secret key file, in this case, the <code>~/.ssh/ansible.pem</code> is the one that is shared with all the nodes.
#<code>--key-file</code> for the secret key file, in this case, the <code>~/.ssh/ansible.pem</code> is the one that is shared with all the nodes.
#<code>-u</code> for user name, in this case, <code>ubuntu</code> is the user associated with the key file.
#<code>-u</code> for user name, in this case, <code>ubuntu</code> is the user associated with the key file.
#<code>-m</code> for module name, in this case, <code>ping</code> is the module to be executed.
  ansible all -i inventory --key-file ~/.ssh/ansible.pem -u ubuntu -m ping
  ansible all -i inventory --key-file ~/.ssh/ansible.pem -u ubuntu -m ping

Revision as of 09:14, 3 August 2021

This article explains how to install Kubernetes using Ansible on AWS's Ubuntu 20.04 computing clusters.

Set up at least two machines on AWS

The first task is to create two EC2 instances that matches Kubernetes Cluster minimal configuration:

The master node must have at least 2 CPU cores, 2 Gb of memory.
The worker node (slave) should have at least 1 CPU core and 2 Gb of memory.

Set the right Security Groups

{{#lst:Input/K8s Installation/Security Groups|Security Groups}}

Ideally, one could first create a Security Group, and name it K8s Sec Grp, then, just create two or more instances of EC2, and select the said security group during the creation cycle.

Use the same Signature File

When creating these instances, make sure that you create or select the same Identity file (.pem file) for all instances of the same cluster. This will significantly reduce the complexity of installation.

Make sure Ansible is installed

Install Ansible on the machine that will run Ansible to install the cluster. You may follow this procedure: Installing Ansible. If you already installed Python 3.0 and pip3, launch the following instruction in your terminal should work:

 pip3 install ansible

Set up Ansible Hosts and Inventory file

It is necessary to set up the hosts and inventory files for Ansible. See the following examples:

For hosts file:

m1.xlp.pub
w1.xlp.pub

For inventory file:

m1.xlp.pub
w1.xlp.pub

Test to see if Ansible can access the machines

One must supply the following data points to enable Ansible to access the machines:

  1. -i for input file, in this case, the inventory file in the current working directory.
  2. --key-file for the secret key file, in this case, the ~/.ssh/ansible.pem is the one that is shared with all the nodes.
  3. -u for user name, in this case, ubuntu is the user associated with the key file.
  4. -m for module name, in this case, ping is the module to be executed.
ansible all -i inventory --key-file ~/.ssh/ansible.pem -u ubuntu -m ping