Skip to content

Commit

Permalink
Merge pull request #13 from EtherealEngine/batch-invalidation
Browse files Browse the repository at this point in the history
Added support for batch invalidation cronjob
  • Loading branch information
hanzlamateen authored Apr 17, 2024
2 parents 9c7e740 + 30ddbdb commit 1d641d4
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 10 deletions.
25 changes: 25 additions & 0 deletions configs/dev.template.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ api:
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: resources.<domain>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <cloudfront_distribution_id>
STORAGE_S3_REGION: us-east-1
Expand Down Expand Up @@ -232,6 +234,8 @@ media:
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: resources.<domain>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <cloudfront_distribution_id>
STORAGE_S3_REGION: us-east-1
Expand Down Expand Up @@ -282,6 +286,8 @@ instanceserver:
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: resources.<domain>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <cloudfront_distribution_id>
STORAGE_S3_REGION: us-east-1
Expand Down Expand Up @@ -403,6 +409,8 @@ builder:
SERVE_CLIENT_FROM_STORAGE_PROVIDER: "false"
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: <CLOUDFRONT_DOMAIN>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <CLOUDFRONT_DISTRIBUTION_ID>
STORAGE_S3_REGION: <S3_REGION>
Expand Down Expand Up @@ -436,3 +444,20 @@ builder:
values:
- ng-<RELEASE_NAME>-builder-1
replicaCount: 1

batchinvalidator:
enabled: true
image:
repository: <SOURCE_REPO_URL>/<SOURCE_REPO_NAME_STEM>-api
extraEnv:
AUTH_SECRET: <INSERT_A_UUID_OR_SOMETHING_SIMILAR>
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: <CLOUDFRONT_DOMAIN>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <CLOUDFRONT_DISTRIBUTION_ID>
STORAGE_S3_REGION: <S3_REGION>
STORAGE_S3_STATIC_RESOURCE_BUCKET: <S3_BUCKET_NAME>
STORAGE_S3_AVATAR_DIRECTORY: avatars
20 changes: 19 additions & 1 deletion configs/local.microk8s.template.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,22 @@ testbot:
APP_HOST: local.etherealengine.org
image:
repository: localhost:32000/etherealengine-testbot
pullPolicy: IfNotPresent
pullPolicy: IfNotPresent

batchinvalidator:
enabled: false
name: etherealengine-batchinvalidator
image:
repository: <SOURCE_REPO_URL>/<SOURCE_REPO_NAME_STEM>-api
extraEnv:
AUTH_SECRET: <INSERT_A_UUID_OR_SOMETHING_SIMILAR>
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: <CLOUDFRONT_DOMAIN>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <CLOUDFRONT_DISTRIBUTION_ID>
STORAGE_S3_REGION: <S3_REGION>
STORAGE_S3_STATIC_RESOURCE_BUCKET: <S3_BUCKET_NAME>
STORAGE_S3_AVATAR_DIRECTORY: avatars
20 changes: 19 additions & 1 deletion configs/local.minikube.template.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,22 @@ testbot:
APP_HOST: local.etherealengine.org
image:
repository: etherealengine-testbot
pullPolicy: IfNotPresent
pullPolicy: IfNotPresent

batchinvalidator:
enabled: false
name: etherealengine-batchinvalidator
image:
repository: <SOURCE_REPO_URL>/<SOURCE_REPO_NAME_STEM>-api
extraEnv:
AUTH_SECRET: <INSERT_A_UUID_OR_SOMETHING_SIMILAR>
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: <CLOUDFRONT_DOMAIN>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <CLOUDFRONT_DISTRIBUTION_ID>
STORAGE_S3_REGION: <S3_REGION>
STORAGE_S3_STATIC_RESOURCE_BUCKET: <S3_BUCKET_NAME>
STORAGE_S3_AVATAR_DIRECTORY: avatars
25 changes: 25 additions & 0 deletions configs/prod.template.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ api:
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: resources.<domain>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <cloudfront_distribution_id>
STORAGE_S3_REGION: us-east-1
Expand Down Expand Up @@ -232,6 +234,8 @@ media:
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: resources.<domain>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <cloudfront_distribution_id>
STORAGE_S3_REGION: us-east-1
Expand Down Expand Up @@ -282,6 +286,8 @@ instanceserver:
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: resources.<domain>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <cloudfront_distribution_id>
STORAGE_S3_REGION: us-east-1
Expand Down Expand Up @@ -400,6 +406,8 @@ builder:
SERVE_CLIENT_FROM_STORAGE_PROVIDER: "false"
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: <CLOUDFRONT_DOMAIN>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <CLOUDFRONT_DISTRIBUTION_ID>
STORAGE_S3_REGION: <S3_REGION>
Expand Down Expand Up @@ -433,3 +441,20 @@ builder:
values:
- ng-<RELEASE_NAME>-builder-1
replicaCount: 1

batchinvalidator:
enabled: true
image:
repository: <SOURCE_REPO_URL>/<SOURCE_REPO_NAME_STEM>-api
extraEnv:
AUTH_SECRET: <INSERT_A_UUID_OR_SOMETHING_SIMILAR>
STORAGE_PROVIDER: s3
STORAGE_AWS_ACCESS_KEY_ID: <S3_USER_ACCESS_KEY>
STORAGE_AWS_ACCESS_KEY_SECRET: <S3_USER_SECRET_KEY>
STORAGE_AWS_ROLE_ARN: <OPTIONAL_ROLE_ARN_TO_ASSUME>
STORAGE_AWS_ENABLE_ACLS: <TRUE/FALSE>
STORAGE_CLOUDFRONT_DOMAIN: <CLOUDFRONT_DOMAIN>
STORAGE_CLOUDFRONT_DISTRIBUTION_ID: <CLOUDFRONT_DISTRIBUTION_ID>
STORAGE_S3_REGION: <S3_REGION>
STORAGE_S3_STATIC_RESOURCE_BUCKET: <S3_BUCKET_NAME>
STORAGE_S3_AVATAR_DIRECTORY: avatars
4 changes: 2 additions & 2 deletions etherealengine/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 5.2.6
version: 5.3.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 1.5.0
appVersion: 1.6.0
35 changes: 34 additions & 1 deletion etherealengine/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ Expand the name of the chart.
{{- end -}}

{{- define "etherealengine.testbot.name" -}}
{{- default .Chart.Name (.Values.testbot).nameOverride | trunc 63 | trimSuffix "-" -}}
{{- default .Chart.Name .Values.testbot.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "etherealengine.batchinvalidator.name" -}}
{{- default .Chart.Name .Values.batchinvalidator.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}


Expand Down Expand Up @@ -102,6 +106,14 @@ If release name contains chart name it will be used as a full name.
{{- end -}}
{{- end -}}

{{- define "etherealengine.batchinvalidator.fullname" -}}
{{- if .Values.batchinvalidator.fullnameOverride -}}
{{- .Values.batchinvalidator.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Values.batchinvalidator.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "etherealengine.client.host" -}}
{{- printf "%s.%s.%s" "dashboard" .Release.Name .Values.domain -}}
{{- end -}}
Expand Down Expand Up @@ -249,6 +261,27 @@ app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: testbot
{{- end -}}

{{/*
Common labels
*/}}
{{- define "etherealengine.batchinvalidator.labels" -}}
helm.sh/chart: {{ include "etherealengine.chart" . }}
{{ include "etherealengine.batchinvalidator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "etherealengine.batchinvalidator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "etherealengine.batchinvalidator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: batchinvalidator
{{- end -}}


{{/*
Create the name of the service account to use
Expand Down
12 changes: 12 additions & 0 deletions etherealengine/templates/batch-invalidator-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if (.Values.batchinvalidator).enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "etherealengine.batchinvalidator.fullname" . }}
labels:
{{- include "etherealengine.batchinvalidator.labels" . | nindent 4 }}
data:
{{- if .Values.batchinvalidator.extraEnv }}
{{ toYaml .Values.batchinvalidator.extraEnv | indent 2 }}
{{- end }}
{{- end -}}
59 changes: 59 additions & 0 deletions etherealengine/templates/batch-invalidator-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if (.Values.batchinvalidator).enabled -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ template "etherealengine.batchinvalidator.fullname" . }}
spec:
schedule: "* * * * *" # Run every minute
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
parallelism: 1
template:
spec:
containers:
- name: batch-invalidator
image: "{{ .Values.batchinvalidator.image.repository }}:{{ .Values.batchinvalidator.image.tag }}"
envFrom:
- configMapRef:
name: {{ include "etherealengine.batchinvalidator.fullname" . }}
optional: true
env:
- name: SERVER_MODE
value: "api"
- name: KUBERNETES
value: "true"
{{ if .Values.sql }}
- name: MYSQL_USER
value: {{ .Values.sql.user }}
- name: MYSQL_DATABASE
value: {{ .Values.sql.database }}
- name: MYSQL_PASSWORD
value: {{ .Values.sql.password | quote }}
- name: MYSQL_HOST
value: {{ .Values.sql.host | quote }}
- name: MYSQL_PORT
value: {{ .Values.sql.port | quote }}
{{ else }}
- name: MYSQL_USER
value: server
- name: MYSQL_DATABASE
value: etherealengine
- name: MYSQL_PASSWORD
value: password
- name: MYSQL_HOST
value: host.minikube.internal
- name: MYSQL_PORT
value: 3306
{{ end }}
command: [
'npx',
'cross-env',
'ts-node',
'--swc',
'scripts/run-batch-invalidation.ts'
]
restartPolicy: Never
{{- end }}
36 changes: 31 additions & 5 deletions etherealengine/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ client:

replicaCount: 1
image:
repository: lagunalabs/etherealengine
repository: etherealengine/etherealengine-dev
tag: latest
pullPolicy: IfNotPresent

Expand Down Expand Up @@ -69,7 +69,7 @@ api:

replicaCount: 1
image:
repository: lagunalabs/etherealengine
repository: etherealengine/etherealengine-dev
tag: latest
pullPolicy: IfNotPresent

Expand Down Expand Up @@ -170,7 +170,7 @@ media:

replicaCount: 1
image:
repository: lagunalabs/etherealengine
repository: etherealengine/etherealengine-dev
tag: latest
pullPolicy: IfNotPresent

Expand Down Expand Up @@ -258,7 +258,7 @@ instanceserver:

replicaCount: 1
image:
repository: lagunalabs/etherealengine
repository: etherealengine/etherealengine-dev
tag: latest
pullPolicy: IfNotPresent

Expand Down Expand Up @@ -303,7 +303,7 @@ taskserver:

replicaCount: 1
image:
repository: lagunalabs/etherealengine
repository: etherealengine/etherealengine-dev
tag: latest
pullPolicy: IfNotPresent

Expand All @@ -322,6 +322,32 @@ taskserver:
type: ClusterIP
port: 3030

serviceAccount:
create: true
annotations: {}
name:

batchinvalidator:
enabled: true
name: etherealengine-batchinvalidator

replicaCount: 1
image:
repository: etherealengine/etherealengine-dev
tag: latest
pullPolicy: IfNotPresent

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

resources: {}
nodeSelector: {}
tolerations: []
affinity: {}
podSecurityContext: {}
securityContext: {}

serviceAccount:
create: true
annotations: {}
Expand Down

0 comments on commit 1d641d4

Please sign in to comment.