Skip to content

Commit

Permalink
feat: support adding init containers to vertices. Closes #284 (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
dseapy authored Oct 30, 2022
1 parent fda3031 commit 6c61728
Show file tree
Hide file tree
Showing 31 changed files with 14,259 additions and 6,549 deletions.
14 changes: 14 additions & 0 deletions api/json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17271,6 +17271,13 @@
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"initContainers": {
"description": "List of init containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.Container"
},
"type": "array"
},
"limits": {
"$ref": "#/definitions/io.numaproj.numaflow.v1alpha1.VertexLimits",
"description": "Limits define the limitations such as buffer read batch size for all the vertices of a pipeline, will override pipeline level settings"
Expand Down Expand Up @@ -18701,6 +18708,13 @@
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"initContainers": {
"description": "List of init containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.Container"
},
"type": "array"
},
"interStepBufferServiceName": {
"type": "string"
},
Expand Down
14 changes: 14 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17279,6 +17279,13 @@
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"initContainers": {
"description": "List of init containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/",
"type": "array",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.Container"
}
},
"limits": {
"description": "Limits define the limitations such as buffer read batch size for all the vertices of a pipeline, will override pipeline level settings",
"$ref": "#/definitions/io.numaproj.numaflow.v1alpha1.VertexLimits"
Expand Down Expand Up @@ -18683,6 +18690,13 @@
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"initContainers": {
"description": "List of init containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/",
"type": "array",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.Container"
}
},
"interStepBufferServiceName": {
"type": "string"
},
Expand Down
1,270 changes: 1,270 additions & 0 deletions config/base/crds/full/numaflow.numaproj.io_pipelines.yaml

Large diffs are not rendered by default.

1,218 changes: 1,218 additions & 0 deletions config/base/crds/full/numaflow.numaproj.io_vertices.yaml

Large diffs are not rendered by default.

8,678 changes: 5,583 additions & 3,095 deletions config/install.yaml

Large diffs are not rendered by default.

8,678 changes: 5,583 additions & 3,095 deletions config/namespace-install.yaml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/APIs.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ Settings for autoscaling
</p>
</td>
</tr>
<tr>
<td>
<code>initContainers</code></br> <em>
<a href="https://v1-18.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core">
\[\]Kubernetes core/v1.Container </a> </em>
</td>
<td>
<em>(Optional)</em>
<p>
List of init containers belonging to the pod. More info:
<a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/">https://kubernetes.io/docs/concepts/workloads/pods/init-containers/</a>
</p>
</td>
</tr>
</tbody>
</table>
<h3 id="numaflow.numaproj.io/v1alpha1.Authorization">
Expand Down
49 changes: 49 additions & 0 deletions docs/init-containers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Init Containers

[Init Containers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) can be provided for all the types of vertices.

The following example shows how to add an init-container to a `udf` vertex.

```yaml
apiVersion: numaflow.numaproj.io/v1alpha1
kind: Pipeline
metadata:
name: my-pipeline
spec:
vertices:
- name: my-udf
initContainers:
- name: my-init
image: busybox:latest
command: ["/bin/sh", "-c", "echo \"my-init is running!\" && sleep 60"]
udf:
container:
image: my-function:latest
```
The following example shows how to use init-containers and [`volumes`](./volumes.md) together to provide a `udf` container files on startup.
```yaml
apiVersion: numaflow.numaproj.io/v1alpha1
kind: Pipeline
metadata:
name: my-pipeline
spec:
vertices:
- name: my-udf
volumes:
- name: my-udf-data
emptyDir: {}
initContainers:
- name: my-init
image: amazon/aws-cli:latest
command: ["/bin/sh", "-c", "aws s3 sync s3://path/to/my-s3-data /path/to/my-init-data"]
volumeMounts:
- mountPath: /path/to/my-init-data
name: my-udf-data
udf:
container:
image: my-function:latest
volumeMounts:
- mountPath: /path/to/my-data
name: my-udf-data
```
6 changes: 3 additions & 3 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ simple-pipeline-cat-0-kqrhy 2/2 Running 0 10s
simple-pipeline-in-0-rhpjm 1/1 Running 0 11s

# Watch the log for the `output` vertex
kubectl logs -f simple-pipeline-out-0-xxxx main
kubectl logs -f simple-pipeline-out-0-xxxx
2022/08/25 23:59:38 (out) {"Data":"VT+G+/W7Dhc=","Createdts":1661471977707552597}
2022/08/25 23:59:38 (out) {"Data":"0TaH+/W7Dhc=","Createdts":1661471977707615953}
2022/08/25 23:59:38 (out) {"Data":"EEGH+/W7Dhc=","Createdts":1661471977707618576}
Expand Down Expand Up @@ -96,12 +96,12 @@ curl -kq -X POST -d "103" https://localhost:8444/vertices/in
curl -kq -X POST -d "104" https://localhost:8444/vertices/in

# Watch the log for the even vertex
kubectl logs -f even-odd-even-sink-0-nf2ql main
kubectl logs -f even-odd-even-sink-0-nf2ql
2022/09/07 22:29:40 (even-sink) 102
2022/09/07 22:29:40 (even-sink) 104

# Watch the log for the odd vertex
kubectl logs -f even-odd-odd-sink-0-a6p0n main
kubectl logs -f even-odd-odd-sink-0-a6p0n
2022/09/07 22:30:19 (odd-sink) 101
2022/09/07 22:30:19 (odd-sink) 103
```
Expand Down
9 changes: 9 additions & 0 deletions docs/user-defined-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ Some environment variables are available in the user defined function Pods, they
- `NUMAFLOW_REPLICA` - Replica index.
- `NUMAFLOW_PIPELINE_NAME` - Name of the pipeline.
- `NUMAFLOW_VERTEX_NAME` - Name of the vertex.

### Configuration

Configuration data can be provided to the UDF container at runtime multiple ways.
* [`environment variables`](./environment-variables.md)
* `args`
* `command`
* [`volumes`](./volumes.md)
* [`init containers`](./init-containers.md)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ nav:
- container-resources.md
- volumes.md
- environment-variables.md
- init-containers.md
- watermarks.md
- APIs.md
- Operator Manual:
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/numaflow/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (

// container names.
CtrInit = "init"
CtrMain = "main"
CtrMain = "numa"
CtrUdf = "udf"
CtrUdsink = "udsink"

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/numaflow/v1alpha1/container_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Test_containerBuilder(t *testing.T) {
resources: testResources,
}).
build()
assert.Equal(t, "main", c.Name)
assert.Equal(t, "numa", c.Name)
assert.Len(t, c.VolumeMounts, 0)
assert.Equal(t, testResources, c.Resources)
}
Loading

0 comments on commit 6c61728

Please sign in to comment.