Skip to content

Commit

Permalink
feat: Include kernel modules as AdditionalVolumes
Browse files Browse the repository at this point in the history
In line with changes to our image-builder pipeline, which removes the
embedded kernel modules from the OS image, this feature adds an option
to include modules as an additional volume.

Templates and docs have been updated.

Old images and options will remain available to not break those using
earlier versions.
  • Loading branch information
Callisto13 committed Jan 6, 2023
1 parent 8d1221d commit 60455eb
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 34 deletions.
6 changes: 5 additions & 1 deletion api/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ type Volume struct {
// ID is a unique identifier for this volume.
// +kubebuilder:validation:Required
ID string `json:"id"`
// Image is the container image to use for the volume.
// Image is the container image to use as the source for the volume.
// +kubebuilder:validation:Required
Image string `json:"image"`
// ReadOnly specifies that the volume is to be mounted readonly.
// +kubebuilder:default:=false
// +optional
ReadOnly bool `json:"readOnly,omitempty"`
// MountPoint specifies the guest mountpoint for the volume.
// This will only be applied to additional volumes.
// +optional
MountPoint string `json:"destination,omitempty"`
}

// IfaceType is a type representing the network interface types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ spec:
description: RootVolume specifies the volume to use for the root of
the microvm.
properties:
destination:
description: MountPoint specifies the guest mountpoint for the
volume. This will only be applied to additional volumes.
type: string
id:
description: ID is a unique identifier for this volume.
type: string
image:
description: Image is the container image to use for the volume.
description: Image is the container image to use as the source
for the volume.
type: string
readOnly:
default: false
Expand Down Expand Up @@ -159,11 +164,16 @@ spec:
items:
description: Volume represents a volume to be attached to a microvm.
properties:
destination:
description: MountPoint specifies the guest mountpoint for the
volume. This will only be applied to additional volumes.
type: string
id:
description: ID is a unique identifier for this volume.
type: string
image:
description: Image is the container image to use for the volume.
description: Image is the container image to use as the source
for the volume.
type: string
readOnly:
default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,17 @@ spec:
description: RootVolume specifies the volume to use for the
root of the microvm.
properties:
destination:
description: MountPoint specifies the guest mountpoint
for the volume. This will only be applied to additional
volumes.
type: string
id:
description: ID is a unique identifier for this volume.
type: string
image:
description: Image is the container image to use for the
volume.
description: Image is the container image to use as the
source for the volume.
type: string
readOnly:
default: false
Expand Down Expand Up @@ -199,12 +204,17 @@ spec:
description: Volume represents a volume to be attached to
a microvm.
properties:
destination:
description: MountPoint specifies the guest mountpoint
for the volume. This will only be applied to additional
volumes.
type: string
id:
description: ID is a unique identifier for this volume.
type: string
image:
description: Image is the container image to use for
the volume.
description: Image is the container image to use as
the source for the volume.
type: string
readOnly:
default: false
Expand Down
7 changes: 4 additions & 3 deletions docs/development-with-tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ Create the declaration for your cluster. We will use the template in the repo.
3. Create a cluster declaration from the template

```bash
export KUBERNETES_VERSION=v1.20.0
export KUBERNETES_VERSION=v1.23.5
export CLUSTER_NAME=mvm-test
export CONTROL_PLANE_MACHINE_COUNT=1
export WORKER_MACHINE_COUNT=1
export CONTROL_PLANE_VIP=192.168.8.15
export MVM_ROOT_IMAGE=docker.io/richardcase/ubuntu-bionic-test:cloudimage_v0.0.1
export MVM_KERNEL_IMAGE=docker.io/richardcase/ubuntu-bionic-kernel:0.0.11
export MVM_ROOT_IMAGE=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5
export MVM_KERNEL_IMAGE=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77
export MVM_KERNEL_MODULES_IMAGE=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77
# NOTE: change 192.168.8.2 to be the IP address from step 2
export HOST_ENDPOINT=192.168.8.2:9090
Expand Down
10 changes: 8 additions & 2 deletions internal/services/microvm/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ func convertToFlintlockAPI(machineScope *scope.MachineScope) *flintlocktypes.Mic
for i := range mvmSpec.AdditionalVolumes {
volume := mvmSpec.AdditionalVolumes[i]

apiVM.AdditionalVolumes = append(apiVM.AdditionalVolumes, &flintlocktypes.Volume{
addVol := &flintlocktypes.Volume{
Id: volume.ID,
IsReadOnly: volume.ReadOnly,
Source: &flintlocktypes.VolumeSource{
ContainerSource: &volume.Image,
},
})
}

if volume.MountPoint != "" {
// addVol.MountPoint = &volume.MountPoint
}

apiVM.AdditionalVolumes = append(apiVM.AdditionalVolumes, addVol)
}

apiVM.Interfaces = []*flintlocktypes.NetworkInterface{}
Expand Down
20 changes: 14 additions & 6 deletions templates/cluster-template-cilium.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: "${KUBERNETES_VERSION:=v1.21.8}"
version: "${KUBERNETES_VERSION:=v1.23.5}"
machineTemplate:
infrastructureRef:
kind: MicrovmMachineTemplate
Expand Down Expand Up @@ -76,10 +76,14 @@ spec:
memoryMb: 2048
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.21.8}"
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5}"
kernel:
filename: "boot/vmlinux"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77}"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77}"
additionalVolumes:
- id: modules
image: "${MVM_KERNEL_MODULES_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77}"
mountPoint: /lib/modules
kernelCmdline: {}
networkInterfaces:
- guestDeviceName: "eth1"
Expand All @@ -97,7 +101,7 @@ spec:
template:
spec:
clusterName: "${CLUSTER_NAME}"
version: "${KUBERNETES_VERSION:=v1.21.8}"
version: "${KUBERNETES_VERSION:=v1.23.5}"
bootstrap:
configRef:
name: "${CLUSTER_NAME}-md-0"
Expand All @@ -119,10 +123,14 @@ spec:
memoryMb: 2048
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.21.8}"
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5}"
kernel:
filename: "boot/vmlinux"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77}"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77}"
additionalVolumes:
- id: modules
image: "${MVM_KERNEL_MODULES_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77}"
mountPoint: /lib/modules
kernelCmdline: {}
networkInterfaces:
- guestDeviceName: "eth1"
Expand Down
28 changes: 18 additions & 10 deletions templates/cluster-template-flannel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: "${KUBERNETES_VERSION:=v1.21.8}"
version: "${KUBERNETES_VERSION:=v1.23.5}"
machineTemplate:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
Expand Down Expand Up @@ -74,17 +74,21 @@ metadata:
spec:
template:
spec:
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5}"
kernel:
filename: boot/vmlinux
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77}"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77}"
additionalVolumes:
- id: modules
image: "${MVM_KERNEL_MODULES_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77}"
mountPoint: /lib/modules
kernelCmdline: {}
memoryMb: 2048
networkInterfaces:
- guestDeviceName: eth1
type: macvtap
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.21.8}"
vcpu: 2
---
apiVersion: cluster.x-k8s.io/v1beta1
Expand All @@ -99,7 +103,7 @@ spec:
template:
spec:
clusterName: "${CLUSTER_NAME}"
version: "${KUBERNETES_VERSION:=v1.21.8}"
version: "${KUBERNETES_VERSION:=v1.23.5}"
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
Expand All @@ -117,17 +121,21 @@ metadata:
spec:
template:
spec:
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5}"
kernel:
filename: boot/vmlinux
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77}"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77}"
additionalVolumes:
- id: modules
image: "${MVM_KERNEL_MODULES_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77}"
mountPoint: /lib/modules
kernelCmdline: {}
memoryMb: 2048
networkInterfaces:
- guestDeviceName: eth1
type: macvtap
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.21.8}"
vcpu: 2
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
Expand Down
20 changes: 14 additions & 6 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: "${KUBERNETES_VERSION:=v1.21.8}"
version: "${KUBERNETES_VERSION:=v1.23.5}"
machineTemplate:
infrastructureRef:
kind: MicrovmMachineTemplate
Expand Down Expand Up @@ -72,10 +72,14 @@ spec:
memoryMb: 2048
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.21.8}"
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5}"
kernel:
filename: "boot/vmlinux"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77}"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77}"
additionalVolumes:
- id: modules
image: "${MVM_KERNEL_MODULES_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77}"
mountPoint: /lib/modules
kernelCmdline: {}
networkInterfaces:
- guestDeviceName: "eth1"
Expand All @@ -93,7 +97,7 @@ spec:
template:
spec:
clusterName: "${CLUSTER_NAME}"
version: "${KUBERNETES_VERSION:=v1.21.8}"
version: "${KUBERNETES_VERSION:=v1.23.5}"
bootstrap:
configRef:
name: "${CLUSTER_NAME}-md-0"
Expand All @@ -115,10 +119,14 @@ spec:
memoryMb: 2048
rootVolume:
id: root
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.21.8}"
image: "${MVM_ROOT_IMAGE:=ghcr.io/weaveworks-liquidmetal/capmvm-kubernetes:1.23.5}"
kernel:
filename: "boot/vmlinux"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/flintlock-kernel:5.10.77}"
image: "${MVM_KERNEL_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-bin:5.10.77}"
additionalVolumes:
- id: modules
image: "${MVM_KERNEL_MODULES_IMAGE:=ghcr.io/weaveworks-liquidmetal/kernel-modules:5.10.77}"
mountPoint: /lib/modules
kernelCmdline: {}
networkInterfaces:
- guestDeviceName: "eth1"
Expand Down

0 comments on commit 60455eb

Please sign in to comment.