Skip to content

Commit

Permalink
feat: Introduce new KubeTaskParallel function to run pods with two co…
Browse files Browse the repository at this point in the history
…ntainers

In order to separate data dump generation by database tools and export
by `kando`, a pod performing database dump can have two separate containers
and set up the pipe over file instead of anonymous pipe
  • Loading branch information
hairyhum committed Sep 11, 2024
1 parent cd61d8c commit fdc0a1b
Show file tree
Hide file tree
Showing 9 changed files with 599 additions and 4 deletions.
67 changes: 67 additions & 0 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,73 @@ Example:
- |
echo "Example"
KubeTaskParallel
----------------

KubeTaskParallel spins up a new pod with two containers connected
via shared emptyDir volume.
It's similar to KubeTask, but allows using multiple images to move backup data.
"background" container is one responsible for generating data, while "output" container
should export it to destination.
The main difference between them is that phase outputs can only generated from the
"output" container outputs.

.. csv-table::
:header: "Argument", "Required", "Type", "Description"
:align: left
:widths: 5,5,5,15

`namespace`, No, `string`, namespace in which to execute (the pod will be created in controller's namespace if not specified)
`backgroundImage`, Yes, `string`, image to be used in "background" container
`backgroundCommand`, Yes, `[]string`, command list to execute in "background" container
`outputImage`, Yes, `string`, image to be used in "output" container
`outputCommand`, Yes, `[]string`, command list to execute in "output" container
`podOverride`, No, `map[string]interface{}`, specs to override default pod specs with
`podAnnotations`, No, `map[string]string`, custom annotations for the temporary pod that gets created
`podLabels`, No, `map[string]string`, custom labels for the temporary pod that gets created
`sharedVolumeMedium`, No, `string`, medium setting for shared volume. See https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
`sharedVolumeSizeLimit`, No, `string`, sizeLimit setting for shared volume
`sharedVolumeDir`, No, `string`, directory to mount shared volume. Defaults to `/tmp`

Example:

.. code-block:: yaml
:linenos:
- func: KubeTaskParallel
name: examplePhase
args:
namespace: "{{ .Deployment.Namespace }}"
podOverride:
containers:
- name: export
imagePullPolicy: IfNotPresent
podAnnotations:
annKey: annValue
podLabels:
labelKey: labelValue
sharedVolumeMedium: Memory
sharedVolumeSizeLimit: 1Gi
sharedVolumeDir: /tmp/
backgroundImage: ubuntu
backgroundCommand:
- bash
- -c
- |
mkfifo /tmp/pipe-file
for i in {1..10}
do
echo $i
sleep 0.1
done > /tmp/pipe-file
outputImage: ubuntu
outputCommand:
- bash
- -c
- |
while [ ! -e /tmp/pipe-file ]; do sleep 1; done
cat /tmp/pipe-file
ScaleWorkload
-------------

Expand Down
2 changes: 2 additions & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ webhook
Kopia
kopia
hostname
emptyDir
sizeLimit
63 changes: 63 additions & 0 deletions docs_new/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,69 @@ Example:
echo "Example"
```
### KubeTaskParallel
KubeTaskParallel spins up a new pod with two containers connected via shared emptyDir volume.
It's similar to KubeTask, but allows using multiple images to move backup data.
"background" container is one responsible for generating data, while "output" container
should export it to destination.
The main difference between them is that phase outputs can only generated from the
"output" container outputs.
| Argument | Required | Type | Description |
| ----------- | :------: | ----------------------- | ----------- |
| namespace | No | string | namespace in which to execute (the pod will be created in controller's namespace if not specified) |
| backgroundImage | Yes | string | image to be used in "background" container |
| backgroundCommand | Yes | []string | command list to execute in "background" container |
| outputImage | Yes | string | image to be used in "output" container |
| outputCommand | Yes | []string | command list to execute in "output" container |
| podOverride | No | map[string]interface{} | specs to override default pod specs with |
| podAnnotations | No | map[string]string | custom annotations for the temporary pod that gets created |
| podLabels | No | map[string]string | custom labels for the temporary pod that gets created |
| sharedVolumeMedium | No | string | medium setting for shared volume, see https://kubernetes.io/docs/concepts/storage/volumes/#emptydir |
| sharedVolumeSizeLimit | No | string | sizeLimit setting for shared volume |
| sharedVolumeDir | No | string | directory to mount shared volume, defaults to `/tmp` |


Example:

``` yaml
- func: KubeTaskParallel
name: examplePhase
args:
namespace: "{{ .Deployment.Namespace }}"
podOverride:
containers:
- name: export
imagePullPolicy: IfNotPresent
podAnnotations:
annKey: annValue
podLabels:
labelKey: labelValue
sharedVolumeMedium: Memory
sharedVolumeSizeLimit: 1Gi
sharedVolumeDir: /tmp/
backgroundImage: ubuntu
backgroundCommand:
- bash
- -c
- |
mkfifo /tmp/pipe-file
for i in {1..10}
do
echo $i
sleep 0.1
done > /tmp/pipe-file
outputImage: ubuntu
outputCommand:
- bash
- -c
- |
while [ ! -e /tmp/pipe-file ]; do sleep 1; done
cat /tmp/pipe-file
```

### ScaleWorkload

ScaleWorkload is used to scale up or scale down a Kubernetes workload.
Expand Down
Loading

0 comments on commit fdc0a1b

Please sign in to comment.