Skip to content

Commit b26e5fa

Browse files
milan-zededauncleDecart
authored andcommitted
Embed prebuilt eden-sdn VM image inside the container
Previously, the lfedge/eden-sdn container included only the SDN service layer (sdnagent and its dependencies). This change builds a complete eden-sdn VM image—including bootloader, kernel, containerd, etc.—and packages it directly into the container, similar to how EVE images are handled in lfedge/eve. This significantly speeds up the eden-sdn setup process by eliminating the need to rebuild the VM image during each `eden setup`. Additionally, the VM image now uses legacy BIOS boot instead of UEFI, which is sufficient for eden-sdn and simplifies the boot process. Finally, eden-sdn now follows its own semantic versioning, independent of eden. Its version is manually defined in `sdn/VERSION`, ensuring that eden-sdn is not unnecessarily rebuilt and published with a new image tag when unrelated eden components change. These are initial steps towards integrating eden-sdn into eden tests and github workflows. Signed-off-by: Milan Lenco <milan@zededa.com>
1 parent 00d2e6c commit b26e5fa

File tree

22 files changed

+296
-160
lines changed

22 files changed

+296
-160
lines changed

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ DO_DOCKER ?= 1
55

66
DOCKER_TARGET ?= load
77
DOCKER_PLATFORM ?= $(shell uname -s | tr '[A-Z]' '[a-z]')/$(subst aarch64,arm64,$(subst x86_64,amd64,$(shell uname -m)))
8-
LINUXKIT_TARGET ?= build
98

109
# ESERVER_TAG is the tag for eserver image to build
1110
ESERVER_TAG ?= "lfedge/eden-http-server"
@@ -33,8 +32,7 @@ ifeq ($(EDEN_VERSION),)
3332
EDEN_VERSION = $(shell git describe --always)
3433
endif
3534

36-
# SDN_DIR is the directory with eden-sdn Dockerfile to build
37-
SDN_DIR=$(CURDIR)/sdn/vm
35+
SDN_DIR=$(CURDIR)/sdn
3836

3937
# HOSTARCH is the host architecture
4038
# ARCH is the target architecture
@@ -158,9 +156,7 @@ push-multi-arch-eden:
158156
@docker buildx build --$(DOCKER_TARGET) --platform $(DOCKER_PLATFORM) --tag $(EDEN_TAG):$(EDEN_VERSION) .
159157

160158
push-multi-arch-sdn: $(LINUXKIT)
161-
$(eval SDN_TAG = $(shell $(LINUXKIT) pkg show-tag $(SDN_DIR)))
162-
@echo "$(LINUXKIT_TARGET) eden-sdn image $(SDN_TAG)"
163-
@$(LINUXKIT) pkg $(LINUXKIT_TARGET) --force --platforms $(DOCKER_PLATFORM) --docker --build-yml build.yml $(SDN_DIR)
159+
$(MAKE) -C $(SDN_DIR) LINUXKIT=$(LINUXKIT) DOCKER_TARGET=$(DOCKER_TARGET) DOCKER_PLATFORM=$(DOCKER_PLATFORM)
164160

165161
push-multi-arch-processing:
166162
@echo "Build and $(DOCKER_TARGET) processing image $(PROCESSING_TAG):$(PROCESSING_VERSION)"

cmd/edenSetup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func newSetupCmd(configName, verbosity *string) *cobra.Command {
8383
addSdnImageOpt(setupCmd, cfg)
8484
addSdnDisableOpt(setupCmd, cfg)
8585
addSdnSourceDirOpt(setupCmd, cfg)
86-
addSdnLinuxkitOpt(setupCmd, cfg)
86+
addSdnVersionOpt(setupCmd, cfg)
8787

8888
return setupCmd
8989
}

cmd/sdn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ func addSdnConfigDirOpt(parentCmd *cobra.Command, cfg *openevec.EdenSetupArgs) {
336336
parentCmd.Flags().StringVarP(&cfg.Sdn.ConfigDir, "sdn-config-dir", "", "", "directory where to put generated SDN-related config files")
337337
}
338338

339-
func addSdnLinuxkitOpt(parentCmd *cobra.Command, cfg *openevec.EdenSetupArgs) {
340-
parentCmd.Flags().StringVarP(&cfg.Sdn.LinuxkitBin, "sdn-linuxkit-bin", "", "", "path to linuxkit binary used to build SDN VM")
339+
func addSdnVersionOpt(parentCmd *cobra.Command, cfg *openevec.EdenSetupArgs) {
340+
parentCmd.Flags().StringVarP(&cfg.Sdn.Version, "sdn-version", "", defaults.DefaultSDNVersion, "Eden-SDN version")
341341
}
342342

343343
func addSdnIPv6Opt(parentCmd *cobra.Command, cfg *openevec.EdenSetupArgs) {

pkg/defaults/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const (
5959
DefaultRegistryTag = "2.7"
6060
DefaultProcTag = "83cfe07"
6161
DefaultMkimageTag = "8.5.0"
62+
DefaultSDNVersion = "v1.0.0"
6263
DefaultImage = "library/alpine"
6364
DefaultAdamContainerRef = "lfedge/adam"
6465
DefaultRedisContainerRef = "redis"

pkg/defaults/templates.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ sdn:
284284
#disable SDN
285285
disable: '{{parse "sdn.disable"}}'
286286
287+
#Eden-SDN version
288+
version: '{{parse "sdn.version"}}'
289+
287290
#directory with SDN source code
288291
source-dir: '{{parse "sdn.source-dir"}}'
289292
@@ -293,9 +296,6 @@ sdn:
293296
#live image of SDN
294297
image-file: '{{parse "sdn.image-file"}}'
295298
296-
#path to linuxkit binary used to build SDN VM
297-
linuxkit-bin: '{{parse "sdn.linuxkit-bin"}}'
298-
299299
#CPU count for SDN VM
300300
cpu: {{parse "sdn.cpu"}}
301301

pkg/edensdn/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (client *SdnClient) SSHIntoSdnVM() error {
191191
return utils.RunCommandForeground("ssh", client.sshArgs()...)
192192
}
193193

194-
// SSHPortFowarding : establish port forwarding between the host and the SDN VM using ssh.
194+
// SSHPortForwarding : establish port forwarding between the host and the SDN VM using ssh.
195195
// Close the tunnel by running returned "close" function.
196196
func (client *SdnClient) SSHPortForwarding(localPort, targetPort uint16,
197197
targetIP string) (close func(), err error) {

pkg/edensdn/qemu.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ func (vm *SdnVMQemuRunner) Start() error {
106106
// QEMU config
107107
qemuConfigPath := filepath.Join(vm.ConfigDir, "qemu.conf")
108108
settings := utils.QemuSettings{
109-
Firmware: vm.Firmware,
110109
MemoryMB: vm.RAM,
111110
CPUs: vm.CPU,
112111
}

pkg/edensdn/vm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type SdnVMConfig struct {
2929
ConfigDir string
3030
CPU int
3131
RAM int // in MB
32-
Firmware []string
3332
NetModel model.NetworkModel
3433
TelnetPort uint16
3534
SSHPort uint16

pkg/openevec/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ type GcpConfig struct {
162162
}
163163

164164
type SdnConfig struct {
165+
Version string `mapstructure:"version" cobraflag:"sdn-version"`
165166
ImageFile string `mapstructure:"image-file" cobraflag:"sdn-image-file"`
166167
SourceDir string `mapstructure:"source-dir" cobraflag:"sdn-source-dir" resolvepath:""`
167168
RAM int `mapstructure:"ram" cobraflag:"sdn-ram"`
168169
CPU int `mapstructure:"cpu" cobraflag:"sdn-cpu"`
169170
ConfigDir string `mapstructure:"config-dir" cobraflag:"sdn-config-dir" resolvepath:""`
170-
LinuxkitBin string `mapstructure:"linuxkit-bin" cobraflag:"sdn-linuxkit-bin" resolvepath:""`
171171
NetModelFile string `mapstructure:"network-model" cobraflag:"sdn-network-model" resolvepath:""`
172172
ConsoleLogFile string `mapstructure:"console-log" cobraflag:"sdn-console-log" resolvepath:""`
173173
Disable bool `mapstructure:"disable" cobraflag:"sdn-disable"`

pkg/openevec/defaults.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func GetDefaultConfig(projectRootPath string) (*EdenSetupArgs, error) {
185185
},
186186

187187
Sdn: SdnConfig{
188+
Version: defaults.DefaultSDNVersion,
188189
RAM: defaults.DefaultSdnMemory,
189190
CPU: defaults.DefaultSdnCpus,
190191
ConsoleLogFile: filepath.Join(projectRootPath, defaults.DefaultDist, "sdn-console.log"),
@@ -195,8 +196,7 @@ func GetDefaultConfig(projectRootPath string) (*EdenSetupArgs, error) {
195196
SSHPort: defaults.DefaultSdnSSHPort,
196197
SourceDir: filepath.Join(projectRootPath, "sdn"),
197198
ConfigDir: filepath.Join(edenDir, fmt.Sprintf("%s-sdn", "default")),
198-
ImageFile: filepath.Join(imageDist, "eden", "sdn-efi.qcow2"),
199-
LinuxkitBin: filepath.Join(projectRootPath, defaults.DefaultBuildtoolsDir, "linuxkit"),
199+
ImageFile: filepath.Join(imageDist, "eden", "eden-sdn.qcow2"),
200200
NetModelFile: "",
201201
EnableIPv6: false,
202202
IPv6Subnet: defaults.DefaultSdnIPv6Subnet,

0 commit comments

Comments
 (0)