Skip to content

Commit 1d61afc

Browse files
authored
Merge pull request #2695 from kmalec/add-selective-insecure-options
Added insecure_options config list
2 parents 67cd515 + 0c21187 commit 1d61afc

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

client/driver/rkt.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type RktDriverConfig struct {
8181
PortMapRaw []map[string]string `mapstructure:"port_map"` //
8282
PortMap map[string]string `mapstructure:"-"` // A map of host port and the port name defined in the image manifest file
8383
Volumes []string `mapstructure:"volumes"` // Host-Volumes to mount in, syntax: /path/to/host/directory:/destination/path/in/container
84+
InsecureOptions []string `mapstructure:"insecure_options"` // list of args for --insecure-options
8485

8586
Debug bool `mapstructure:"debug"` // Enable debug option for rkt command
8687
}
@@ -155,6 +156,9 @@ func (d *RktDriver) Validate(config map[string]interface{}) error {
155156
"volumes": &fields.FieldSchema{
156157
Type: fields.TypeArray,
157158
},
159+
"insecure_options": &fields.FieldSchema{
160+
Type: fields.TypeArray,
161+
},
158162
},
159163
}
160164

@@ -262,6 +266,18 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
262266
// Disble signature verification if the trust command was not run.
263267
insecure = true
264268
}
269+
270+
// if we have a selective insecure_options, prefer them
271+
// insecure options are rkt's global argument, so we do this before the actual "run"
272+
if len(driverConfig.InsecureOptions) > 0 {
273+
cmdArgs = append(cmdArgs, fmt.Sprintf("--insecure-options=%s", strings.Join(driverConfig.InsecureOptions, ",")))
274+
} else if insecure {
275+
cmdArgs = append(cmdArgs, "--insecure-options=all")
276+
}
277+
278+
// debug is rkt's global argument, so add it before the actual "run"
279+
cmdArgs = append(cmdArgs, fmt.Sprintf("--debug=%t", debug))
280+
265281
cmdArgs = append(cmdArgs, "run")
266282

267283
// Write the UUID out to a file in the state dir so we can read it back
@@ -304,10 +320,6 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
304320
}
305321

306322
cmdArgs = append(cmdArgs, img)
307-
if insecure {
308-
cmdArgs = append(cmdArgs, "--insecure-options=all")
309-
}
310-
cmdArgs = append(cmdArgs, fmt.Sprintf("--debug=%t", debug))
311323

312324
// Inject environment variables
313325
for k, v := range ctx.TaskEnv.Map() {

website/source/docs/drivers/rkt.html.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,19 @@ The `rkt` driver supports the following configuration in the job spec:
6262
6363
* `trust_prefix` - (Optional) The trust prefix to be passed to rkt. Must be
6464
reachable from the box running the nomad agent. If not specified, the image is
65-
run without verifying the image signature.
65+
run with `--insecure-options=all`.
66+
67+
* `insecure_options` - (Optional) List of insecure options for rkt. Consult `rkt --help`
68+
for list of supported values. This list overrides the `--insecure-options=all` default when
69+
no ```trust_prefix``` is provided in the job config, which can be effectively used to enforce
70+
secure runs, using ```insecure_options = ["none"]``` option.
71+
72+
```hcl
73+
config {
74+
image = "example.com/image:1.0"
75+
insecure_options = ["image", "tls", "ondisk"]
76+
}
77+
```
6678

6779
* `dns_servers` - (Optional) A list of DNS servers to be used in the container.
6880
Alternatively a list containing just `host` or `none`. `host` uses the host's

0 commit comments

Comments
 (0)