2020-05-16 03:03:54 +00:00
|
|
|
# Changing Platforms
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-04-30 01:54:48 +00:00
|
|
|
[TOC]
|
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
This guide described how to change the
|
|
|
|
[platform](../architecture_guide/platforms.md) used by `runsc`.
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
## Prerequisites
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
If you intend to run the KVM platform, you will also to have KVM installed on
|
|
|
|
your system. If you are running a Debian based system like Debian or Ubuntu you
|
|
|
|
can usually do this by ensuring the module is loaded, and permissions are
|
|
|
|
appropriately set on the `/dev/kvm` device.
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
If you have an Intel CPU:
|
2019-04-03 19:18:46 +00:00
|
|
|
|
|
|
|
```bash
|
2020-05-16 03:03:54 +00:00
|
|
|
sudo modprobe kvm-intel && sudo chmod a+rw /dev/kvm
|
2019-04-03 19:18:46 +00:00
|
|
|
```
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
If you have an AMD CPU:
|
2019-03-30 02:40:11 +00:00
|
|
|
|
|
|
|
```bash
|
2020-05-16 03:03:54 +00:00
|
|
|
sudo modprobe kvm-amd && sudo chmod a+rw /dev/kvm
|
2019-03-30 02:40:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
If you are using a virtual machine you will need to make sure that nested
|
|
|
|
virtualization is configured. Here are links to documents on how to set up
|
2019-04-03 19:18:46 +00:00
|
|
|
nested virtualization in several popular environments:
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-12 19:55:23 +00:00
|
|
|
* Google Cloud: [Enabling Nested Virtualization for VM Instances][nested-gcp]
|
|
|
|
* Microsoft Azure:
|
|
|
|
[How to enable nested virtualization in an Azure VM][nested-azure]
|
|
|
|
* VirtualBox: [Nested Virtualization][nested-virtualbox]
|
|
|
|
* KVM: [Nested Guests][nested-kvm]
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2019-12-21 08:27:52 +00:00
|
|
|
***Note: nested virtualization will have poor performance and is historically a
|
|
|
|
cause of security issues (e.g.
|
|
|
|
[CVE-2018-12904](https://nvd.nist.gov/vuln/detail/CVE-2018-12904)). It is not
|
|
|
|
recommended for production.***
|
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
## Configuring Docker
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
The platform is selected by the `--platform` command line flag passed to
|
|
|
|
`runsc`. By default, the ptrace platform is selected. For example, to select the
|
|
|
|
KVM platform, modify your Docker configuration (`/etc/docker/daemon.json`) to
|
|
|
|
pass the `--platform` argument:
|
2019-03-30 02:40:11 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"runtimes": {
|
|
|
|
"runsc": {
|
|
|
|
"path": "/usr/local/bin/runsc",
|
|
|
|
"runtimeArgs": [
|
|
|
|
"--platform=kvm"
|
|
|
|
]
|
2020-05-16 03:03:54 +00:00
|
|
|
}
|
2019-03-30 02:40:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
You must restart the Docker daemon after making changes to this file, typically
|
|
|
|
this is done via `systemd`:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo systemctl restart docker
|
|
|
|
```
|
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
Note that you may configure multiple runtimes using different platforms. For
|
|
|
|
example, the following configuration has one configuration for ptrace and one
|
|
|
|
for the KVM platform:
|
2019-03-30 02:40:11 +00:00
|
|
|
|
2020-05-16 03:03:54 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"runtimes": {
|
|
|
|
"runsc-ptrace": {
|
|
|
|
"path": "/usr/local/bin/runsc",
|
|
|
|
"runtimeArgs": [
|
|
|
|
"--platform=ptrace"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"runsc-kvm": {
|
|
|
|
"path": "/usr/local/bin/runsc",
|
|
|
|
"runtimeArgs": [
|
|
|
|
"--platform=kvm"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-30 02:40:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
[nested-azure]: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nested-virtualization
|
|
|
|
[nested-gcp]: https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances
|
|
|
|
[nested-virtualbox]: https://www.virtualbox.org/manual/UserManual.html#nested-virt
|
|
|
|
[nested-kvm]: https://www.linux-kvm.org/page/Nested_Guests
|