Creating an AMI with a Gravity-based installation

We’re looking to create an AMI that has our application installed on it, where the application is the Gravity cluster and our services running inside (so just a normal Gravity thing). Running the gravity install command takes about 6-7 minutes to complete, as it has to set up the cluster, download our images, etc.

What would be ideal for us is if during the AMI building process, we could actually run gravity install, get the cluster properly set up, and then freeze the AMI, so that new instantiations of it would just work with that installation and we could shave off that 6-7 minute startup cost (and since our application is not running at this point since we don’t have Kubernetes, it’s hard for us to even display an installation UI).

My questions are:

  1. Is there a way to “pre install” the Gravity cluster for an AMI? What are the risks?
  2. If there isn’t a way, is there a way to do some of the steps (e.g. get all the Docker images unpacked and loaded into the registry, etc) to reduce the 6-7 minute time?

Hello @itay!

Off the top of my head, the caveat here would be is that the “advertise IP” used by the cluster node is selected (or provided) during the initial installation and changing it post-installation is not something we currently support. So unless you always use 1-node clusters and can guarantee that all instances created off your AMI will get the same internal IP address, this approach likely won’t work. IIRC those of our customers who use AMIs add “gravity install” to the cloud init script which is what I’m assuming you’re doing as well.

Regarding speeding the installation up, I can’t really see what kind of “pre-work” can be done on the node because everything is packaged inside your cluster image and the installer expects the “clean” node and provisions everything from scratch… One “wild” idea would be to try to put your registry layers in the directory gravity will be exporting them to (/var/lib/gravity/planet/registry IIRC) but I’m not even sure it’ll work and this is certainly not the expected use-case (and even if it worked, it’d only probably let you shave a few seconds off of installation).

Sorry I couldn’t give a more helpful answer, let us know if you have any questions.

Thanks,
Roman