Need your automated opinions~


Recommended Posts

I have a GitLab container that's running very nicely (it starts up in about 8-10 seconds or so, this is nginx, rake, etc) -- two VMs (Ubuntu Server 16.04LTS and Windows Server 2016 Standard) with GitLab runners installed as well as a SonarQube container for code coverage.

 

I'm looking to balance things out towards power savings since the runners only need to be up and running for a short amount of time -- the same applies to the SonarQube container.

 

So here begs the question:

What approach can I take here for a bit of automation? -- these are my thoughts so far:

 

All events would begin from a GitLab CI job being triggered -- at this point, our VMs are off (as well as our Docker container).

GitLab can trigger a webhook along with a CI job (we can't run commands in our instructions file [.gitlab.yml] just yet because that's actually ran by the runners so no bash from there).

 

Since GitLab is on the unRAID server, it makes sense to have the consumer on the unRAID box (possibly in a container as well, albeit a light one -- but not ideal, you'll see why).

I'm thinking python or ruby as they have built-in modules to put together what we need -- but you what they say, don't reinvent the wheel.

 

From my time with Google; I ended up finding a Go utility with the apt name of webhook... [https://github.com/adnanh/webhook]

As it turns out, this will do exactly what we need -- only problem is that we are running in a container...

 

So how do you call a script from a Docker container onto its host -- not entirely sure how that would be possible.

Does unRAID have an API I can poke at -- I'm thinking whatever I want to do has to run on the unRAID box itself (not from Docker).

 

What do you guys think?

Should I install this directly or keep on researching for a way to run this from Docker?

What about my approach? Too complicated?

 

This is begging for a plugin rather than a container (this would make it much easier to interact with unRAID when it's time to fire up the VMs/Docker containers).

Link to comment

Not sure precisely what you are asking to do, but firing up VM's and dockers can all be scripted at the unraid console. Either using cron for timed events, or even using telnet or SSH from the container or VM to log back in to unraid and issue commands that rely on timing inside the container or VM.

 

Maybe if you laid out your desired end result we could help you to find the most efficient way to get it done.

For example...

When I fire up VM(a) I want docker(a1) to start after VM(a) has fully booted, then when both VM(a) and docker(a1) are up VM(b) and docker(a2,a3,a4) need to be started. After VM(b) is finished with a job, shut down VM(a,b) and docker(a1,a2,a3,a4) and send a notification.

Or something like that.

Link to comment
3 hours ago, jonathanm said:

When I fire up VM(a) I want docker(a1) to start after VM(a) has fully booted, then when both VM(a) and docker(a1) are up VM(b) and docker(a2,a3,a4) need to be started.

This can be done with the Docker Autostart Manager plugin available within CA, either by utilizing appropriate delays or by checking for a port becoming available (either locally or on a completely different system / VM)

 

7 hours ago, avluis said:

So how do you call a script from a Docker container onto its host -- not entirely sure how that would be possible.

 

If you add a mapping for whatever the script requires outside the container, then a script running within will be able to do what it needs.

Link to comment

 

6 hours ago, jonathanm said:

Not sure precisely what you are asking to do, but firing up VM's and dockers can all be scripted at the unraid console. Either using cron for timed events, or even using telnet or SSH from the container or VM to log back in to unraid and issue commands that rely on timing inside the container or VM.

 

Yep~ Keep those ideas coming in -- I'm still picking the most suitable way to do this.

My limitation is what I have available to do this with -- with the VMs and containers off, it has to be done via a webhook (when a build job is fired off) -- said hook can be consumed by the utility I mentioned above (running on the unRAID box -- on it or via Docker to be decided).

The above utility can call off scripts -- these scripts will in turn power up the VMs and/or Docker containers I need.

 

6 hours ago, jonathanm said:

Maybe if you laid out your desired end result we could help you to find the most efficient way to get it done.

 

I thought I did -- was probably way too tired:

- GitLab container receives a push for a CI enabled branch

- GitLab fires off a webhook due to the above

- webhook (the Go utility) consumes this and in turn, calls off the associated script

- The script processes a few variables to determine what needs to start up and does so

- The runner comes online, fetches the job and processes away -- it powers back off on its own after some time

- In the case of a container (SonarQube), a cron task is fired off to take care of turning it back off after some time

 

2 hours ago, Squid said:

If you add a mapping for whatever the script requires outside the container, then a script running within will be able to do what it needs.

 

That's exactly what I wanted to know -- that's perfect!

I'm still trying to wrap my head around the concept of a script that's running in a container calling up commands on the host but I'm simply over thinking things.

I could go about it by establishing a connection to unRAID (SSH?) and running my commands that way -- but I'd like to keep it local and slim.

 

Yeah -- I need to stop overthinking this and go have some fun with my next container~

Edited by avluis
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.