Closed tewfik-ghariani closed 4 years ago
@AmineChikhaoui Could you check this PR?
Hello again :))
As a result of the meeting with @AmineChikhaoui and based on his remarks, updated the code in a way to make it more intuitive to create root disks or separate disks from a public image.
The usage syntax shall be as simple as the following :
machine = {
deployment.gce = {
bootstrapImage = {
name = "base-image-bootstrap";
family = null;
project = "nixos-org";
};
};
}
resources.gceDisks.main-volume = {
image = {
name = null;
family = "super-family";
project = "another-project";
};
};
I've completed my work based on the new changes related to types and options per #7
Change log
The imageOptions contains the following :
- image : either image-resource or the name of an existing image
- family : the image family to be used
- project : the parent project containing the image/imageFamily
Note that we have to specify either name or family. Default value = {} Then adjusted the image option to inherit from the imageOptions submodule in
- gceDiskOptions in gce.nix
- gce-disk.nix Finally, updated the bootstrapImage gce option accordingly
- Created a new common retrieve_gce_image method to fetch the GCENodeImage object.
- Removed the publicImageProject attribute
- Upgraded libcloud
- Ignored libcloud mypy annotations
Full list of changes : https://github.com/nix-community/nixops-gce/compare/master...tewfik-ghariani:gcp-plugin
cc @AmineChikhaoui , @adisbladis can you review please? Or do you prefer if I create a new PR?
For some reason, the changes are no longer visible and the commit log has gotten confusing. Maybe it's because the second PR containing the original changes was already merged and this branch was re-based of master
In any case, I will be closing this PR and creating a new one
Cheers :))
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
Background
After reading some docs related to running NixOs on GCE, I've seen that we currently have to bootstrap our own image from an object publicly shared in GS according to this : https://nixos.wiki/wiki/Install_NixOS_on_GCE
And at this time, the nixops-gcp plugin is deemed broken specifically due to this particular 'bootstrap-image' resource
Proposed Solution
However, according to the GCP docs, we can actually just bake some images in a given GCP account, and then make the images public. https://cloud.google.com/compute/docs/images/managing-access-custom-images#share-images-publicly
Even better, we may create image families to allow better flexibility to manage single images. No need to specify the machine name per say but just the family. And under the hood, the maintainer may deprecate old ones and keep the 'latest' up-to-date.
Validation
I started by testing the whole scenario using gcloud commands and it worked like a charm!
Building an image from source
Making the image public
And then that image may be used publicly so that all nixops users won't have the need to provision their own 'bootstrap-image' resource for every deployment.
Implementation
Implemented the change described above in this codebase and the gce plugins should be working fine now.
The way it works
A summary of what has been achieved overall
Small Additions
ToDo
Please let me know what do you think about this. If you have any suggestions or recommendations, feel free to share them. cc @PsyanticY @AmineChikhaoui
cc @rbvermaa Can we consider this as part of https://github.com/NixOS/nixpkgs/issues/6991