Skip to content

Commit

Permalink
Merge pull request #20 from bytewax/pvc
Browse files Browse the repository at this point in the history
Adding VPC resource for recovery
  • Loading branch information
miccioest authored Jun 6, 2023
2 parents e381cc3 + 9d9803a commit 5a9d7df
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 8 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The command removes all the Kubernetes components associated with the chart and
| Parameter | Description | Default |
|-------------------------------------------|-----------------------------------------------|---------------------------------------------------------|
| `image.repository` | Image repository | `bytewax.docker.scarf.sh/bytewax/bytewax` |
| `image.tag` | Image tag | `0.16.1-python3.9` |
| `image.tag` | Image tag | `0.16.2-python3.9` |
| `image.pullPolicy` | Image pull policy | `Always` |
| `imagePullSecrets` | Image pull secrets | `[]` |
| `serviceAccount.create` | Create service account | `true` |
Expand All @@ -72,7 +72,7 @@ The command removes all the Kubernetes components associated with the chart and
| `envRenderSecret` | Sensible environment variables passed to pods and stored as secret | `{}` |
| `extraSecretMounts` | Secret mounts to get secrets from files instead of env vars | `[]` |
| `extraVolumeMounts` | Additional volume mounts | `[]` |
| `configuration.pythonFileName` | Path of the python file to run | `basic.py` |
| `configuration.pythonFileName` | Path of the python file to run | `simple.py` |
| `configuration.processesCount` | Number of concurrent processes to run | `1` |
| `configuration.workersPerProcess` | Number of workers per process | `1` |
| `configuration.jobMode` | Create a kubernetes Job resource instead of a Statefulset (use this for batch processing) - Kubernetes version required: 1.24 or superior | `false` |
Expand All @@ -81,6 +81,13 @@ The command removes all the Kubernetes components associated with the chart and
| `configuration.configMap.customName` | Configmap which has python file(s) created manually | `` |
| `configuration.configMap.files.pattern` | Files to store in the ConfigMap to be created | `examples/*` |
| `configuration.configMap.files.tarName` | Tar file to store in the ConfigMap to be created | `` |
| `configuration.recovery.enabled` | Enable Recovery | `false` |
| `configuration.recovery.persistence.accessModes` | Persistence access modes | `[ReadWriteOnce]` |
| `configuration.recovery.persistence.size` | Size of persistent volume claim | `10Gi` |
| `configuration.recovery.persistence.annotations` | PersistentVolumeClaim annotations | `{}` |
| `configuration.recovery.persistence.finalizers` | PersistentVolumeClaim finalizers | `[ "kubernetes.io/pvc-protection" ]` |
| `configuration.recovery.persistence.extraPvcLabels` | Extra labels to apply to the PVC | `{}` |
| `configuration.recovery.persistence.storageClassName` | Type of persistent volume claim | `nil` |
| `customOtlpUrl` | OTLP Endpoint URL | `` |
| `opentelemetry-collector.enabled` | Install OpenTelemetry Collector Helm Chart | `false` |
| `jaeger.enabled` | Install Jaeger Helm Chart | `false` |
Expand Down
4 changes: 2 additions & 2 deletions charts/bytewax/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: bytewax
description: A Helm chart for Bytewax
type: application
version: 0.6.0
appVersion: "0.16.1"
version: 0.6.1
appVersion: "0.16.2"
icon: https://bytewax.io/assets/img/favicon.png
dependencies:
- condition: opentelemetry-collector.enabled
Expand Down
9 changes: 9 additions & 0 deletions charts/bytewax/examples/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ./simple.py
from bytewax.dataflow import Dataflow
from bytewax.testing import TestingInput
from bytewax.connectors.stdio import StdOutput

flow = Dataflow()
flow.input("inp", TestingInput(range(99999999)))
flow.map(lambda item: item + 1)
flow.output("out", StdOutput())
13 changes: 13 additions & 0 deletions charts/bytewax/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ spec:
{{- else }}
value: "http://{{ .Release.Name }}-opentelemetry-collector:4317"
{{- end }}
{{- if .Values.configuration.recovery.enabled }}
- name: BYTEWAX_SQLITE_DIRECTORY
value: /var/recovery
{{- end }}
{{- range $key, $value := .Values.env }}
- name: "{{ tpl $key $ }}"
value: "{{ tpl (print $value) $ }}"
Expand Down Expand Up @@ -154,6 +158,10 @@ spec:
mountPath: /etc/bytewax
- name: working-directory
mountPath: /var/bytewax/
{{- if .Values.configuration.recovery.enabled }}
- name: recovery
mountPath: /var/recovery
{{- end }}
volumes:
- name: hostfile
emptyDir: {}
Expand Down Expand Up @@ -192,4 +200,9 @@ spec:
emptyDir: {}
{{- end }}
{{- end }}
{{- if .Values.configuration.recovery.enabled }}
- name: recovery
persistentVolumeClaim:
claimName: {{ .Release.Name }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions charts/bytewax/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if and .Values.configuration.jobMode .Values.configuration.recovery.enabled}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "bytewax.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: "keep"
{{- with .Values.configuration.recovery.persistence.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.configuration.recovery.persistence.finalizers }}
finalizers:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
{{- range .Values.configuration.recovery.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.configuration.recovery.persistence.size | quote }}
{{- with .Values.configuration.recovery.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- with .Values.configuration.recovery.persistence.selectorLabels }}
selector:
matchLabels:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
40 changes: 39 additions & 1 deletion charts/bytewax/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ metadata:
{{- include "bytewax.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.configuration.processesCount }}
{{- if .Values.configuration.recovery.enabled }}
volumeClaimTemplates:
- metadata:
name: recovery
annotations:
helm.sh/resource-policy: "keep"
{{- with .Values.configuration.recovery.persistence.annotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.configuration.recovery.persistence.finalizers }}
finalizers:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
accessModes:
{{- range .Values.configuration.recovery.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.configuration.recovery.persistence.size }}
{{- with .Values.configuration.recovery.persistence.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- with .Values.configuration.recovery.persistence.selectorLabels }}
selector:
matchLabels:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
selector:
matchLabels:
bytewax.io/dataflow-info: {{ .Release.Name }}
Expand All @@ -25,7 +55,7 @@ spec:
{{- include "bytewax.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- end }}
spec:
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
Expand Down Expand Up @@ -146,6 +176,10 @@ spec:
{{- else }}
value: "http://{{ .Release.Name }}-opentelemetry-collector:4317"
{{- end }}
{{- if .Values.configuration.recovery.enabled }}
- name: BYTEWAX_SQLITE_DIRECTORY
value: /var/recovery
{{- end }}
{{- range $key, $value := .Values.env }}
- name: "{{ tpl $key $ }}"
value: "{{ tpl (print $value) $ }}"
Expand Down Expand Up @@ -179,6 +213,10 @@ spec:
mountPath: /etc/bytewax
- name: working-directory
mountPath: /var/bytewax/
{{- if .Values.configuration.recovery.enabled }}
- name: recovery
mountPath: /var/recovery
{{- end }}
volumes:
{{- if .Values.api.enabled }}
- name: api-cache
Expand Down
22 changes: 19 additions & 3 deletions charts/bytewax/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image:
repository: bytewax.docker.scarf.sh/bytewax/bytewax
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "0.16.1-python3.9"
tag: "0.16.2-python3.9"

imagePullSecrets: []

Expand Down Expand Up @@ -116,17 +116,33 @@ extraVolumeMounts: []
# hostPath: /usr/shared/

configuration:
pythonFileName: "k8s_basic.py"
pythonFileName: "simple.py"
processesCount: 1
workersPerProcess: 1
keepAlive: false
jobMode: false
configMap:
create: true
customName:
customName:
files:
pattern: "examples/*"
tarName: ""
recovery:
enabled: false
## Enable recovery using Kubernetes Persistent Volume Claims to store Sqlite files
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
# storageClassName: default
accessModes:
- ReadWriteOnce
size: 10Gi
# annotations: {}
finalizers:
- kubernetes.io/pvc-protection
# selectorLabels: {}
## Extra labels to apply to a PVC.
extraPvcLabels: {}

## Configuration examples ##
#
Expand Down

0 comments on commit 5a9d7df

Please sign in to comment.