Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aws image generation based of the raw image #338

Merged
merged 2 commits into from
Jun 29, 2021

Conversation

Itxaka
Copy link
Contributor

@Itxaka Itxaka commented Jun 28, 2021

Uses the new cos-deploy script to install the image from recovery and
the user-data facility to partition the disk

As a side effect it moves from using json to using HCL for packer as json is no longer receiving any features and HCL is the recommended config language for packer

If HCL is not liked, I can easily revert to using plain json, but it had some issues on selecting the ami image using regex. HCL allows us to use "cos*recovery" and use latest to pick the latest recovery image and not have any issues with selecting the wrong image. I could not make the same work on json templates.

Fixes #302

Signed-off-by: Itxaka [email protected]

@Itxaka
Copy link
Contributor Author

Itxaka commented Jun 28, 2021

This has been tested by creating a raw image from master, uploading it to s3, creating a snapshot then turning that snapshot into an ami (cos_0.5.6-recovery.raw)

Then launching the packer process and deploying version 0.5.5 from the repositories snapshooting the image and manually booting from it to test that it was working.

provisioner "shell" {
only = ["amazon-ebs.cos"]
inline = [
"cos-deploy --docker-image quay.io/costoolkit/releases-opensuse:cos-system-${var.cos_version}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just leave this open as an entire variable, like container_image. In this way the template can be used to bootstrap also images from external images too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good point!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this? or the full url?

Thing is, we can take advantage of the cos version for several places

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but this ideally should work also with custom images, not only for cOS ones, and we can't assume they are using luet for the building process. I would really let open to a cos-deploy-args even for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about now?

Still, I think we are confusing things here. We are providing packer templates for our own use, to publish our images. We dont have an obligation to provide packer templates for derivatives or other customers.

We can provide examples, but those examples are not gonna be anything out of the ordinary from any example packer templates as they will use our published image as base, which is ready for consumption and then they can expand on that to build their own images following the packer documentation on how to provision stuff.

We need a clear separation here, because making OUR own stuff too flexible just in case someone uses it, only causes us identity issues. Is this for us, is this for derivatives? We should have a clear line here, this is for OUR deployment of images, here are also some examples on how to consume our images with packer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that was clear from the card, but apparently it wasn't 😅 sorry !

The packer templates for Cloud are for derivatives/users only, as long as we don't need them internally to provide base images. The fact that we use packer to spin up images used for tests is for convenience, but it is flexible enough to be re-used for derivatives too in case of need.

We could also use raw disks for tests for example, but then we don't have a way to see if we break the installation process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but...wont we need to publish images to cloud providers so others can consume them? ITs a different process altogether I think. In aws, are we gonna provide derivatives a recovery image instead of a fully released image??? Doesn't seem good to me, they will need to actually install the system and then once the image is "working" deploy their stuff.. I havent seen an image that works like that in a cloud provider, they are all ready images so your first launch with user data can configure it completely.

Copy link
Contributor

@mudler mudler Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what we are going to publish is only vanilla images where only the recovery partition is working.

cOS is not meant to actually be used by per-se, but it's main use is to allow a complete system customization via container images. The recovery image just serves the purpose to bootstrap the minimal required to run the container image you supply (and taking later upgrades from). That can be a system/cos image (the one we use), but that could be a foo/bar image that will later on pickup upgrades from its configuration, and so on so forth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that clarifies it a lot! Then I think down the line we may need a refactor of the templates to separate everything so it's easier for derivatives to work with! Even a readme to provide a pck.vars file by the user with the proper vars instead of cli args and some vars descriptions

provisioner "shell" {
only = ["amazon-ebs.cos"]
inline = [
"cos-deploy --docker-image ${var.cos_install_url}:cos-system-${var.cos_version}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmh images don't necessarly have to follow that schema, users might also pick something like myimage:testing or myimage:latest. I think we should also account that verification might be skipped as well during this process

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats what I though :(

Uses the new cos-deploy script to install the image from recovery and
the user-data facility to partition the disk

Signed-off-by: Itxaka <[email protected]>
ssh_username = "root"
source_ami_filter {
filters = {
name = "*cos*recovery*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also probably this one too should be customizable, with a default (like this one)

@mudler mudler enabled auto-merge (squash) June 29, 2021 10:24
@mudler mudler mentioned this pull request Jun 29, 2021
@mudler mudler merged commit 7085566 into rancher:master Jun 29, 2021
@Itxaka Itxaka mentioned this pull request Jul 1, 2021
frelon pushed a commit to frelon/elemental-toolkit that referenced this pull request May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build AWS Images with Packer
2 participants