Skip to content

Commit 8f509e0

Browse files
docs: document runArgs for custom actions and verify
Documents the conservative runArgs whitelist (--network, -v/--volume, --add-host, --tmpfs) and its security note on the custom-actions page, adds a short cross-linked note on the verify page (verify shares the same whitelist), and ships a runnable custom-actions-runargs example.
1 parent 6628f0a commit 8f509e0

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

docs-v2/content/en/docs/custom-actions.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,45 @@ A Custom Action has an execution mode associated with it that indicates Skaffold
109109

110110
This is the default configuration when no [`customActions[].executionMode`]({{< relref "/docs/references/yaml/#customActions-executionMode" >}}) is specified. With this execution mode, Skaffold will run every container associated to a given Custom Action with a Docker daemon.
111111

112+
##### Passing Docker run flags with `runArgs`
113+
114+
When an action needs to reach host resources (for example your local
115+
`~/.config/gcloud` credentials, or the host network for GCE/GKE metadata),
116+
use [`customActions[].executionMode.local.runArgs`]({{< relref
117+
"/docs/references/yaml/#customActions-executionMode-local-runArgs" >}}).
118+
Skaffold parses each entry against a conservative whitelist and overlays
119+
the result on the Docker `HostConfig` used to start the container:
120+
121+
| Flag | Effect |
122+
| --- | --- |
123+
| `--network=<mode>` | Sets `HostConfig.NetworkMode`. Accepts `host`, `bridge`, `none`, or a named network. |
124+
| `-v=<src>:<dst>[:opts]`, `--volume=<src>:<dst>[:opts]` | Appends to `HostConfig.Binds`. |
125+
| `--add-host=<host>:<ip>` | Appends to `HostConfig.ExtraHosts`. |
126+
| `--tmpfs=<path>[:opts]` | Merges into `HostConfig.Tmpfs`. |
127+
128+
Only the `--flag=value` form is accepted — space-separated values and
129+
unknown flags are rejected at load time so typos fail loudly rather
130+
than silently dropping settings.
131+
132+
```yaml
133+
customActions:
134+
- name: reuse-local-adc
135+
executionMode:
136+
local:
137+
runArgs:
138+
- "-v=/root/.config/gcloud:/root/.config/gcloud:ro"
139+
- "--network=host"
140+
containers:
141+
- name: gcloud
142+
image: google/cloud-sdk:slim
143+
command: ["gcloud"]
144+
args: ["auth", "list"]
145+
```
146+
147+
> **Security note:** `runArgs` hands raw flags to the host Docker daemon.
148+
> Avoid committing broad bind mounts (`-v=/:/host`) or host-network access
149+
> to source control unless the action genuinely needs them.
150+
112151
#### Remote (K8s job)
113152

114153
With this execution mode, Skaffold will create a K8s job for each container associated with the given action. For the following configuration:

docs-v2/content/en/docs/verify.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ You can run post-deployment verification tests in the following execution enviro
2121

2222
When Skaffold runs a post-deployment verifications test in the local execution mode, it uses the `docker` CLI to run the test container on the host machine. This is the default execution mode.
2323

24+
Local verify containers accept the same conservative `runArgs` whitelist as custom actions via [`verify[].executionMode.local.runArgs`]({{< relref "/docs/references/yaml/#verify-executionMode-local-runArgs" >}}) (`--network`, `-v`/`--volume`, `--add-host`, `--tmpfs`). See [Passing Docker run flags with `runArgs`]({{< relref "/docs/custom-actions#passing-docker-run-flags-with-runargs" >}}) for details and the security note.
25+
2426
### Kubernetes cluster
2527

2628
When Skaffold runs a post-deployment verification test in the Kubernetes cluster execution mode, it uses the `kubectl` CLI to run the test container as a Kubernetes Job.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: skaffold/v4beta15
2+
kind: Config
3+
metadata:
4+
name: custom-actions-runargs
5+
6+
customActions:
7+
- name: extra-host
8+
executionMode:
9+
local:
10+
runArgs:
11+
- "--add-host=metadata-server:169.254.169.254"
12+
- "--tmpfs=/scratch:size=16m"
13+
containers:
14+
- name: probe
15+
image: alpine:3.20
16+
command: ["/bin/sh"]
17+
args: ["-c", "grep metadata-server /etc/hosts && touch /scratch/ok && echo scratch-writable"]
18+
19+
- name: gcloud-auth-list
20+
executionMode:
21+
local:
22+
runArgs:
23+
- "-v=/root/.config/gcloud:/root/.config/gcloud:ro"
24+
- "--network=host"
25+
containers:
26+
- name: gcloud
27+
image: google/cloud-sdk:slim
28+
command: ["gcloud"]
29+
args: ["auth", "list"]

0 commit comments

Comments
 (0)