Skip to content

Commit a75142b

Browse files
committed
describe the portmapping API and command lines
1 parent de649cd commit a75142b

File tree

6 files changed

+59
-8
lines changed

6 files changed

+59
-8
lines changed

Diff for: SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* [rm](reference/rm.md)
2929
* [info](reference/info.md)
3030
* [list](reference/list.md)
31+
* [ports](reference/ports.md)
3132
* [pull](reference/pull.md)
3233
* [images](reference/images.md)
3334
* [rmi](reference/rmi.md)

Diff for: reference/api.md

+31
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,37 @@ Send kill signal to containers of a Pod
100100

101101
`POST /pod/kill?podName=pod-xxxxxxxxxx&container=xxxxxxx&signal=9`
102102

103+
##### List Port Mapping Rules
104+
105+
`GET /pod/{pod_id}/portmappings`
106+
107+
Get a list of current port mappings of a pod.
108+
109+
##### Modify Port Mapping Rules
110+
111+
`PUT /pod/{pod_id}/portmappings/{action}`
112+
113+
Update port mapping rules
114+
115+
- `action` could be `add` or `delete`
116+
117+
The request body is an json **array** of `PortMapping`:
118+
119+
```
120+
{
121+
"containerPort": "80",
122+
"hostPort": "3000",
123+
"protocol": "udp"
124+
}
125+
```
126+
127+
Where
128+
129+
- `containerPort` and `hostPort` could be a single port or a range, such as "8000-8080"; and if the `containerPort` is a range, the `hostPort` should be a range in same size;
130+
- `protocol` could be `tcp` or `udp`.
131+
132+
The request body should be an array even if there is only one rule to be added/deleted.
133+
103134
#### 2.2 Container
104135
##### Create container
105136
`POST /container/create`

Diff for: reference/cli.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Command:
1717
login Register or log in to a Docker registry server
1818
logout Log out from a Docker registry server
1919
pause Pause a running pod
20+
ports List or modify port mapping rules of a Pod
2021
pull Pull an image from a Docker registry server
2122
push Push an image or a repository to a Docker registry server
2223
rm Remove one or more pods or containers

Diff for: reference/containers.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- `workdir`: the directory running the container command
1313

14-
- `ports`: the exposed ports of the container
14+
- *[Deprecated]* `ports`: the exposed ports of the container, the ports now is move to the Pod level
1515
- `containerPort`: the listening port inside container
1616
- `hostPort`: the port exposed in host machine
1717
- `protocol`: `tcp` (default) or `udp`
@@ -62,9 +62,5 @@ example:
6262
"content": ""
6363
}
6464
}],
65-
"ports":[{
66-
"containerPort": 80,
67-
"hostPort": 8000,
68-
}],
6965
"tty": true
7066
}]

Diff for: reference/podfile.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Podfile is in JSON format. A basic sample looks like the following:
99
"vcpu": 1,
1010
"memory": 128
1111
},
12-
1312
"containers" : [{
1413
"image": "nginx:latest",
1514
"files": [{
@@ -18,14 +17,17 @@ Podfile is in JSON format. A basic sample looks like the following:
1817
"perm": "0755"
1918
}]
2019
}],
21-
2220
"files": [{
2321
"name": "filename",
2422
"encoding": "raw",
2523
"uri": "https://s3.amazonaws/bucket/file.conf",
2624
"content": ""
2725
}],
28-
26+
"portmappings": [{
27+
"containerPort": "80",
28+
"hostPort": "3000",
29+
"protocol": "udp"
30+
}],
2931
"volumes": []
3032
}
3133

@@ -35,5 +37,8 @@ Podfile is in JSON format. A basic sample looks like the following:
3537
- `hostname`: the hostname of the Pod
3638
- `resources`: specify the number of CPU cores and RAM size allocated to the HyperVM instance
3739
- `containers`: a group of [containers](./containers.md) to run in the Pod. Since 0.8, we could create a Pod with empty containers list, and add containers later.
40+
- `portmappings`: the port mapping rules, and the portmappings could be `add`/`remove` during runtime with API or command line tools. The fields:
41+
- `containerPort` and `hostPort` could be a single port or a range, such as "8000-8080"; and if the `containerPort` is a range, the `hostPort` should be a range in same size;
42+
- `protocol` could be `tcp` or `udp`.
3843
- `files`: [files](./files.md) to be present in the containers
3944
- `volumes`: [volumes](./volumes.md) to mount from the host to the containers

Diff for: reference/ports.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ports
2+
3+
List or modify port mapping rules of a Pod
4+
5+
```
6+
Usage:
7+
hyperctl ports ls|add|delete [OPTIONS] POD
8+
9+
List or modify port mapping rules of a Pod
10+
11+
Application Options:
12+
13+
-p, --publish Publish a container's port to the host (only valid for add and delete)
14+
15+
Help Options:
16+
-h, --help Show this help message
17+
```

0 commit comments

Comments
 (0)