Rancher Server v1

  • Rancher provides some very intriguing features:
    • A docker image repository
    • The ability to add target hosts running the Rancher agent.
    • Secrets storage
  • The v1 Rancher server is effectively an all-in-one alternative to Kubernetes, ECS, EKS, et. al.,

  • Rancher is very good as an on-prem datacenter solution, particularly for development.
  • It is very easy to take a series of on-prem physical servers and provide the Rancher interface to developers or an entry-level ops team.
  • Where Rancher falls short is in cloud deployments.
    • The method of adding target hosts can be automated using the API, but there is almost as much heavy lifting to make Rancher work as you would invest with another product like Kubernetes, ECS, or EKS.
    • Rancher doesn’t like it if the resolv.conf is set to lookup against localhost. It’s rare that localhost would be used as a DNS server, but little quirks like that will cause the Rancher agent to immediately fail.
  • In the end Rancher will feel like using VMware VCenter for Docker. And maybe that’s ok.
  • You have to add hosts manually to Rancher, and the experience is a bit unpredictable.
  • However, the GUI for provisioning docker containers means that even the most inexperienced person can instantly start working with docker and all the myriad of parameters.
  • Rancher is a great solution for a simple setup, but doesn’t make much sense outside of that environment.
  • Rancher feels like a product trying desperately to get some traction in the container ecosystem rather than spend the time to make a polished solution.

Rancher Server

The Rancher Server is a central node which all Rancher Agents connect back to.

Start the Rancher Server

docker pull rancher/server:latest

docker run -d \
  -p 8080:8080 \
  --name rancher-server \
  rancher/server:latest

Visit the Rancher console

  • Once the Rancher server is up and running, connect to the console
  • http://127.0.0.1:8080/

Rancher Agent

  • Install the Rancher Agent on any host where Docker agents will be run.
  • The agent host must be Linux-based and running the Docker daemon.

Agent credentials

  • The agent credentials are acquired by going to the rancher server console and adding a host.
  • http://127.0.0.1:8080/env/1a5/infra/hosts/add?driver=custom

Start the Rancher Agent

docker pull rancher/agent:latest

export RANCHER_SERVER_PROTO="http"
export RANCHER_SERVER_IP="10.10.10.159"
export RANCHER_SERVER_PORT="8080"
export RANCHER_AGENT_CREDS1="F2007C058AF4C1C0BFBC"
export RANCHER_AGENT_CREDS2="1514678400000"
export RANCHER_AGENT_CREDS3="S6G7FTpo67jDTBPgZagc4WqIaPA"

##
## Rancher agent will not start if nameserver is localhost
##
echo "nameserver 8.8.8.8" > /etc/resolv.conf

docker run -d --name rancher-agent \
  --rm --privileged \
  --dns=8.8.8.8 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/rancher:/var/lib/rancher \
  rancher/agent:latest \
  ${RANCHER_SERVER_PROTO}://${RANCHER_SERVER_IP}:${RANCHER_SERVER_PORT}/v1/scripts/${RANCHER_AGENT_CREDS1}:${RANCHER_AGENT_CREDS2}:${RANCHER_AGENT_CREDS3}

Host stuck in the “Reconnecting” state

  • Remove the rancher agent containers.
docker ps -a | awk '{print "docker stop "$1; print "docker rm "$1; }' | sh
  • Use the command that Rancher gives to start a custom host
docker stop rancher-agent
docker rm rancher-agent

docker run --rm --network=host --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://10.10.10.159:8080/v1/scripts/F2007C058AF4C1C0BFBC:1514678400000:S6G7FTpo67jDTBPgZagc4WqIaPA

Deploy a container using the Rancher server

Image, ports, and environment variables

Healthcheck

Network type

  • Pay close attention to the network type.
  • If you just want to use Rancher to start a container in the “normal” way ensure that you set the network type to bridged.

categories: rancher | rancher1 | docker |