VERSION=v1.1.4 && \
curl -LO https://github.com/rancher/rke/releases/download/$VERSION/rke_linux-amd64 && \
chmod +x ./rke_linux-amd64 && \
sudo mv ./rke_linux-amd64 /usr/local/bin/rke
-
Install packages to allow apt to use repo over https
sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
-
Add Docker official GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
Setup Repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
Update
sudo apt-get update
-
Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
-
Create Docker Group
sudo groupadd docker
-
Add User to the docker Group
sudo usermod -aG docker $USER
-
Activate Changes
newgrp docker
Use the example below to create a cluster.yml
, and populate it with the IP and host name of your VM's.
cluster.yaml
nodes:
# Controlplane & Etcd nodes
- address: NODE_IP
user: HOST_USER
role:
- controlplane
- etcd
- worker
hostname_override: master
# Worker nodes
- address: NODE_IP
user: HOST_USER
role:
- controlplane
- etcd
- worker
hostname_override: worker1
- address: NODE_IP
user: HOST_USER
role:
- controlplane
- etcd
- worker
hostname_override: worker2
Note: Your local environment must have ssh
access to all the nodes. Click here to see more on how to setup public key authentication.
rke up --config ./cluster.yaml
After provisioning the cluster, rke
will create kube_config_cluster.yml
to interact with the cluster,
kubectl get nodes --kubeconfig kube_config_cluster.yml
A quick way to setup a rancher server on a docker.
-
Create a dir on you local machine
/opt/rancher
to persist the rancher data. -
Run the docker command
docker run -d --restart=unless-stopped \ -p 80:80 -p 443:443 \ -v /opt/rancher:/var/lib/rancher \ rancher/rancher:latest
-
Goto: https://localhost and login.
-
GOTO Add Cluster > Import an existing cluster > Name the cluster and click create.
-
Follow the instructions on the rancher dashboard to import the cluster.