elotl / kip

Virtual-kubelet provider running pods in cloud instances
Apache License 2.0
223 stars 14 forks source link

Use correct root device name when creating instance #83

Closed ldx closed 4 years ago

ldx commented 4 years ago

Right now, "xvda" is hardcoded when we call RunInstances(). However, the name of the root device depends on the AMI. We need to check and save BlockDeviceMappings[0].DeviceName from DescribeImages(), and use it when creating a new instance.

Example result from DescribeImages():

    {
        "VirtualizationType": "hvm",
        "Name": "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20161010",
        "PlatformDetails": "Linux/UNIX",
        "Hypervisor": "xen",
        "State": "available",
        "SriovNetSupport": "simple",
        "ImageId": "ami-feb6fee9",
        "UsageOperation": "RunInstances",
        "BlockDeviceMappings": [
            {
                "DeviceName": "/dev/sda1",
                "Ebs": {
                    "SnapshotId": "snap-fe547de8",
                    "DeleteOnTermination": true,
                    "VolumeType": "gp2",
                    "VolumeSize": 8,
                    "Encrypted": false
                }
            },
            {
                "DeviceName": "/dev/sdb",
                "VirtualName": "ephemeral0"
            },
            {
                "DeviceName": "/dev/sdc",
                "VirtualName": "ephemeral1"
            }
        ],
        "Architecture": "x86_64",
        "ImageLocation": "099720109477/ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20161010",
        "RootDeviceType": "ebs",
        "OwnerId": "099720109477",
        "RootDeviceName": "/dev/sda1",
        "CreationDate": "2016-10-11T01:17:16.000Z",
        "Public": true,
        "ImageType": "machine"
    }