Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

CloudStack datasource support #1255

Closed
hwaastad opened this issue Sep 27, 2016 · 20 comments
Closed

CloudStack datasource support #1255

hwaastad opened this issue Sep 27, 2016 · 20 comments
Milestone

Comments

@hwaastad
Copy link

RancherOS Version: 0.6.1

Where are you running RancherOS? baremetal

I would like to see CloudStack datasource support in RancherOS.
It's supported by many other distributions like ubuntu/redhat and oem coreos builds.

/hw

@ibuildthecloud
Copy link
Contributor

The tricky thing about CloudStack is just getting the IP of the metadata service. If we know the IP, you can just use the existing EC2 datasource we have today and override the URL. I think one could get cloudstack to work with a long fancy post-up networking command that finds the IP doing https://github.com/coreos/coreos-overlay/blob/master/coreos-base/oem-cloudstack/files/cloudstack-dhcp and then calls ros config set rancher.cloud_init.datasources '["ec2:http://'${IP}'"]'

@hwaastad
Copy link
Author

@ibuildthecloud ,
yes that's what I'm trying to do. Not really sure where RancherOS is storing dhcp lease file.
Script could maybe be hooked into a pre-init step?

@2k0ri
Copy link

2k0ri commented Jan 2, 2017

I've found lease binary in /var/db/ in network container.
So I modified get_dhcp_ip function to:

get_dhcp_ip() {
    local found=0
    while true; do
        for eth in $(sudo system-docker exec network sh -c 'ls /var/db/dhcpcd-*.lease' | sed -r 's/.*dhcpcd-(.*)\.lease/\1/'); do
            dhcp_server_ip=$(sudo system-docker exec network dhcpcd -U $eth 2> /dev/null | awk -F= '/dhcp_server_identifier/ { print $2 }')
            if [[ -n "${dhcp_server_ip}" ]]; then
                metadata_url="http://${dhcp_server_ip}/latest/meta-data/"
                if wget -q -O /dev/null "${metadata_url}"; then
                    echo $dhcp_server_ip
                    found=1
                    break
                fi
            fi
        done
        [[ $found -eq 0 ]] || break
        sleep .5
    done
}

@2k0ri
Copy link

2k0ri commented Jan 5, 2017

I appended below when ros install -c and it works(user-data and ssh key from CloudStack) for me.
I'm not clear about the right way around cloud-init-execute.

#cloud-config
write_files:
  - path: /usr/bin/cloudstack-dhcp
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash
      get_dhcp_ip() {
          local found=1
          local retry=0
          until [[ $found -eq 0 || retry -ge 20 ]]; do
              sleep $((retry++))
              for eth in $(sudo system-docker exec network sh -c 'ls /var/db/dhcpcd-*.lease' | sed -r 's/.*dhcpcd-(.*)\.lease/\1/'); do
                  dhcp_server_ip=$(sudo system-docker exec network dhcpcd -U $eth 2> /dev/null | awk -F= '/dhcp_server_identifier/ { print $2 }')
                  if [[ -n "${dhcp_server_ip}" ]]; then
                      metadata_url="http://${dhcp_server_ip}/latest/meta-data/"
                      if wget -qO /dev/null "${metadata_url}"; then
                          echo $dhcp_server_ip
                          found=0
                          break
                      fi
                  fi
              done
          done
          return $found
      }
  - path: /usr/bin/cloudstack-cloudinit
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash
      
      . /usr/bin/cloudstack-dhcp
      
      DHCP_SERVER=$(get_dhcp_ip)
      KEY_URL="http://${DHCP_SERVER}/latest/meta-data/public-keys"
      
      cat <<EOT > /var/lib/rancher/conf/cloud-config.d/cloudstack.yml
      rancher:
        cloud_init:
          datasources:
          - ec2:http://${DHCP_SERVER}
      ssh_authorized_keys:
      EOT
      { wget -qO- "${KEY_URL}"; echo; } | while read -r line
      do
          echo "- ${line}" >> /var/lib/rancher/conf/cloud-config.d/cloudstack.yml
      done
      if [[ ! -f /tmp/.cloudstack-cloudinit ]]; then
          touch /tmp/.cloudstack-cloudinit
          cloud-init-execute -pre-console -console
          rm /tmp/.cloudstack-cloudinit
      fi
runcmd:
- [/usr/bin/cloudstack-cloudinit]

@retrack
Copy link

retrack commented Sep 5, 2017

May I ask for a status on this one? Cloudstack support is requested by users at Exoscale too.

@stffabi
Copy link
Contributor

stffabi commented Apr 10, 2018

We would be interested in contributing the Cloudstack support. @ibuildthecloud, @niusmallnan would you be interested having this included directly into rancheros?

Our company is currently evaluating RancherOs for CloudStack providers, we are also looking into using Exoscale. @retrack as I've seen you are working at Exoscale, any chance we could arrange for a test-account where we could test the new integration? That would be really awesome 😄

@niusmallnan
Copy link
Contributor

@stffabi We welcome all kinds of PRs, I can help review and merge if needed.

@stffabi
Copy link
Contributor

stffabi commented Apr 10, 2018

@niusmallnan awesome, I've just started with the implementation. I'll let you know as soon as I've created the PR, so we could discuss the enhancements.

@retrack
Copy link

retrack commented Apr 10, 2018

@stffabi Current version Rancher works out of the box with Exoscale, just enable the driver in settings.

Just use this one-off link to try it out: https://portal.exoscale.com/register?coupon=RANCHER4stffabi

@stffabi
Copy link
Contributor

stffabi commented Apr 10, 2018

@retrack thanks for you coupon. Unfortunately we would like to use RancherOS as base system instead of Ubuntu/Debian/..., so we are looking for a new Template for "RancherOS".

I'm currently implementing the support that cloud-init from RancherOS could directly use the meta-data and user-data information provided by Cloudstack. That would be needed to give Exoscale and other CloudProviders the ability to provide a template for RancherOS.

The next question would be if Exoscale is interested in providing such a template.

@retrack
Copy link

retrack commented Apr 10, 2018

@stffabi sorry I totally confused OS and Platform!

As soon as a template with the appropriate cloud-init support is ready we would integrate it. Let us know.

@stffabi
Copy link
Contributor

stffabi commented Apr 10, 2018

@retrack you could find a first version of a cloudstack qcow2 template here. Unfortunately I currently don't have any cloudstack infrastructure to test it. Would it be possible for you to test it on your infrastructure? Or would it be possible for you to activate the template creation future for my trial Exoscale account?

@dahendel
Copy link

dahendel commented Apr 10, 2018

@stffabi I can test it on our CS infrastructure. I have very little experience with RancherOS, but we are interested in the possibility of using it in our new 2.0 infrastructure. Also, are you deploying the template straight through the ui or with docker-machine?

@dahendel
Copy link

I was able to deploy the template successfully with docker-machine to cloudstack

@stffabi
Copy link
Contributor

stffabi commented Apr 11, 2018

@dahendel oh great, thanks so much for testing it. Were you also able to login into the machine with through ssh with docker-machine ssh?

@dahendel
Copy link

@stffabi I was. Thanks for you work on this btw.

@stffabi
Copy link
Contributor

stffabi commented Apr 12, 2018

@niusmallnan I've created the corresponding PR #2326, thanks for any help to bring it into state where it could be merged in.

@niusmallnan niusmallnan added this to the v1.4.0 milestone Apr 13, 2018
@stffabi
Copy link
Contributor

stffabi commented Jun 4, 2018

RancherOs 1.4.0 with cloud-stack support and an appropriate image has been released, would it be possible for you @retrack to trigger the image creation at exoscale? That would be really awesome and we could start using RancherOs at exoscale.

@retrack
Copy link

retrack commented Jun 5, 2018

@stffabi the RancherOS 1.4 image is now available at Exoscale

From our tests, the datasource works correctly with basic directives like DNS, SSH keys, ... Let us know your feedback.

@stffabi
Copy link
Contributor

stffabi commented Jun 7, 2018

@retrack works like a charm, thanks so much...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants