Skip to content

Commit

Permalink
docs: finishing doc page for Custom Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
renzodavid9 committed May 23, 2023
1 parent 7719576 commit b566d30
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
47 changes: 42 additions & 5 deletions docs-v2/content/en/docs/custom-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Per default, a Custom Action does not have a timeout configured, which means, th

{{% readfile file="samples/custom-actions/two-local-actions-timeout.yaml" %}}

Running `skaffold exec update-infra` with the previous configuration will fail if the Custom Action takes more than 10 seconds to complete. If the timeout is triggered, Skaffold will stop any container that is still running and will return a status code `1`:
Running `skaffold exec update-infra` with the previous configuration will fail if the Custom Action takes more than 10 seconds to complete. If the timeout is triggered, Skaffold will stop any running container and will return a status code `1`:

```console
$ skaffold exec update-infra
Expand All @@ -64,7 +64,7 @@ Skaffold will return status code `0` if all the containers associated with the g

### Fail strategy

A Custom Action will be run with a `fail-fast` strategy, which means, if one container associated with the action fails, Skaffold will stop the containers that are still running, and will return a status code `1`:
A Custom Action will be run with a `fail-fast` strategy, which means, if one container associated with the action fails, Skaffold will stop any running container, and will return a status code `1`:

The following `skaffold.yaml` config:

Expand Down Expand Up @@ -103,18 +103,55 @@ Starting execution for update-infra

### Execution modes

A Custom Action has an execution mode associated with it that indicates Skaffold in which environment and how the containers of that action should be created and executed. This execution mode can be change with the [`customActions[].executionMode` property]({{< relref "/docs/references/yaml/#customActions-executionMode" >}}). These are the available execution modes for a Custom Action:
A Custom Action has an execution mode associated with it that indicates Skaffold in which environment and how the containers of that action should be created and executed. This execution mode can be configured with the [`customActions[].executionMode` property]({{< relref "/docs/references/yaml/#customActions-executionMode" >}}). These are the available execution modes for a Custom Action:

#### Local (Docker) - default {#local-docker}

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.

#### Remote (K8s job)

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

{{% readfile file="samples/custom-actions/k8s-action.yaml" %}}

Skaffold will create one K8s job for `update-db-schema` and another for `setup-external-proxy`. The jobs will use the following template per default:

```yaml
apiVersion: batch/v1
kind: Job
metadata:
name: # <- Container name defined in skaffold.yaml.
spec:
template:
spec:
containers: # <- Only one container, the one defined in the skaffold.yaml.
# ...
restartPolicy: Never
backoffLimit: 0
```
The template can be extended using the [`customActions[].executionMode.kubernetesCluster.overrides`]({{< relref "/docs/references/yaml/#customActions-executionMode-kubernetesCluster-overrides" >}}) and [`customActions[].executionMode.kubernetesCluster.jobManifestPath`]({{< relref "/docs/references/yaml/#customActions-executionMode-kubernetesCluster-jobManifestPath" >}}) properties.

## Skaffold build + exec

docs/references/cli/#skaffold-exec
Custom Actions can be used together with [Skaffold build]({{< relref "docs/builders/" >}}) so the Custom Actions can use images build by Skaffold.

Using the following `skaffold.yaml` file:

{{% readfile file="samples/custom-actions/actions-local-build.yaml" %}}

We trigger an Skaffold build using the `skaffold build` command:

```console
$ skaffold build --file-output=build.json
```

Skaffold will create a new `build.json` file with the necessary info. Then, using the generated file, we can run `skaffold exec`:

```console
$ skaffold exec update-infra --build-artifacts=build.json
```

That way, Skaffold will be able to run the `local-db-updater` image in the `update-infra` Custom Action.

15 changes: 15 additions & 0 deletions docs-v2/content/en/samples/custom-actions/actions-local-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: skaffold/v4beta5
kind: Config

build:
artifacts:
- image: local-db-updater # <- Image build by Skaffold.
# ...

customActions:
- name: update-infra
containers:
- name: update-db-schema
image: local-db-updater # <- Image build by Skaffold.
- name: setup-external-proxy
image: gcr.io/my-registry/proxy:latest
2 changes: 1 addition & 1 deletion docs-v2/content/en/samples/custom-actions/k8s-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Config
customActions:
- name: update-infra
executionMode:
kubernetesCluster: {}
kubernetesCluster: {} # <- Indicates Skaffold to run the action with K8s jobs.
containers:
- name: update-db-schema
image: gcr.io/my-registry/db-updater:latest
Expand Down

0 comments on commit b566d30

Please sign in to comment.