2015-09-29 22:55:23 +00:00
|
|
|
---
|
|
|
|
layout: "docs"
|
|
|
|
page_title: "Drivers: Rkt"
|
|
|
|
sidebar_current: "docs-drivers-rkt"
|
|
|
|
description: |-
|
2015-11-17 23:39:38 +00:00
|
|
|
The rkt task driver is used to run application containers using rkt.
|
2015-09-29 22:55:23 +00:00
|
|
|
---
|
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
# Rkt Driver
|
2015-09-29 22:55:23 +00:00
|
|
|
|
|
|
|
Name: `rkt`
|
|
|
|
|
2015-11-17 23:39:38 +00:00
|
|
|
The `rkt` driver provides an interface for using CoreOS rkt for running
|
2016-10-03 21:35:20 +00:00
|
|
|
application containers.
|
|
|
|
|
2015-09-29 22:55:23 +00:00
|
|
|
## Task Configuration
|
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
```hcl
|
|
|
|
task "webservice" {
|
|
|
|
driver = "rkt"
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "redis:3.2"
|
|
|
|
}
|
2016-10-28 00:55:55 +00:00
|
|
|
}
|
2016-10-03 21:35:20 +00:00
|
|
|
```
|
|
|
|
|
2015-11-17 23:39:38 +00:00
|
|
|
The `rkt` driver supports the following configuration in the job spec:
|
2015-09-29 22:55:23 +00:00
|
|
|
|
2016-08-27 12:56:39 +00:00
|
|
|
* `image` - The image to run. May be specified by name, hash, ACI address
|
2015-11-18 23:16:42 +00:00
|
|
|
or docker registry.
|
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
```hcl
|
|
|
|
config {
|
|
|
|
image = "https://hub.docker.internal/redis:3.2"
|
|
|
|
}
|
|
|
|
```
|
2015-11-18 23:16:42 +00:00
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
* `command` - (Optional) A command to execute on the ACI.
|
2016-01-11 19:12:09 +00:00
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
```hcl
|
|
|
|
config {
|
|
|
|
command = "my-command"
|
|
|
|
}
|
2016-01-11 19:12:09 +00:00
|
|
|
```
|
2016-10-03 21:35:20 +00:00
|
|
|
|
|
|
|
* `args` - (Optional) A list of arguments to the optional `command`. References
|
|
|
|
to environment variables or any [interpretable Nomad
|
2016-10-28 00:36:26 +00:00
|
|
|
variables](/docs/runtime/interpolation.html) will be interpreted before
|
2016-10-03 21:35:20 +00:00
|
|
|
launching the task.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
config {
|
|
|
|
args = [
|
|
|
|
"-bind", "${NOMAD_PORT_http}",
|
|
|
|
"${nomad.datacenter}",
|
|
|
|
"${MY_ENV}",
|
|
|
|
"${meta.foo}",
|
|
|
|
]
|
|
|
|
}
|
2016-01-11 19:12:09 +00:00
|
|
|
```
|
2015-11-18 23:16:42 +00:00
|
|
|
|
|
|
|
* `trust_prefix` - (Optional) The trust prefix to be passed to rkt. Must be
|
|
|
|
reachable from the box running the nomad agent. If not specified, the image is
|
|
|
|
run without verifying the image signature.
|
2015-09-29 22:55:23 +00:00
|
|
|
|
2016-12-12 18:59:56 +00:00
|
|
|
* `dns_servers` - (Optional) A list of DNS servers to be used in the container.
|
|
|
|
Alternatively a list containing just `host` or `none`. `host` uses the host's
|
|
|
|
`resolv.conf` while `none` forces use of the image's name resolution configuration.
|
2016-03-08 05:28:24 +00:00
|
|
|
|
|
|
|
* `dns_search_domains` - (Optional) A list of DNS search domains to be used in
|
2016-08-27 12:56:39 +00:00
|
|
|
the containers.
|
2016-03-08 05:28:24 +00:00
|
|
|
|
2016-08-18 16:00:21 +00:00
|
|
|
* `net` - (Optional) A list of networks to be used by the containers
|
|
|
|
|
2017-02-02 00:16:12 +00:00
|
|
|
* `port_map` - (Optional) A key/value map of ports used by the container. The
|
|
|
|
value is the port name specified in the image manifest file. When running
|
|
|
|
Docker images with rkt the port names will be of the form `${PORT}-tcp`. See
|
|
|
|
[networking](#networking) below for more details.
|
2016-08-18 16:00:21 +00:00
|
|
|
|
2017-02-02 00:16:12 +00:00
|
|
|
```hcl
|
2016-08-18 16:00:21 +00:00
|
|
|
port_map {
|
2017-02-02 00:16:12 +00:00
|
|
|
# If running a Docker image that exposes port 8080
|
2016-08-18 16:00:21 +00:00
|
|
|
app = "8080-tcp"
|
|
|
|
}
|
|
|
|
```
|
2017-02-02 00:16:12 +00:00
|
|
|
|
2016-08-18 16:00:21 +00:00
|
|
|
|
2016-08-27 12:56:39 +00:00
|
|
|
* `debug` - (Optional) Enable rkt command debug option.
|
2016-08-08 10:30:47 +00:00
|
|
|
|
2016-10-19 00:36:19 +00:00
|
|
|
* `volumes` - (Optional) A list of `host_path:container_path` strings to bind
|
2016-10-24 23:00:19 +00:00
|
|
|
host paths to container paths.
|
2015-10-16 00:55:26 +00:00
|
|
|
|
2016-10-19 00:36:19 +00:00
|
|
|
```hcl
|
|
|
|
config {
|
2016-10-24 23:00:19 +00:00
|
|
|
volumes = ["/path/on/host:/path/in/container"]
|
2016-10-19 00:36:19 +00:00
|
|
|
}
|
|
|
|
```
|
2015-10-16 00:55:26 +00:00
|
|
|
|
2016-08-18 16:00:21 +00:00
|
|
|
## Networking
|
|
|
|
|
|
|
|
The `rkt` can specify `--net` and `--port` for the rkt client. Hence, there are two ways to use host ports by
|
|
|
|
using `--net=host` or `--port=PORT` with your network.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```
|
2016-10-26 00:11:01 +00:00
|
|
|
task "redis" {
|
|
|
|
# Use rkt to run the task.
|
|
|
|
driver = "rkt"
|
|
|
|
|
|
|
|
config {
|
|
|
|
# Use docker image with port defined
|
|
|
|
image = "docker://redis:latest"
|
|
|
|
port_map {
|
|
|
|
app = "6379-tcp"
|
|
|
|
}
|
|
|
|
}
|
2016-08-18 16:00:21 +00:00
|
|
|
|
2016-10-26 00:11:01 +00:00
|
|
|
service {
|
|
|
|
port = "app"
|
|
|
|
}
|
2016-08-18 16:00:21 +00:00
|
|
|
|
2016-10-26 00:11:01 +00:00
|
|
|
resources {
|
|
|
|
network {
|
|
|
|
mbits = 10
|
|
|
|
port "app" {
|
|
|
|
static = 12345
|
2016-08-18 16:00:21 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-26 00:11:01 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-18 16:00:21 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Allocating Ports
|
|
|
|
|
|
|
|
You can allocate ports to your task using the port syntax described on the
|
2016-10-28 00:55:55 +00:00
|
|
|
[networking page](/docs/job-specification/network.html).
|
2016-08-18 16:00:21 +00:00
|
|
|
|
|
|
|
When you use port allocation, the image manifest needs to declare public ports and host has configured network.
|
|
|
|
For more information, please refer to [rkt Networking](https://coreos.com/rkt/docs/latest/networking/overview.html).
|
|
|
|
|
2015-09-29 22:55:23 +00:00
|
|
|
## Client Requirements
|
|
|
|
|
2016-08-27 12:56:39 +00:00
|
|
|
The `rkt` driver requires rkt to be installed and in your system's `$PATH`.
|
2015-09-29 22:55:23 +00:00
|
|
|
The `trust_prefix` must be accessible by the node running Nomad. This can be an
|
|
|
|
internal source, private to your cluster, but it must be reachable by the client
|
|
|
|
over HTTP.
|
|
|
|
|
2016-10-19 00:36:19 +00:00
|
|
|
## Client Configuration
|
|
|
|
|
|
|
|
The `rkt` driver has the following [client configuration
|
2016-11-01 12:53:13 +00:00
|
|
|
options](/docs/agent/configuration/client.html#options):
|
2016-10-19 00:36:19 +00:00
|
|
|
|
2016-10-20 00:13:45 +00:00
|
|
|
* `rkt.volumes.enabled`: Defaults to `true`. Allows tasks to bind host paths
|
2016-10-21 17:34:01 +00:00
|
|
|
(`volumes`) inside their container. Binding relative paths is always allowed
|
|
|
|
and will be resolved relative to the allocation's directory.
|
|
|
|
|
2016-10-19 00:36:19 +00:00
|
|
|
|
2015-09-29 22:55:23 +00:00
|
|
|
## Client Attributes
|
|
|
|
|
2015-11-17 23:39:38 +00:00
|
|
|
The `rkt` driver will set the following client attributes:
|
2015-09-29 22:55:23 +00:00
|
|
|
|
2015-11-17 23:39:38 +00:00
|
|
|
* `driver.rkt` - Set to `1` if rkt is found on the host node. Nomad determines
|
2016-10-19 00:36:19 +00:00
|
|
|
this by executing `rkt version` on the host and parsing the output
|
|
|
|
* `driver.rkt.version` - Version of `rkt` eg: `1.1.0`. Note that the minimum required
|
|
|
|
version is `1.0.0`
|
|
|
|
* `driver.rkt.appc.version` - Version of `appc` that `rkt` is using eg: `1.1.0`
|
2015-09-29 22:55:23 +00:00
|
|
|
|
2016-10-03 21:00:32 +00:00
|
|
|
Here is an example of using these properties in a job file:
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "docs" {
|
|
|
|
# Only run this job where the rkt version is higher than 0.8.
|
|
|
|
constraint {
|
|
|
|
attribute = "${driver.rkt.version}"
|
|
|
|
operator = ">"
|
2016-10-19 00:36:19 +00:00
|
|
|
value = "1.2"
|
2016-10-03 21:00:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-09-29 22:55:23 +00:00
|
|
|
## Resource Isolation
|
|
|
|
|
2016-10-03 21:35:20 +00:00
|
|
|
This driver supports CPU and memory isolation by delegating to `rkt`. Network
|
|
|
|
isolation is not supported as of now.
|