Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/compute/nested-virtualization.tsx
Views: 687
import { Alert, Checkbox, Switch } from "antd";1import { useState } from "react";2import { A, Icon } from "@cocalc/frontend/components";34export default function NestedVirtualization({5setConfig,6configuration,7loading,8}) {9const [enableNestedVirtualization, setEnableNestedVirtualization] =10useState<boolean>(!!configuration.enableNestedVirtualization);11const [help, setHelp] = useState<boolean>(false);1213return (14<div>15<div style={{ color: "#666", marginBottom: "5px" }}>16<div>17<b>18<Switch19size="small"20checkedChildren={"Help"}21unCheckedChildren={"Help"}22style={{ float: "right" }}23checked={help}24onChange={(val) => setHelp(val)}25/>26<Icon name="users" /> Enable Nested Virtualization27</b>28</div>29{help && (30<Alert31showIcon32style={{ margin: "15px 0" }}33type="info"34message={"Enable Nested Virtualization"}35description={36<div>37<ul>38<li>39Enable this option to run full VM's inside of this compute40server.41</li>42<li>43There is roughly{" "}44<A href="https://cloud.google.com/compute/docs/instances/nested-virtualization/overview">45a 10% performance penalty46</A>47.48</li>49<li>50One way to run a VM is to ssh into the compute server as51root, install <A href="https://multipass.run/">Multipass</A>{" "}52by typing <code>snap install multipass</code> then use any53multipass command, e.g., <code>multipass launch</code>.54</li>55<li>56Nested virtualization is only supported for Intel processes57on non-E2 general-purpose, or A3 accelerator-optimized58servers.{" "}59<b>60The currently selected machine type is{" "}61{isSupported(configuration) ? "" : " NOT "} supported.62</b>63</li>64<li>65NOTE: All compute servers fully support running Docker66containers without this option. This is for running full67virtual machines.68</li>69</ul>70</div>71}72/>73)}74<Checkbox75style={{ marginTop: "5px" }}76disabled={loading || !isSupported(configuration)}77checked={enableNestedVirtualization && isSupported(configuration)}78onChange={() => {79setConfig({80enableNestedVirtualization: !enableNestedVirtualization,81});82setEnableNestedVirtualization(!enableNestedVirtualization);83}}84>85Enable Nested Virtualization: make it possible to run full VM's inside86of this compute server87</Checkbox>88</div>89</div>90);91}9293function isSupported(configuration) {94const { machineType } = configuration;95if (!machineType) {96return false;97}98if (machineType.startsWith("a3")) {99return false;100}101if (machineType.startsWith("e2")) {102return false;103}104const i = machineType.indexOf("-");105if (i == -1) {106return false;107}108const x = machineType[i - 1];109if (x == "a" || x == "d") {110return false;111}112return true;113}114115116