Rancher Tutorial: How to Run Rancher 2.0 on your Desktop


A Detailed Overview of Rancher's Architecture
This newly-updated, in-depth guidebook provides a detailed overview of the features and functionality of the new Rancher: an open-source enterprise Kubernetes platform.

Don’t have access to Cloud infrastructure? Maybe you would like to use Rancher for local Kubernetes deployments just like you do in production?

No problem, you can install Rancher 2.x on your desktop.

In this Rancher tutorial we will install Docker-for-Desktop Edge release and enable the built in Kubernetes engine to run your own personal instance of Rancher 2.x on your desktop.

Prerequisites

For this guide you will need a couple of tools to manage and deploy to your local Kubernetes instance.

  • kubectl - Kubernetes CLI tool.
  • helm - Kubernetes manifest catalog tool.

Docker-for-Desktop

The Edge install of Docker CE for Windows/Mac includes a basic Kubernetes engine. We can leverage it to install a local Rancher Server. Download and install from the Docker Store.

Docker Configuration

Sign into Docker then right click on the Docker icon in your System Tray and select Settings

Advanced Settings

In the Advanced section increase Memory to at least 4096 MB. You may want to increase the number of CPUs assigned and the Disk image max size while you’re at it.

advanced

Enable Kubernetes

In the Kubernetes section, check the box to enable the Kubernetes API. Docker-for-Desktop will automatically create ~/.kube/config file with credentials for kubectl to access your new local “cluster”.

kubernetes

Don’t see a Kubernetes section? Check the General section and make sure you are running the Edge version.

Testing Your Cluster

Open terminal and test it out. Run kubectl get nodes. kubectl should return a node named docker-for-desktop.

> kubectl get nodes

NAME                 STATUS    ROLES     AGE       VERSION
docker-for-desktop   Ready     master    6d        v1.9.6

Preparing Kubernetes

Docker-for-Desktop doesn’t come with any extra tools installed. We could apply some static YAML manifest files with kubectl, but rather than reinventing the wheel, we want leverage existing work from the Kubernetes community. helm is the package management tool of choice for Kubernetes.

helm charts provide templating syntax for Kubernetes YAML manifest documents. With helm we can create configurable deployments instead of just using static files. For more information about creating your own catalog of deployments, check out the docs at https://helm.sh/

Initialize Helm on your Cluster

helm installs the tiller service on your cluster to manage chart deployments. Since docker-for-desktop has RBAC enabled by default we will need to use kubectl to create a serviceaccount and clusterrolebinding so tiller can deploy to our cluster for us.

Create the ServiceAccount in the kube-system namespace

kubectl -n kube-system create serviceaccount tiller

Create the ClusterRoleBinding to give the tiller account access to the cluster

kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller

Finally use helm to initialize the tiller service

helm init --service-account tiller --wait

NOTE: This tiller install has full cluster access, and may not be suitable for a production environment. Check out the helm docs for restricting tiller access to suit your security requirements.

Add an Ingress Controller

Ingress controllers are used to provide L7 (hostname or path base) http routing from the outside world to services running in Kubernetes.

We’re going to use helm to install the Kubernetes stable community nginx-ingress chart. This will create an ingress controller on our local cluster.

helm install stable/nginx-ingress --name ingress-nginx --namespace ingress-nginx --wait

Install Cert-Manager

The Cert-Manger project for Kubernetes will manage the SSL certs for our local Rancher install.

Install Cert-Manager from Kubernetes Helm stable repository:

helm install stable/cert-manager --name cert-manager --namespace kube-system --wait

Installing Rancher

We’re going to use Rancher’s official helm chart for the install.

The default install will use Rancher’s built in self-signed SSL certificate. For additional details and install options check out Rancher’s HA Install Docs.

First add the rancher-server repository to helm

helm repo add rancher-latest https://releases.rancher.com/server-charts/latest

Now install the rancher chart

Install Rancher and set a hostname for it to listen on. rancher.localhost should automatically resolve to 127.0.0.1.

helm install rancher-latest/rancher --name rancher --namespace cattle-system --set hostname=rancher.localhost --wait

Setting hosts file

If you set the hostname to something other than rancher.localhost, you may need to update your hosts file to access it.

  • Windows - c:\windows\system32\drivers\etc\hosts
  • Mac - /etc/hosts

Edit the appropriate file for your system and add an entry

127.0.0.1 myrancher.mydomain.com

Connecting to Rancher

Browse to https://rancher.localhost

Ignore the SSL warning and you should be greeted by the colorful Rancher login asking you to Set the Admin password.

rancher

Congratulations you have your very own local instance of Rancher 2.0. You can add your application charts and deploy your apps just like production. Happy Containering!

Next Up

This Rancher tutorial showed you how to install your own local Rancher. To learn what Rancher can do and how it works, join a free weekly Intro to Rancher and Kubernetes online training.

A Detailed Overview of Rancher's Architecture
This newly-updated, in-depth guidebook provides a detailed overview of the features and functionality of the new Rancher: an open-source enterprise Kubernetes platform.
Jason Greathouse
github
Jason Greathouse
Senior Solutions Architect
Since 1999 Jason Greathouse has been building scalable infrastructure for businesses of all sizes, from early stage startups to Fortune 500 companies. He was an early adopter of containers and has been running solutions built on Docker since version 0.7.
快速开启您的Rancher之旅