sealer icon indicating copy to clipboard operation
sealer copied to clipboard

Feature: build cluster image with buildah

Open justadogistaken opened this issue 2 years ago • 5 comments

Describe what this PR does / why we need it

Sealer has integrated the buildah to build a cluster image. But There are some todos.

  1. How to save container images? solution: scan the whole kubefile, pre-download all "http://" to build context. And check the image: of them, then save then in registry under build context. Finally add an instruction COPY registry / before real building procedure.

  2. Semantic translator. All basic instructions are FROM, ADD, COPY, RUN. We will implement all new instructions based on these basics. So we are going to need a Semantic translator.

A brief flow as following: sealer-build drawio

todos:

  • [x] deal with the flags from buildah
  • [x] commit images by buildah.
  • [x] find a place for flags
  • [x] find a place for global info. Like authfile
  • [x] support for sealer rootfs
  • [x] sealer v1.Image refactor. And annotate it to oci image.
  • [x] list sealer images only for images. Add label to image.
  • [ ] clean environment after build.
  • [ ] multiple platform support.

justadogistaken avatar Jul 28 '22 09:07 justadogistaken

Maybe the sealer imageSpec and image is not in need any more.

// ImageSpec defines the desired state of Image
type ImageSpec struct {
	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
	// Important: Run "make" to regenerate code after modifying this file

	// Foo is an example field of Image. Edit Image_types.go to remove/update
	ID            string      `json:"id,omitempty"`
	Layers        []Layer     `json:"layers,omitempty"`
	SealerVersion string      `json:"sealer_version,omitempty"`
	Platform      Platform    `json:"platform"`
	ImageConfig   ImageConfig `json:"image_config"`
}

The ImageConfig is valuable probably.

type ImageConfig struct {
	// define this image is application image or normal image.
	ImageType string            `json:"image_type,omitempty"`
	Cmd       ImageCmd          `json:"cmd,omitempty"`
	Args      ImageArg          `json:"args,omitempty"`
	Labels    map[string]string `json:"labels,omitempty"`
}

We can store essential information in annotations of manifest from OCI v1 image.

type ImageCmd struct {
	//cmd list of base image
	Parent []string `json:"parent,omitempty"`
	//cmd list of current image
	Current []string `json:"current,omitempty"`
}

type ImageArg struct {
	//arg set of base image
	Parent map[string]string `json:"parent,omitempty"`
	//arg set of current image
	Current map[string]string `json:"current,omitempty"`
}

For the Cmd and Arg, I think we don't need to record the data from parent image.

justadogistaken avatar Jul 29 '22 02:07 justadogistaken

@sealerio/sealer-maintainers @sealerio/sealer-reviewers Help me review this, plz.

justadogistaken avatar Aug 09 '22 12:08 justadogistaken

Codecov Report

Merging #1611 (4e6d169) into main (2a89fa5) will increase coverage by 0.03%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #1611      +/-   ##
==========================================
+ Coverage   14.04%   14.08%   +0.03%     
==========================================
  Files          78       78              
  Lines        6691     6675      -16     
==========================================
  Hits          940      940              
+ Misses       5637     5621      -16     
  Partials      114      114              
Impacted Files Coverage Δ
apply/apply.go 0.00% <0.00%> (ø)
pkg/filesystem/filesystem.go 0.00% <0.00%> (ø)
utils/os/readers.go 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Aug 10 '22 06:08 codecov-commenter

related issues will be fixed. https://github.com/sealerio/sealer/issues/1581 https://github.com/sealerio/sealer/issues/1538

justadogistaken avatar Aug 13 '22 12:08 justadogistaken

@justadogistaken Conflict happens. Please update this ASAP. And we will merge this with high priority.

allencloud avatar Aug 15 '22 02:08 allencloud

/test apply

justadogistaken avatar Aug 15 '22 03:08 justadogistaken

LGTM, great work 👍🏻

allencloud avatar Aug 15 '22 07:08 allencloud