Reply
Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Controller on Google Cloud Platform (Free)

[ Edited ]

Here is a link to my Instructable documenting the setup of a controller on a Free micro instance of Google Cloud Platform. 

The resources are limited, but several people have been running it with smaller deployments without problem.

 

https://www.instructables.com/id/Unifi-Controller-on-Google-Cloud-Platform-GCP/

 

Update: 9/5/2018 Added commands for Google Cloud Shell to make deployment even easier.  Open a text file and make some modifications for your specific needs and then copy/paste to create everything needed.  Paired with the script from @PetriR this makes the deployment very quick and easy.

Established Member
Posts: 1,603
Registered: ‎01-29-2014
Kudos: 489
Solutions: 82

Re: Controller on Google Cloud Platform (Free)

+1 for anyone with your username saying "600MB is enough".

 

I have a strange feeling of deja vu/being very old Man Very Happy

New Member
Posts: 34
Registered: ‎07-15-2016
Kudos: 9

Re: Controller on Google Cloud Platform (Free)

Thanks!  I also have a Unifi Controller set up in the Google Cloud using the "always free" tier.  I used your instructions to set up a 1GB swap file.  

 

So far I've been very happy with the Google Cloud.  My AWS free trial hasn't expired yet so I was looking for cheaper alternatives when I found Google Cloud Compute.  

New Member
Posts: 9
Registered: ‎10-01-2015

Re: Controller on Google Cloud Platform (Free)

I just set one up last night using your instructions. Thank you so much, worked perfectly! I changed your "deb http://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti" command to "deb http://www.ubnt.com/downloads/unifi/debian  stable ubiquiti" for the latest stable version of the controller.

 

Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

Thank you for the suggestion.  I'll update my instructions

Emerging Member
Posts: 62
Registered: ‎07-28-2017
Kudos: 11
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

[ Edited ]

DId this recently as well.   Works very nicely.

 

One other suggestion--I created a google cloud storage bucket for backups.  Then I dropped a simple cron script into the /etc/cron.daily folder of the instance that syncs the contents of /var/lib/unifi/backup into the storage bucket.  

 

This is important to retain the backup folder separately from the instance, just in case the VM dies and becomes unusable.  If that happens, you can then spin up another instance and easily restore the backup from the storage bucket.

 

#!/bin/sh

gsutil rsync -r -d /var/lib/unifi/backup gs://[name_of_storage_bucket]

 

dont forget to chmod +x to make the script executable by crontab.

 

You could also take snapshots of the instance, but that will only preserve the status quo.  I like having the backup file separately for more flexibility in case I want to upgrade to a different version of the controller, or use a different image for the instance.

 

Finally, I will just point out that the entropy error in Ubuntu which causes long boot times for the instnance can be easily fixed by installing 

sudo apt-get install haveged

 as noted in this post

https://community.ubnt.com/t5/UniFi-Wireless/Ubuntu-14-04-x64-Unifi-4-6-6-very-slow-start-up/td-p/13...

 

Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

Thanks for the note on haveged.  Is there anything you need to do after installing it?  I did the apt-get you mentioned and rebooted and it still took 8 minutes compared to 20 before I installed it. 

 

[2017-12-27 16:57:39,728] <launcher> INFO  system - Hostname: unifi-controller
[2017-12-27 17:05:21,954] <localhost-startStop-1> WARN  SessionIdGeneratorBase - Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [459,019] milliseconds.

 

I'll take a closer look at the storage bucket as well.  I'm not familiar with them but a good idea if you can copy the backups to it.

 

Emerging Member
Posts: 62
Registered: ‎07-28-2017
Kudos: 11
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

[ Edited ]

Not really sure why you still have such a long boot time. Mine takes just a few seconds to come alive. I am using a Ubuntu 16.04 image with all the apt-get upgrades. I simply ran the install command for haveged, nothing special or anything.

Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

I've upgraded to 17.10 so maybe that plays into it somewhat.  I'm not sure.

 

I almost have the storage buckets setup.  I can manually copy the backup files but the cron script isn't working just yet.  I'm documenting in instructables at the same time and I think it is causing some copy and paste errors, so going to manually bang out the script and see if that resolves it.

Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

I'm all set now.  Thank you for the suggestions.

Member
Posts: 225
Registered: ‎06-19-2015
Kudos: 42
Solutions: 6

Re: Controller on Google Cloud Platform (Free)

I would like to know some stats from the people who are using the free google cloud. 

 

1. How many sites per controller?

2. Average devices per site?

3. Clients per site?

4. DPI and Settings, minimum stats saved? DPI on/off?

5. Guest Portal?

6. VPN tunnels between sites, only multisite controllers or if your are manually creating the vpns?

 

We just switched from a cloud key back to a headless windows controller. Had 30+ sites on the CK with no portals or stats retention or DPI. CK kept crashing. Window pc no issues or ram or cpu spikes with about 35 sites now, with DPI on some sites and vpn tunnels between sites too. 600+ client devices

Emerging Member
Posts: 62
Registered: ‎07-28-2017
Kudos: 11
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

Mine is just a home network.  1 site, 5 devices, 25 clients.  DPI on.  No guest portal or VPN.

New Member
Posts: 9
Registered: ‎12-21-2017
Kudos: 1

Re: Controller on Google Cloud Platform (Free)

Very nice. I have been using a AWS lightsail server for the controller, will be switching.
New Member
Posts: 27
Registered: ‎01-04-2016
Kudos: 3

Re: Controller on Google Cloud Platform (Free)

Thank you @MallocArray for the great instructions. I got my GCP Controller all up and running with minimal stress.

 

A few minor updates to the documentation you may consider:

  • Minor typo: 'VPN Network' should be VPC Network'
  • I would also suggest making clear that 'Menu' means the Google Cloud Platform primary Memu and no the VM Instance Menu
  • Step 2 5.1.5 is 'Create' rather than 'Save'
Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

Thank you Dean.  I've updated with your suggestions.

Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

@ncscomm The free VM in GCP won't be up for that large of an install.  I'm not sure how large the Cloud Key is designed to support, but this VM is less than the Cloud Key specs wise.

 

I'm running my home from with, USG, 2 UAP and 18 clients with no problems. I sometimes have a guest portal, but always a guest network.

Member
Posts: 112
Registered: ‎09-17-2014
Kudos: 55
Solutions: 4

Re: Controller on Google Cloud Platform (Free)

Someone on Instructables pointed out that their IP changed when they restarted their instance. I wasn't experiencing that until the last week when mine changed for the first time.

 

I updated Step 2 with another sub-step 6 that covers creating a Static IP reservation so it won't happen in the future.

Emerging Member
Posts: 62
Registered: ‎12-01-2014
Kudos: 4
Solutions: 2

Re: Controller on Google Cloud Platform (Free)

that was me.  Really appreciate your guide.  Only thing I would change is that I would deploy this to an SSD and just eat the cost per month as this helps with the performance of the micro deployment.

Member
Posts: 238
Registered: ‎10-07-2017
Kudos: 92
Solutions: 1

Re: Controller on Google Cloud Platform (Free)

[ Edited ]

Im just going to say i looked at Google Cloud after getting locked out of my paid instance on LightSail (twice last week), and went no thanks (on top of why continually chase trying to stay under a free limit...$5 a month, thats a cup of coffee folks...), went over to digitalocean where i should have gone in the first place...same price $5/m...and they have a VNC console to your instance, so even if you (or LightSail in my case - no support ticket option on lower tier, even paid...joke) lock yourself out of ssh access, you can login to the dashboard and VNC back into it and recover, and if thats not enough theres also a recovery image they can mount for you.

 

You are not going to get that on most of the VPS servers...certianly not on LightSail (turns head and spits) and i suspect Google Cloud free

 
 
 
My Little Project: P2P Autoban/Autounban - Uses IPS logs to detect and automatically ban & unban problem P2P users
Emerging Member
Posts: 62
Registered: ‎12-01-2014
Kudos: 4
Solutions: 2

Re: Controller on Google Cloud Platform (Free)

I'll say now that at least for me it's not about the $5/mo.  I have a colo in LA, a Knownhost VPS and a DO droplet (which now that they've increased the RAM allocated to droplets I can move down one level, until just very recently for $5 at DO you would only get 512Mb of RAM.) and I'm currently testing a Scaleway server to see how it compares to DO).   

 

For me, it's the fun part of doing something with nothing (which is one reason I love SBC's so much).  I haven't had a chance to play around with GCP and this was a way to do so.  I'm using this for my home network and the free tier may be a touch underpowered I haven't had any complaints or issues staying under the free limit.  

Reply