Using cloud-init

Eugene Brodsky's Avatar

Eugene Brodsky

04 May, 2017 07:50 PM

I am experimenting with CoreOS hosts on Scalr. I have it set up to run scalarizr agent via cloud-init. I am able to launch a host, but now am curious about my orchestration options. Currently, all orchestration is based on a shell script. Can I somehow instead make use of cloud-init via orchestration to add systemd units, or should just I write shell scripts to output systemd units? In other words, is cloud-init useful for anything aside from setting up scalarizr agent?

Thanks!

  1. 1 Posted by Eugene Brodsky on 04 May, 2017 07:56 PM

    Eugene Brodsky's Avatar

    Correction - spoke too soon - instances terminate almost instantly and never come up. Is there any point in experimenting with this, or is CoreOS broken and totally unsupported?

  2. 2 Posted by Eugene Brodsky on 04 May, 2017 08:37 PM

    Eugene Brodsky's Avatar

    Update - was able to get this running (including intialization of Scalr agent via cloud-init!) by changing to a Paravirtualized AMI for Core OS (instead of HVM). This pointed me in the right direction: https://github.com/docker/machine/issues/2898#issuecomment-214919898.

    Looks like Scalr also assumes the root device is /dev/sda1, which is correct for PV AMIs, but for HVM it should be /dev/xvda1. I realize this is a digression from my original question re: utility of cloud-init, but is this something that can be fixed by Scalr? It's a bummer to not be able to use any of the HVM images.

  3. 3 Posted by Eugene Brodsky on 04 May, 2017 09:05 PM

    Eugene Brodsky's Avatar

    Back to my original question (sort of).

    Looks like the way to use Scalr orchestration in this setup is by chrooting to /rootfs inside the Scalarizr container:

    #!/bin/sh
    chroot /rootfs /bin/bash -x <<EOF
    
    # do stuff here
    # like output a systemd unit
    # or just `docker run ...`
    
    EOF
    

    This works, but is ugly and gross. Can anyone suggest a better way?

  4. Support Staff 4 Posted by Igor Savchenko on 05 May, 2017 12:55 AM

    Igor Savchenko's Avatar

    Hi Eugene,

    CoreOS support is in beta right now and was not officially announced yet; this is why it's not really "stable" and "efficient." Do you want to help us to make it better as well as be a part of our containers strategy discussion? If yes, I'll be happy to have a call with you to get some feedback and thoughts around CoreOS and containers in general.

    Regards,
    Igor

  5. Support Staff 5 Posted by Marat Komarov on 05 May, 2017 02:47 AM

    Marat Komarov's Avatar

    Hey Eugene,

    We've tested CoreOS only on HVM images. It's interesting that PV works for you while HVM doesn't. What AMI are you using?

    Regarding orchestration, you're absolutely right. And we don't believe that it will be useful for anybody in this way.

    That's why we're working on the following approach:

    • each script execution request will produce a systemd unit file
    • systemd executes unit file on the host and controls timeouts
    • on script completion, Scalarizr deletes the unit file and sends report to Scalr.

    Regards,
    Marat

  6. 6 Posted by Eugene Brodsky on 05 May, 2017 03:33 PM

    Eugene Brodsky's Avatar

    Thanks guys for the replies!

    Marat: I'm trying the CoreOS stable channel - https://coreos.com/os/docs/latest/booting-on-ec2.html. ami-ad593cbb (HVM) did NOT work for me, but the ami-a6a7c2b0 (PV) is working.

    The orchestration approach you describe makes sense and would be great to see! Have you considered an option of skipping the shell-script middleman, and implementing an interface for writing/managing systemd units directly? (kind of like what you've got going with Apache vhosts). scalarizr could then query services via systemctl, with all the ensuing benefits (status monitoring, logs, etc). Having a native Scalr interface into systemd would be actually pretty amazing. Though this is edging into configuration management territory, so I might be asking for too much.

    Also, just realized something: when using cloud-init, scalarizr is deployed in a container. What if the image has cloud-init, but no docker engine? I.e. could I deploy scalarizr on an any arbitrary cloud-init-enabled distro without having to build a custom AMI, or is the docker engine also a prerequisite and assumed to exist?

    Igor: I'm by no means a CoreOS or systemd expert (just scratching the surface really), but we've been running containers on Scalr for a while via other means (vanilla Ubuntu + orchestration + Rancher), and I would love to share whatever knowledge i have. Please reach out via email and we can take it from there - we're a hosted Scalr customer, so you should have my info. Looking forward to it.

  7. Support Staff 7 Posted by Marat Komarov on 09 May, 2017 02:04 AM

    Marat Komarov's Avatar

    ami-ad593cbb (CoreOS-stable-135370-hvm) works for us. Please verify that you're registered Image with Cloud-Init: Yes, Scalarizr: No. While Role with Scalarizr: Yes.

    Regards,
    Marat

  8. 8 Posted by Eugene Brodsky on 09 May, 2017 03:48 PM

    Eugene Brodsky's Avatar

    Hi Marat. I double checked, and that is how the image/role are set up. To be sure, I removed the role and image entirely and repeated the process from scratch, but unfortunately with the same result - the instance shuts down almost immediately after entering "running" state in AWS (it never gets to "running" in Scalr).
    Anything you can suggest?
    Thanks!

  9. Support Staff 9 Posted by Marat Komarov on 09 May, 2017 05:07 PM

    Marat Komarov's Avatar

    Could you provide farm_id / server_id to check?

  10. 10 Posted by Eugene Brodsky on 09 May, 2017 05:41 PM

    Eugene Brodsky's Avatar

    farmId=21852&farmRoleId=154050

    I don't have a serverId since i can't get one to stay running for longer than a minute :)

    Thanks!

  11. Support Staff 11 Posted by Igor Savchenko on 16 May, 2017 10:22 PM

    Igor Savchenko's Avatar

    Hi Eugene,

    We've found an issue and fix is ready and will be deployed within the next 24 hours.

    Regards,
    Igor

  12. 12 Posted by Eugene Brodsky on 16 May, 2017 10:27 PM

    Eugene Brodsky's Avatar
    ╔═════════════════════════════════════════════════════════════════════╗  
    ║                                                                     ║░░
    ║     __     __  __  __     __    ____    ___     ___ ___      __     ║░░
    ║   /'__`\  /\ \/\ \/\ \  /'__`\ /',__\  / __`\ /' __` __`\  /'__`\   ║░░
    ║  /\ \L\.\_\ \ \_/ \_/ \/\  __//\__, `\/\ \L\ \/\ \/\ \/\ \/\  __/   ║░░
    ║  \ \__/.\_\\ \___x___/'\ \____\/\____/\ \____/\ \_\ \_\ \_\ \____\  ║░░
    ║   \/__/\/_/ \/__//__/   \/____/\/___/  \/___/  \/_/\/_/\/_/\/____/  ║░░
    ║                                                                     ║░░
    ╚═════════════════════════════════════════════════════════════════════╝░░
      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    
  13. 13 Posted by Eugene Brodsky on 17 May, 2017 05:46 PM

    Eugene Brodsky's Avatar

    Confirmed, this now works with the CoreOS stable HVM image. I did not have to re-create the role.
    Thank you!!

  14. Eugene Brodsky closed this discussion on 05 Jun, 2017 01:49 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac