How to start "rancher/rancher-agent" in cloud-config.yml


#1

Hi,
I’am trying to start a “rancher/rancher-agent” service from cloud-config.aml provided to “ros install”. But the Agent always get’s a Bridge-Network not the Host-Network assigned and fails.

How to reproduce:

  1. Create Cluster in Rancher

  2. Boot RancherOS

  3. Install RancherOS with following cloud-config.yml
    #cloud-config
    ssh_authorized_keys:
    - ssh-rsa ##SSH-PUBLIC-KEY##

    hostname: ##CLUSTER-NODE-HOSTNAME##

    rancher:
    services:
    rancher-agent1:
    image: rancher/rancher-agent:v2.0.8
    privileged: true
    restart: unless-stopped
    volumes:
    - /var/run:/var/run
    - /etc/kubernetes:/etc/kubernetes
    net: host
    networks:
    hostnet: {}
    environment:
    - CATTLE_SERVER=##URL-OF-RANCHER##
    - CATTLE_TOKEN=##TOKEN-FROM-RANCHER##
    - CATTLE_CA_CHECKSUM=##CHECKSUM-FROM-RANCHER##
    - ETCD=true
    - CONTROL=true
    - WORKER=true
    networks:
    hostnet:
    external: true
    name: host

  4. run “docker inspect rancher-agent1” / Provisioning in Rancher fails

Expected Result:
rancher-agent1 get’s Host-Network assigned and provisioning finished.

Logging in to RancherOS and running the following manually via ssh is working:
“sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.0.8 --server ##URL-OF-RANCHER## --token ##TOKEN-FROM-RANCHER## --ca-checksum ##CHECKSUM-FROM-RANCHER## --etcd --controlplane --worker”

Appendix:
I’ve a running testing Environment using libvirt on my system so and ideas on how to start rancher/rancher-agent with cloud-config are welcome - I can try them quickly.