The networks available within Rancher that containers could be launched on.
| Field | Type | Create | Update | Default | Notes |
|---|---|---|---|---|---|
| defaultPolicyAction | enum | Optional | Yes | allow | The options are allow, deny. |
| description | string | Optional | Yes | - | |
| dns | array[string] | Optional | - | - | |
| dnsSearch | array[string] | Optional | - | - | |
| hostPorts | boolean | Optional | - | - | |
| metadata | map[json] | Optional | Yes | - | |
| name | string | Optional | Yes | - | |
| networkDriverId | networkDriver | Yes | - | - | |
| policy | array[networkPolicyRule] | Optional | Yes | - | |
| subnets | array[subnet] | Optional | - | - |
| Field | Type | Notes |
|---|---|---|
| id | int | The unique identifier for the network |
Please read more about the common resource fields. These fields are read only and applicable to almost every resource. We have segregated them from the list above.
CreatePOST: /v2-beta/projects/${PROJECT_ID}/networks
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"defaultPolicyAction": "allow",
"description": "string",
"dns": [
"string1",
"...stringN"
],
"dnsSearch": [
"string1",
"...stringN"
],
"hostPorts": false,
"metadata": {
"key": "value-pairs"
},
"name": "string",
"networkDriverId": "reference[networkDriver]",
"policy": "array[networkPolicyRule]",
"subnets": "array[subnet]"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/networks'
DeleteDELETE: /v2-beta/projects/${PROJECT_ID}/networks/${ID}
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X DELETE \
'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/networks/${ID}'
UpdatePUT: /v2-beta/projects/${PROJECT_ID}/networks/${ID}
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X PUT \
-H 'Content-Type: application/json' \
-d '{
"defaultPolicyAction": "allow",
"description": "string",
"metadata": {
"key": "value-pairs"
},
"name": "string",
"policy": "array[networkPolicyRule]"
}' 'http://${RANCHER_URL}:8080/v2-beta/projects/${PROJECT_ID}/networks/${ID}'