Recently, I started to learn and discover deeper the world of containers. When it comes to containers, one of the most important tools in today’s days is the Kubernetes. Unfortunately, it’s not easy to find a good solution for k8s. It comes in various products, mainly tailored to the given infrastructure. As a result, we have products like AWS EKS (Amazon Elastic Container Service for Kubernetes), GKE (Google Kubernetes Engine) or AKS (Azure Kubernetes Service) – managed by main cloud providers. Kubernetes comes also in form of on-premises solutions, here we have products like Cloudstack, Kubespray or Kubeadm. Everything depends on your needs, current infrastructure and expectations.

rancher1

After some good discussions with my friends, I’ve been informed about another great tool, called Rancher. And here begins my new post! Rancher is powerful, easy to install and very user-friendly Kubernetes service.

Official documentation is available at rancher.com. Let’s have a look what they write about themselves. Some of the good facts are that Rancher allows us to centrally manage multiple Kubernetes clusters (EKS, GKS, AKS, on-premises etc). It comes with a nice, easy to understand GUI. Installation is very easy, and many more. So, let’s check it out!

One of the easiest way to demonstrate the Rancher is to use AWS Quick Start method described in rancher quickstart. It requires from us the programmatic access to our AWS account (ideally with admin rights, to simplify the process) and installed Terraform. The Rancher has prepared nicely terraform script to provision our initial infrastructure. I’m going to provision my single node setup in AWS eu-west-1 region to minimalize the costs. You can follow my procedure described below:

# First, let's create a SSH-Key pair.

$ ssh-keygen -t rsa -C "my-key" -f ~/.ssh/my-key
$ aws ec2 \ 
  import-key-pair \
  --key-name "my-key" \
  --public-key-material file://$HOME/.ssh/my-key.pub \
  --region eu-west-1

# Next, clone the terraform scripts from Rancher github

$ git clone https://github.com/rancher/quickstart
$ cd quickstart/aws

# Edit the terraform.tfvars.example 
# Add your AWS credentials, ssh_key_name, region and prefix. 
# You can optionally modify the count of various node types, but I’ll leave them with default values. 
# Consider that any extra resources created in AWS will cost you more money!

$ vi terraform.tfvars.example
...
# Amazon AWS Access Key
aws_access_key = "your-aws-access-key"
# Amazon AWS Secret Key
aws_secret_key = "your-aws-secret-key"
# Amazon AWS Key Pair Name
ssh_key_name = "my-key"
# Region where resources should be created
region = "eu-west-1"
# Resources will be prefixed with this to avoid clashing names
prefix = "rancher-test"
...

$ mv terraform.tfvars.example terraform.tfvars
$ terraform init
$ terraform apply

# Confirm the installation, by typing "yes"

rancher2

You will get the following message, which indicates that your setup has been successfull.

rancher3

/*The IP address will vary, as AWS automatically attach random Elastic IP to your newly created instance.

After couple of minutes (it depends on your selected setup), your first Rancher instance will be ready to access. As you can see, it’s a piece of cake. Just open the URL from the terraform output.

For now, please ignore the message about untrusted certificate and proceed with access. The default username and password is admin/admin

rancher4

When everything went good, you will get the dashboard similar to below one.

rancher5

In the next article, I’ll walk through the Rancher dashboard and will try to demonstrate some of the basic usages as well as create my first Kubernetes cluster.

I hope you enjoyed my post! :)

! Important Note - don’t forget to remove your AWS setup, otherwise you will be charged by Amazon for the usage :)

# From the quickstart/aws folder
$ terraform destroy