Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Treat kernels as OCI images #105

Merged
merged 4 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/ignite.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,9 @@ This file is stored in /var/lib/firecracker/kernels/{oci-image-digest}/metadata.



## <a name="KernelSpec">type</a> [KernelSpec](/src/target/types.go?s=5245:5459#L136)
## <a name="KernelSpec">type</a> [KernelSpec](/src/target/types.go?s=5245:5418#L136)
``` go
type KernelSpec struct {
Version string `json:"version"`
OCIClaim OCIImageClaim `json:"ociClaim"`
}

Expand All @@ -283,9 +282,10 @@ KernelSpec describes the properties of a kernel



## <a name="KernelStatus">type</a> [KernelStatus](/src/target/types.go?s=5510:5583#L144)
## <a name="KernelStatus">type</a> [KernelStatus](/src/target/types.go?s=5469:5583#L143)
``` go
type KernelStatus struct {
Version string `json:"version"`
OCISource OCIImageSource `json:"ociSource"`
}

Expand Down
16 changes: 8 additions & 8 deletions api/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions cmd/ignite/cmd/imgcmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
Expand All @@ -15,7 +14,7 @@ import (
func NewCmdImage(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "image",
Short: "Manage VM base images",
Short: "Manage base images for VMs",
Long: dedent.Dedent(`
Groups together functionality for managing VM base images.
Calling this command alone lists all available images.
Expand Down
20 changes: 6 additions & 14 deletions cmd/ignite/cmd/imgcmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@ import (
// NewCmdImport imports a new VM image
func NewCmdImport(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "import <source>",
Use: "import <OCI image>",
Short: "Import a new base image for VMs",
Long: dedent.Dedent(`
Import a new base image for VMs, takes in a Docker image as the source.
The base image is an ext4 block device file, which contains a root filesystem.

If a kernel is found in the image, /boot/vmlinux is extracted from it
and imported to a kernel with the same name.

Example usage:
$ ignite image import luxas/ubuntu-base:18.04
Import a base image from an OCI image for VMs, takes in a Docker image as the source.
This importing is done automatically when the run or create commands are run. This step
is essentially a cache to be used later when running VMs.
`),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
errutils.Check(func() error {
io, err := run.NewImportOptions(args[0])
if err != nil {
return err
}
return run.Import(io)
_, err := run.ImportImage(args[0])
return err
}())
},
}
Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/imgcmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/imgcmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil"
Expand Down
31 changes: 31 additions & 0 deletions cmd/ignite/cmd/kerncmd/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package kerncmd

import (
"io"

"github.com/lithammer/dedent"
"github.com/spf13/cobra"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
)

// NewCmdImport imports a new kernel image
func NewCmdImport(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "import <OCI image>",
Short: "Import a kernel image from an OCI image",
Long: dedent.Dedent(`
Import a kernel image from an OCI image for VMs, takes in a Docker image as the source.
This importing is done automatically when the run or create commands are run. This step
is essentially a cache to be used later when running VMs.
`),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
errutils.Check(func() error {
_, err := run.ImportKernel(args[0])
return err
}())
},
}
return cmd
}
1 change: 1 addition & 0 deletions cmd/ignite/cmd/kerncmd/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewCmdKernel(out io.Writer) *cobra.Command {
},
}

cmd.AddCommand(NewCmdImport(out))
cmd.AddCommand(NewCmdLs(out))
cmd.AddCommand(NewCmdRm(out))
return cmd
Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/kerncmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/kerncmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil"
Expand Down
11 changes: 5 additions & 6 deletions cmd/ignite/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import (
"io"
"os"

"github.com/lithammer/dedent"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/cmd/imgcmd"
"github.com/weaveworks/ignite/cmd/ignite/cmd/kerncmd"
"github.com/weaveworks/ignite/cmd/ignite/cmd/vmcmd"
"github.com/weaveworks/ignite/pkg/logs"
"github.com/weaveworks/ignite/pkg/util"

"github.com/lithammer/dedent"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// NewIgniteCommand returns the root command for ignite
Expand Down Expand Up @@ -58,9 +57,9 @@ func NewIgniteCommand(in io.Reader, out, err io.Writer) *cobra.Command {

Example usage:

$ ignite run weaveworks/ignite-ubuntu \
$ ignite run centos:7 \
--cpus 2 \
--memory 1024 \
--memory 2GB \
--ssh \
--name my-vm
$ ignite images
Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/vmcmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
Expand Down
15 changes: 8 additions & 7 deletions cmd/ignite/cmd/vmcmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/constants"
"github.com/weaveworks/ignite/pkg/errutils"
)

Expand All @@ -16,24 +17,24 @@ func NewCmdCreate(out io.Writer) *cobra.Command {
cf := run.NewCreateFlags()

cmd := &cobra.Command{
Use: "create <image>",
Use: "create <OCI image>",
Short: "Create a new VM without starting it",
Long: dedent.Dedent(`
Create a new VM by combining the given image and kernel.
Various VM tunables can be set during creation by using
the flags for this command. The image and kernel are
matched by prefix based on their ID and name.
Various configuration options can be set during creation by using
the flags for this command.

If the name flag (-n, --name) is not specified,
the VM is given a random name. Using the copy files
flag (-f, --copy-files), additional files can be added to
the VM during creation with the syntax /host/path:/vm/path.

Example usage:
$ ignite create my-image my-kernel \
$ ignite create centos:7 \
--name my-vm \
--cpus 2 \
--memory 2048 \
--ssh \
--memory 2GB \
--size 6GB
`),
Args: cobra.RangeArgs(0, 1),
Expand All @@ -60,7 +61,7 @@ func addCreateFlags(fs *pflag.FlagSet, cf *run.CreateFlags) {
cmdutil.SizeVar(fs, &cf.VM.Spec.Memory, "memory", cf.VM.Spec.Memory, "Amount of RAM to allocate for the VM")
cmdutil.SizeVarP(fs, &cf.VM.Spec.DiskSize, "size", "s", cf.VM.Spec.DiskSize, "VM filesystem size, for example 5GB or 2048MB")
fs.StringSliceVarP(&cf.CopyFiles, "copy-files", "f", nil, "Copy files from the host to the created VM")
fs.StringVarP(&cf.KernelName, "kernel", "k", "", "Specify a kernel to use. By default this equals the image name")
fs.StringVarP(&cf.KernelClaimRef, "kernel-image", "k", constants.DEFAULT_KERNEL_IMAGE, "Specify an OCI image containing the kernel at /boot/vmlinux and optionally, modules")
fs.StringVar(&cf.VM.Spec.Kernel.CmdLine, "kernel-args", cf.VM.Spec.Kernel.CmdLine, "Set the command line for the kernel")

cf.SSH = &run.SSHFlag{}
Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/vmcmd/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
Expand Down
4 changes: 1 addition & 3 deletions cmd/ignite/cmd/vmcmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/weaveworks/ignite/cmd/ignite/run"

"github.com/spf13/cobra"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/vmcmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/run"
Expand Down
1 change: 0 additions & 1 deletion cmd/ignite/cmd/vmcmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/cmd/cmdutil"
Expand Down
9 changes: 4 additions & 5 deletions cmd/ignite/cmd/vmcmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"

"github.com/lithammer/dedent"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/run"
Expand All @@ -19,7 +18,7 @@ func NewCmdRun(out io.Writer) *cobra.Command {
}

cmd := &cobra.Command{
Use: "run <image>",
Use: "run <OCI image>",
Short: "Create a new VM and start it",
Long: dedent.Dedent(`
Create and start a new VM immediately. The image and kernel are matched by
Expand All @@ -28,12 +27,12 @@ func NewCmdRun(out io.Writer) *cobra.Command {
specified to immediately attach to the started VM after creation.

Example usage:
$ ignite run weaveworks/ignite-ubuntu \
--kernel weaveworks/ignite-ubuntu \
$ ignite run centos:7 \
--interactive \
--name my-vm \
--cpus 2 \
--memory 2048 \
--ssh \
--memory 2GB \
--size 10G
`),
Args: cobra.RangeArgs(0, 1),
Expand Down
3 changes: 1 addition & 2 deletions cmd/ignite/cmd/vmcmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"io"

"github.com/lithammer/dedent"
"github.com/spf13/pflag"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
)
Expand Down
5 changes: 2 additions & 3 deletions cmd/ignite/cmd/vmcmd/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package vmcmd
import (
"io"

"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"

"github.com/lithammer/dedent"
"github.com/spf13/cobra"
"github.com/weaveworks/ignite/cmd/ignite/run"
"github.com/weaveworks/ignite/pkg/errutils"
)

// NewCmdVM handles VM-related functionality via its subcommands
Expand Down
Loading