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

enki should be able to convert an image to Kairos #1721

Closed
jimmykarily opened this issue Aug 14, 2023 · 6 comments
Closed

enki should be able to convert an image to Kairos #1721

jimmykarily opened this issue Aug 14, 2023 · 6 comments
Assignees

Comments

@jimmykarily
Copy link
Contributor

jimmykarily commented Aug 14, 2023

Part of: #1546

When the user specified a Dockefile or a base (non-Kairos) image, the image has to be converted to Kairos the same way we do using Earthly in our release pipelines.

This conversion from vanilla OS to Kairos has a well defined logic but it's currently implemented in Earthly. We will implement it in enki instead so that we can use Auroraboot to convert vanilla images to Kairos.

Eventually, we should be able to replace the Earthly targets in our pipelines with calls to auroraboot.

@jimmykarily jimmykarily converted this from a draft issue Aug 14, 2023
@jimmykarily jimmykarily moved this from Todo 🖊 to In Progress 🏃 in 🧙Issue tracking board Aug 14, 2023
@jimmykarily jimmykarily self-assigned this Aug 14, 2023
@jimmykarily
Copy link
Contributor Author

We had a discussion and this is what the process should look like:

  • We take the user's Dockerfile or image
  • We create a multi-stage Dockerfile that combines the user's Dockerfile/image with one from us
  • In "our" part of the dockerfile, we copy over all the overlay files and binaries from the framework image
  • We also generate the initramfs
  • [TBD] Generate an /etc/os-release file (what info should this file include?)
  • Build the multi-stage dockefile with kaniko
  • Generate additional artifacts from the image (iso, etc)
  • Done

To make this happen, we need to have one single framework image for all flavors/models/etc. and blindly copy
all overlay files in place. The scripts themselves should have all the logic on whether they should have any effect or not. E.g. Instead of checking in the dockerfile/earthlyfile whether to copy an overlay file, the overlay file should decide whether to do something or not, by checking if it's running on that specific model/flavor. It should use the kairos-agent to infer the needed information (e.g. like we do here)

@jimmykarily
Copy link
Contributor Author

Created a story for the work on the overlay files: #1726

jimmykarily added a commit to kairos-io/osbuilder that referenced this issue Aug 31, 2023
Will happen as part of this: kairos-io/kairos#1721

Signed-off-by: Dimitris Karakasilis <[email protected]>
jimmykarily added a commit to kairos-io/osbuilder that referenced this issue Aug 31, 2023
* Add fields to the CRDs

Signed-off-by: Dimitris Karakasilis <[email protected]>

* WIP Create test

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Refactor code to split in testable functions

Signed-off-by: Dimitris Karakasilis <[email protected]>

* WIP

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Do something actually useful in tests

- Create a random namespace
- Create an artifact
- Check that CreateConfigmap doesn't error

Signed-off-by: Dimitris Karakasilis <[email protected]>

* WIP

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Refactor before each so that we can change the artifact object per test

Signed-off-by: Dimitris Karakasilis <[email protected]>

* WIP

Signed-off-by: Dimitris Karakasilis <[email protected]>

* WIP

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Run kaniko to build the Dockerfile

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Build the image from Dockerfile with kaniko

Currently can build an image. For example apply these:

```
kind: Secret
apiVersion: v1
metadata:
  name: mydockerfile
stringData:
  Dockerfile: |
    FROM ubuntu
    RUN touch myfile

---
kind: OSArtifact
apiVersion: build.kairos.io/v1alpha2
metadata:
  name: hello-kairos
spec:
  imageName: "quay.io/kairos/core-opensuse-leap:latest"
  baseImageDockerfile:
    name: "mydockerfile"
    key: "Dockerfile"
  iso: true
```

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Clarify that convert-to-kairos is not yet implemented

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Remove implemented TODO

Signed-off-by: Dimitris Karakasilis <[email protected]>

* WIP

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Bump linting action

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Fix linting errors

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Bump it again

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Unexport function and run controller tests in CI

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Unexport the other one too

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Extract case to a function

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Split controller tests in a separate job

so that they run on a fresh cluster and they run in parallel

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Remove non-implemented functionality

Will happen as part of this: kairos-io/kairos#1721

Signed-off-by: Dimitris Karakasilis <[email protected]>

* go mod tidy

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Try to use a random (free) port in tests

because sometimes we collide

Signed-off-by: Dimitris Karakasilis <[email protected]>

---------

Signed-off-by: Dimitris Karakasilis <[email protected]>
@jimmykarily
Copy link
Contributor Author

WIP here: kairos-io/osbuilder#96

@jimmykarily jimmykarily moved this from In Progress 🏃 to Todo 🖊 in 🧙Issue tracking board Sep 25, 2023
@jimmykarily jimmykarily moved this from Todo 🖊 to In Progress 🏃 in 🧙Issue tracking board Sep 25, 2023
@jimmykarily jimmykarily moved this from In Progress 🏃 to Todo 🖊 in 🧙Issue tracking board Sep 25, 2023
@jimmykarily jimmykarily moved this from Todo 🖊 to In Progress 🏃 in 🧙Issue tracking board Oct 2, 2023
@jimmykarily
Copy link
Contributor Author

We discussed this with Mauro and Ettore. This is what we decided to do instead of enki.

Our current Dockerfiles already implement a way to build certain flavors. The problem is that a flavor assumes a certain base image (flavor and base image go together).

We will differentiate the base image from the "strategy" (which is what we call a "flavor"). A "strategy" is a number of steps we take to configure the given base image. For example:

  • building ubuntu 20.04 with the ubuntu-20.04 strategy

What this allows us to do, is to let the user build on top of any base image, using any strategy. E.g.

  • build my base image which is a customized ubuntu 20.04 with the ubuntu-20.04 strategy

but also more "dangerous" things like:

  • build my base image which is a customized ubuntu 18.04 with the ubuntu-20.04 strategy

This requires minimum changes to our dockerfiles. e.g.

24,25c24
< ARG BASEIMAGE
< FROM ${BASEIMAGE} AS ubuntu-upstream
---
> FROM ubuntu:rolling AS ubuntu-upstream
27c26
< FROM ${BASEIMAGE} AS ubuntu-20-lts-upstream
---
> FROM ubuntu:20.04 AS ubuntu-20-lts-upstream
29c28
< FROM ${BASEIMAGE} AS ubuntu-22-lts-upstream
---
> FROM ubuntu:22.04 AS ubuntu-22-lts-upstream

We then only have to implement some logic to select the right Dockerfile for the "strategy" the user wants (e.g. nvidia strategy is on a different dockerfile right now).

We also need to move the rest of the logic from Earthly base-image target to the Dockerfiles themselves. Then in Earthly we have very little things to do (which don't necessarily require Earthly at all).

@jimmykarily
Copy link
Contributor Author

Closing in favor of: #1898

@github-project-automation github-project-automation bot moved this from In Progress 🏃 to Done ✅ in 🧙Issue tracking board Oct 9, 2023
@jimmykarily
Copy link
Contributor Author

Also this follow up: #1897

after #1897 , one should only need docker/kaniko in order and our Dockerfiles in order to build a Kairos container image. The rest of the story is described here: #1633 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant