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 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.
For this guide you will need a couple of tools to manage and deploy to your local Kubernetes instance.
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.
Sign into Docker then right click on the Docker icon in your System Tray and select
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.
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”.
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
> kubectl get nodes NAME STATUS ROLES AGE VERSION docker-for-desktop Ready master 6d v1.9.6
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.
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
tiller can deploy to our cluster for us.
ServiceAccount in the
kubectl -n kube-system create serviceaccount tiller
ClusterRoleBinding to give the
tiller account access to the cluster
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm to initialize the
helm init --service-account tiller --wait
tillerinstall has full cluster access, and may not be suitable for a production environment. Check out the helm docs for restricting
tilleraccess 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
chart. This will create an ingress controller on our local cluster.
helm install stable/nginx-ingress --name ingress-nginx --namespace ingress-nginx --wait
The Cert-Manger project for Kubernetes will manage the SSL certs for our local Rancher install.
Install Cert-Manager from Kubernetes Helm
helm install stable/cert-manager --name cert-manager --namespace kube-system --wait
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 repo add rancher-latest https://releases.rancher.com/server-charts/latest
Now install the
Install Rancher and set a hostname for it to listen on.
rancher.localhost should automatically resolve to
helm install rancher-latest/rancher --name rancher --namespace cattle-system --set hostname=rancher.localhost --wait
If you set the hostname to something other than
rancher.localhost, you may need to update your
hosts file to access it.
- Windows -
- Mac -
Edit the appropriate file for your system and add an entry
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.
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!