|
1 | 1 | # Lifecycle
|
2 | 2 |
|
3 |
| - |
| 3 | + |
4 | 4 |
|
5 |
| -In Hyper, a Pod has two states: |
| 5 | +> Since v0.8, HyperContainer simplified the model (and the state machine), we won't maintain Pod and VM lifecycle independently any more. |
6 | 6 |
|
7 |
| -- `Created`: a Pod is defined, its storage has been allocated, and the Docker images have been downloaded |
8 |
| -- `Running`: a Pod (with its containers) is launched in a VM instance |
| 7 | +In HyperContainer, a Pod is encapsulated in a VM. A Pod can be launched either explicitly: |
9 | 8 |
|
10 |
| - |
11 |
| -A Pod can be launched either explicitly: |
12 |
| - |
13 |
| - [root@user ~:]# hyperctl run -p podfile.json |
| 9 | + ➜ sudo ./hyperctl run -p podfile.json |
14 | 10 |
|
15 | 11 | Or, implicitly:
|
16 | 12 |
|
17 |
| - [root@user ~:]# hyperctl run -t ubuntu |
18 |
| - |
19 |
| -In both cases, Pods and VMs are indivisible. Hyper will automatically provision a new VM instance to host the Pod, and the Pod will be `Running`. |
20 |
| - |
21 |
| -However, you can also create a Pod, but without an underlying VM. In such case, the pod stays in `Created` state. |
22 |
| - |
23 |
| - [root@user ~:]# hyperctl create -p podfile.json |
24 |
| - |
25 |
| -There are two options to start the pod: |
26 |
| - |
27 |
| - [root@user ~:]# hyperctl start pod_id |
28 |
| - |
29 |
| -The `START` command will trigger a VM provisioned, and allocate the new VM to the Pod. |
30 |
| - |
31 |
| -When you `STOP` a Pod, the underlying VM instance will be terminated: |
32 |
| - |
33 |
| - [root@user ~:]# hyperctl stop pod_id |
34 |
| - |
35 |
| -When stopped, the Pod will return to the `Created` state. |
36 |
| - |
37 |
| -To permantly destroy a Pod, you need to `RM` it: |
38 |
| - |
39 |
| - [root@user ~:]# hyperctl rm pod_id |
40 |
| - |
41 |
| -Hyper will (stop if neccessary, then) remove the Pod definition and its storage. |
| 13 | + ➜ sudo ./hyperctl run -d nginx |
| 14 | + POD id is nginx-8530075287 |
| 15 | + |
| 16 | +In both cases, Pods and VMs are indivisible. Hyper will automatically provision a new VM instance to host the Pod, and the Pod will be `Running`. There may be zero, one, or more containers in a Pod. And you may create, start, stop, and remove containers in/from a Pod. |
| 17 | + |
| 18 | + ➜ sudo ./hyperctl create -c -d nginx-8530075287 busybox |
| 19 | + Container ID is a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c |
| 20 | + ➜ sudo ./hyperctl list container |
| 21 | + Container ID Name POD ID Status |
| 22 | + 6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623 nginx-8530075287 nginx-8530075287 running |
| 23 | + a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c busybox-2602968228 nginx-8530075287 pending |
| 24 | + ➜ sudo ./hyperctl start -c busybox-2602968228 |
| 25 | + Successfully started container busybox-2602968228 |
| 26 | + ➜ sudo ./hyperctl list container |
| 27 | + Container ID Name POD ID Status |
| 28 | + a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c busybox-2602968228 nginx-8530075287 running |
| 29 | + 6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623 nginx-8530075287 nginx-8530075287 running |
| 30 | + ➜ sudo ./hyperctl stop -c busybox-2602968228 nginx-8530075287 |
| 31 | + ➜ sudo ./hyperctl list container |
| 32 | + Container ID Name POD ID Status |
| 33 | + 6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623 nginx-8530075287 nginx-8530075287 succeeded |
| 34 | + a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c busybox-2602968228 nginx-8530075287 succeeded |
| 35 | + ➜ sudo ./hyperctl rm -c busybox-2602968228 nginx-8530075287 |
| 36 | + container busybox-2602968228 is successfully deleted! |
| 37 | + container nginx-8530075287 is successfully deleted! |
| 38 | + ➜ sudo ./hyperctl list container |
| 39 | + Container ID Name POD ID Status |
| 40 | + ➜ sudo ./hyperctl list |
| 41 | + POD ID POD Name VM name Status |
| 42 | + nginx-8530075287 nginx-8530075287 vm-pqEnBvQVdS running |
| 43 | + |
| 44 | +And you could stop or remove the Pod. |
| 45 | + |
| 46 | + ➜ sudo ./hyperctl rm nginx-8530075287 |
| 47 | + Pod(nginx-8530075287) is successfully deleted! |
0 commit comments