Blog Article:

Focusing on IaC with OpenNebula

Miguel Ángel Flores

Nov 2, 2018

Infrastructure as Code (IaC) is changing the way that we’re doing things. Some people think that it’s the motorway that we have to follow and be aligned with business, as a resume they want us to be agile.

The arrival of tools such as Ansible, Puppet, SaltStack, and Chef, have enabled sysadmins to maintain modular, automatable infrastructure. This time I would like to introduce the Terraform tool.

Terraform is a provisioning declarative tool that is based on the Infrastructure as Code paradigm. Terraform is a multipurpose composition tool: it composes multiple tiers (SaaS/PaaS/IaaS).

Terraform is not a cloud agnostic tool, but in combination with OpenNebula, it can be amazing. By taking advantage of the template concept it will allow us to deploy vm’s agnostically in different cloud providers, such as AWS, Azure or on premise cloud infrastructure.

one cloud

From the OpenNebula community we can observe several Terraform providers that have been developed. The first example is the project started by the Runtastic team that has recently been enhanced by Blackberry.

After this little introduction about Terraform, let’s go with a tutorial where a PaaS Rancher platform is deployed in an automated way with Terraform and RKE.

Deploy Rancher HA in OpenNebula with Terraform and RKE

paas one

Install Terraform

To install Terraform, find the appropriate package for your system and download it

$ curl -O https://releases.hashicorp.com/terraform/0.11.10/terraform_0.11.10_linux_amd64.zip

After downloading Terraform, unzip the package

$ sudo mkdir /bin/terraform
$ sudo unzip terraform_0.11.10_linux_amd64.zip -d /bin/terraform

After installing Terraform, verify the installation worked by opening a new terminal session and checking that Terraform is available.

$ export PATH=$PATH:/bin/terraform
$ terraform --version
Add Terraform providers for Opennebula and RKE

You need to install go first: https://golang.org/doc/install

After go is installed and set up, just type:

$ go get github.com/blackberry/terraform-provider-opennebula
$ go install github.com/blackberry/terraform-provider-opennebula 

Copy your terraform-provider-opennebula binary in a folder, like /usr/local/bin, and write this in ~/.terraformrc:

providers {
opennebula = "/usr/local/bin/terraform-provider-opennebula"
}

providers {
rke = "/usr/local/bin/terraform-provider-rke"
}

For RKE provider, download the binary and copy in the same folder:

$ wget https://github.com/yamamoto-febc/terraform-provider-rke/releases/download/0.5.0/terraform-provider-rke_0.5.0_linux-amd64.zip 
$ sudo unzip terraform-provider-rke_0.5.0_linux-amd64.zip -d /usr/local/bin/terraform-provider-rke

Install Rancher

Clone this repo:
$ git clone https://github.com/CSUC/terraform-rke-paas.git
Create infrastructure

First we have to initialize Terraform simply with:

$ terraform init

We let Terraform create a plan, which we can review:

$ terraform plan

The plan command lets you see what Terraform will do before actually doing it.

Now we execute:

$ terraform apply

one

That’s it – you should have a functional Rancher server:

rancher dashboard

Now, you can install the Docker Machine OpenNebula Driver and deploy new Kubernetes clusters in your Rancher platform:

docker machine opennebula

cluster one

The complete tutorial is available at Github:

https://github.com/CSUC/terraform-rke-paas

If you are interested in more details, don’t miss the talk: Hybrid Clouds: Dancing with “Automated” Virtual Machines in the next OpenNebula Conf 2018 in Amsterdam.

See you cloudadmins!

Barcelona UserGroup Team –  www.cloudadmins.org

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *