Install Rancher and set up a Kubernetes cluster

Install docker:

sudo curl https://releases.rancher.com/install-docker/19.03.sh | sh
sudo usermod -aG docker $user

install Rancher in a docker container (single node) with persistent data. We’ll map 80 of the container to 8080 of the docker host and 443 of the container to 8443 of the external host, I’m doing this since I will be using the above ports for different containers.

docker run -d --restart=unless-stopped \
  -p 8080:80 -p 8443:443 \
  -v /opt/rancher:/var/lib/rancher \
  rancher/rancher:latest

check the status of the container:

docker ps -l

on a browser, open the IP address of the Docker host with the port specified previously. in my case it was https://192.168.3.101:8443/ , it should prompt you for a password similar to the below.

Once Done, You are prompted with the below page, click on “add a cluster” and then select “existing node”


Enter the cluster name and then hit next


In the node option, ensure that you select etcd, control plane and worker, copy the script from the below tab and run them on the Nodes that you want to spin up kubernetics.

In my senario since this is a lab setup, I will use the same docker host and 2 other nodes.

Node 1
Node 2
Node 3

Once Setup, wait a while for the nodes to startup (you will see few warnings, do not panic. wait it out.)

once they are all up, it should look like the below:

Congratulations!!, you have now set up rancher and are ready to start deploying Kubernetes workloads!!

Usage Meter 4.2 : trigger manual collection

manual collection can be triggered via API we first need to get a tioken and then invoke API:

token:

curl --location --request POST 'https://<UM_IP>:8443/api/v1/login' \
--header 'Content-Type: application/json' \
--data-raw '{
   "user":"usagemeter",
   "password":"vmware"
}' 

trigger collection:

curl --location --request POST 'https://<um_ip>:8443/api/v1/collect' \
--header 'Content-Type: application/json' \
--header 'sessionid: UmSIDzwOFhFRjBhdXOG6nrEaGJMco10t4im8pJN8kYXFn54E' \
--data-raw '{
  "trigger" : ["All"]
}'