mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-26 17:11:19 +02:00
feat(initramfs): set the platform explicitly (#124)
This commit is contained in:
parent
b48884b037
commit
ca93edeb4a
@ -108,7 +108,7 @@ DEFAULT Dianemo
|
||||
LABEL Dianemo
|
||||
KERNEL /boot/vmlinuz
|
||||
INITRD /boot/initramfs.xz
|
||||
APPEND ip=dhcp consoleblank=0 console=tty0 console=ttyS0,9600 dianemo.autonomy.io/root=${DIANEMO_ROOT} dianemo.autonomy.io/userdata=${DIANEMO_USERDATA}
|
||||
APPEND ip=dhcp consoleblank=0 console=tty0 console=ttyS0,9600 dianemo.autonomy.io/root=${DIANEMO_ROOT} dianemo.autonomy.io/userdata=${DIANEMO_USERDATA} dianemo.autonomy.io/platform=${DIANEMO_PLATFORM}
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -122,6 +122,7 @@ function cleanup {
|
||||
|
||||
DIANEMO_ROOT="sda"
|
||||
DIANEMO_USERDATA=""
|
||||
DIANEMO_PLATFORM="bare-metal"
|
||||
RAW_IMAGE="/out/image.raw"
|
||||
VMDK_IMAGE="/out/image.vmdk"
|
||||
ISO_IMAGE="/out/image.iso"
|
||||
@ -131,7 +132,7 @@ RAW=false
|
||||
case "$1" in
|
||||
image)
|
||||
shift
|
||||
while getopts "b:flt:u:" opt; do
|
||||
while getopts "b:flt:p:u:" opt; do
|
||||
case ${opt} in
|
||||
b )
|
||||
DEVICE=${OPTARG}
|
||||
@ -148,6 +149,10 @@ case "$1" in
|
||||
RAW=true
|
||||
echo "Using loop device ${RAW_IMAGE} as installation media"
|
||||
;;
|
||||
p )
|
||||
DIANEMO_PLATFORM=${OPTARG}
|
||||
echo "Using kernel parameter dianemo.autonomy.io/platform=${DIANEMO_PLATFORM}"
|
||||
;;
|
||||
t )
|
||||
DIANEMO_ROOT=${OPTARG}
|
||||
echo "Using kernel parameter dianemo.autonomy.io/root=${DIANEMO_ROOT}"
|
||||
|
@ -70,7 +70,7 @@
|
||||
"sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
|
||||
"sudo apt-get -y update",
|
||||
"sudo apt-get -y install docker-ce",
|
||||
"sudo docker run --privileged --volume /dev:/dev autonomy/dianemo:{{ user `version` }} image -b /dev/xvdf -t /dev/xvda -f -u none"
|
||||
"sudo docker run --privileged --volume /dev:/dev autonomy/dianemo:{{ user `version` }} image -b /dev/xvdf -t /dev/xvda -f -p aws -u none"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -9,6 +9,10 @@ const (
|
||||
// to the user data.
|
||||
KernelParamUserData = "dianemo.autonomy.io/userdata"
|
||||
|
||||
// KernelParamPlatform is the kernel parameter name for specifying the
|
||||
// platform.
|
||||
KernelParamPlatform = "dianemo.autonomy.io/platform"
|
||||
|
||||
// NewRoot is the path where the switchroot target is mounted.
|
||||
NewRoot = "/root"
|
||||
|
||||
|
@ -3,6 +3,10 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/constants"
|
||||
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/kernel"
|
||||
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/platform/baremetal"
|
||||
"github.com/autonomy/dianemo/src/initramfs/cmd/init/pkg/platform/cloud/aws"
|
||||
"github.com/autonomy/dianemo/src/initramfs/pkg/userdata"
|
||||
@ -17,11 +21,23 @@ type Platform interface {
|
||||
|
||||
// NewPlatform is a helper func for discovering the current platform.
|
||||
func NewPlatform() (p Platform, err error) {
|
||||
if aws.IsEC2() {
|
||||
p = &aws.AWS{}
|
||||
} else {
|
||||
p = &baremetal.BareMetal{}
|
||||
arguments, err := kernel.ParseProcCmdline()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if platform, ok := arguments[constants.KernelParamPlatform]; ok {
|
||||
switch platform {
|
||||
case "aws":
|
||||
if aws.IsEC2() {
|
||||
p = &aws.AWS{}
|
||||
} else {
|
||||
return nil, fmt.Errorf("failed to verify EC2 PKCS7 signature")
|
||||
}
|
||||
case "bare-metal":
|
||||
p = &baremetal.BareMetal{}
|
||||
default:
|
||||
return nil, fmt.Errorf("no platform specified")
|
||||
}
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user