rootshell2 / kubernetes-cluster

Automated scripts to provision a Kubernetes cluster on the Azure cloud, based on Terraform and Ansible.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

  1. Introduction
  2. Getting Started
  3. Terraform Configuration
  4. Ansible Configuration

  • Automated scripts to provision a Kubernetes cluster on the Azure cloud, based on Terraform and Ansible.
  • These scripts provision a Kubernetes cluster. The Kubernetes cluster has 1 master VMs and 2 node VMs, these numbers can also be configured when launching the Terraform script.

General Requirements:

  • Docker

  • Instructions for installing Docker on Ubuntu:

https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository

Create the service principal:

Authenticating a service principal with Azure Resource Manager.

  • Export credentials through environment variables:
$ export AZURE_CLIENT_ID         = "YOUR_AZURE_CLIENT_ID"
$ export AZURE_CLIENT_SECRET     = "YOUR_AZURE_CLIENT_SECRET"
$ export AZURE_SERVICE_PRINCIPAL = "YOUR_AZURE_SERVICE_PRINCIPAL"
$ export AZURE_SUBSCRIPTION_ID   = "YOUR_AZURE_SUBSCRIPTION_ID"
$ export AZURE_TENANT_ID         = "YOUR_AZURE_TENANT_ID"

Setup

  • Cleaning the environment:
$ make clean
  • Create the environment for execution:
$ make setup

Spin up infrastructure:

  • Initialize a working directory containing Terraform configuration files:
$ make terraform-init
  • Create an execution plan:
$ make terraform-plan
  • Building the Infrastructure:
$ make terraform-apply

Create a Kubernetes cluster Using Kubeadm

  • Create a hosts file containing inventory information such as the IP addresses from Terraform output:
$ make ansible-inventory
  • Execute the master playbook:
$ make ansible-playbook 

File Content
variables.tf Configure Azure Provider as well as declare all the variables that we will use in all our Terraform configurations.
var_values.tfvars Assign values to variables. Terraform automatically loads them to populate variables.
networks.tf Instructions for creating the entire network infrastructure of the project. In this file the main VNET is created, the routes and the subnets for the VMs.
storage.tf Storage account with a container to store VHDs of Virtual Machines.
security_group.tf This file contains inbound and outbound rules for traffic flow.
vm-.tf Terraform configuration to provision the VMs.
pip_nic.tf Public IP address to connect to the VMs from the internet.
ansible-inventory.sh Creates Ansible inventory from Terraform output.
File Content
1-dependencies.yml Installing Kubernetes' Dependencies.
2-master.yml Setting Up the Master Node.
3-workers.yml Setting Up the Worker Nodes.
hosts Host inventories.
list.yml Master playbook. The plays and tasks in each playbook listed will be run in the order they are listed.

  • Contact
   E-mail: rootshell2@gmail.com

About

Automated scripts to provision a Kubernetes cluster on the Azure cloud, based on Terraform and Ansible.


Languages

Language:HCL 73.5%Language:Makefile 15.4%Language:Dockerfile 6.3%Language:Shell 4.9%