Skip to content

Commit

Permalink
Merge pull request #1596 from Sefaria/remove-sandbox-flags
Browse files Browse the repository at this point in the history
Remove sandbox flags
  • Loading branch information
edamboritz authored Aug 23, 2023
2 parents 439946c + c8af1ec commit 225eb87
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 54 deletions.
5 changes: 5 additions & 0 deletions build/ci/production-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ sandbox: "false"
contentSandbox: "false"
deployEnv: production
previousServicesCount: "3"
deploymentMessage: true
restore:
enabled: false
dynamicName: false
cleanup: false
backup:
mongo:
enabled: true
Expand Down Expand Up @@ -52,6 +55,7 @@ redis:
containerImage:
imageRegistry: redis
tag: latest
pdb: true
resources:
requests:
memory: "500Mi"
Expand Down Expand Up @@ -138,6 +142,7 @@ nginx:
imageRegistry:
tag:
SEARCH_HOST: elasticsearch-data
disableScraping: false
replicaCount: 2
resources:
requests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if eq .Values.backup.mongo.enabled true }}
{{- if .Values.backup.mongo.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -10,7 +10,7 @@ data:
create-dumps.sh: |-
#!/usr/bin/env bash
{{- if eq .Values.sandbox "true" }}
{{- if .Values.restore.dynamicName }}
DATABASE="${SEFARIA_DB}-{{ .Values.deployEnv | quote }}"
{{- else }}
DATABASE="${SEFARIA_DB}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ data:
MONGO_HOST = os.getenv("MONGO_HOST")
MONGO_PORT = 27017
{{- if eq .Values.sandbox "true" }}
{{- if .Values.restore.dynamicName }}
SEFARIA_DB = os.getenv("SEFARIA_DB") + "-" + {{ .Values.deployEnv | quote }}
{{- else }}
SEFARIA_DB = os.getenv("SEFARIA_DB")
Expand Down Expand Up @@ -334,4 +334,4 @@ data:
# Example: If a text or ref cannot be properly loaded, fail gracefully and let the server continue to run
FAIL_GRACEFULLY = os.getenv("FAIL_GRACEFULLY").lower() == "true"
if "pytest" in sys.modules:
FAIL_GRACEFULLY = False
FAIL_GRACEFULLY = False
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if eq .Values.sandbox "true" }}
{{- if .Values.restore.cleanup }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -16,11 +16,17 @@ data:
set -e
set -x
mongo --host $MONGO_HOST sefaria-$SANDBOX_NAME <<EOF
{{- if .Values.restore.dynamicName }}
DB_NAME="$SEFARIA_DB-{{ .Values.deployEnv }}"
{{ else }}
DB_NAME=$SEFARIA_DB
{{ end }}
mongo --host $MONGO_HOST $DB_NAME <<EOF
db.dropDatabase();
EOF
mongo --host $MONGO_HOST apscheduler-$SANDBOX_NAME <<EOF
mongo --host $MONGO_HOST $APSCHEDULER_NAME <<EOF
db.dropDatabase();
EOF
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if eq .Values.sandbox "true" }}
{{- if .Values.restore.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
data:
robots.txt: |-
User-agent: *
{{- if eq .Values.sandbox "true" }}
{{- if .Values.nginx.disableScraping }}
Disallow: /
{{- else }}
Disallow: /activity/
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/sefaria-project/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
spec:
tls:
- secretName: {{ template "sefaria.secrets.originTls" . }}
{{- if ne .Values.sandbox "true" }}
{{- if or .Values.ingress.secrets.originIlTls.data .Values.ingress.secrets.originIlTls.ref }}
- secretName: {{ template "sefaria.secrets.originIlTls" . }}
{{- end }}
rules:
Expand Down
25 changes: 16 additions & 9 deletions helm-chart/sefaria-project/templates/jobs/mongo-destroy.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# NB: This assumes an already-functioning mongo instance.
# Parameters:
# MONGO_HOST: Mongo hostname
# SANDBOX_NAME: The name of the table created by this job
---
{{- if eq .Values.sandbox "true" }}
{{- if .Values.restore.cleanup }}
apiVersion: batch/v1
kind: Job
metadata:
Expand All @@ -21,11 +18,21 @@ spec:
containers:
- name: destroy-mongo-{{ .Values.deployEnv }}
image: mongo:4.4
env:
- name: MONGO_HOST
value: {{ .Values.localSettings.MONGO_HOST | quote }}
- name: SANDBOX_NAME
value: {{ .Values.deployEnv }}
envFrom:
- secretRef:
name: {{ .Values.secrets.localSettings.ref }}
optional: true
- configMapRef:
name: local-settings-{{ .Values.deployEnv }}
- secretRef:
name: local-settings-secrets-{{ .Values.deployEnv }}
optional: true
- configMapRef:
name: local-settings-web-{{ .Values.deployEnv }}
optional: true
- secretRef:
name: local-settings-web-secrets-{{ .Values.deployEnv }}
optional: true
command: ["/script/destroy-mongo.sh"]
volumeMounts:
- name: script
Expand Down
7 changes: 1 addition & 6 deletions helm-chart/sefaria-project/templates/jobs/mongo-restore.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# NB: This assumes an already-functioning mongo instance.
# Parameters:
# MONGO_DUMP_PATH: URI of database dump
# MONGO_HOST: Mongo hostname
# SANDBOX_NAME: The name of the table created by this job
# ENVIRONMENT: Deployment environment {prod, preprod, stage}
---
{{- if and (eq .Values.sandbox "true") .Values.restore.enabled }}
{{- if .Values.restore.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if eq .Values.sandbox "false" }}
{{- if .Values.redis.pdb }}
# TODO: This could be made global by matching on label `stackRole: redis` instead
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
Expand Down
4 changes: 2 additions & 2 deletions helm-chart/sefaria-project/templates/rollout/nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ spec:
value: web-{{ .Values.deployEnv }}-{{ .Release.Revision }}
- name: DJANGO_PORT
value: "80"
- name: DEBUG
value: {{ if eq .Values.sandbox "true" }}"true"{{ else }}"false"{{ end }}
- name: REDIS_HOST
value: redis-{{ .Values.deployEnv }}
- name: DEBUG
value: {{ .Values.localSettings.DEBUG | quote }}
envFrom:
- configMapRef:
name: local-settings-node-{{ .Values.deployEnv }}
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/sefaria-project/templates/rollout/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
args:
- name: healthcheck-hostname
value: "nginx-{{ .Values.deployEnv }}-{{ .Release.Revision }}"
{{- if eq .Values.sandbox "false" }}
{{- if .Values.deploymentMessage }}
postPromotionAnalysis:
templates:
- templateName: rollout-complete-{{ .Values.deployEnv }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ metadata:
labels:
deployEnv: "{{ .Values.deployEnv }}"
app: nginx-{{ .Values.deployEnv }}
sandbox: "{{ .Values.sandbox }}"
{{- if eq .Values.sandbox "true" }}
sandbox-name: "{{ .Values.deployEnv }}"
argoPreview: "true"
{{- end }}
spec:
type: {{ if eq .Values.sandbox "true" }}ClusterIP{{ else }}NodePort{{ end }}
ports:
- name: http
port: 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ metadata:
labels:
deployEnv: "{{ $.Values.deployEnv }}"
app: nginx-{{ $.Values.deployEnv }}
sandbox: "{{ $.Values.sandbox }}"
releaseRevision: "{{ $v }}"
{{- if eq $.Values.sandbox "true" }}
sandbox-name: "{{ $.Values.deployEnv }}"
{{- end }}
spec:
type: {{ if eq $.Values.sandbox "true" }}ClusterIP{{ else }}NodePort{{ end }}
ports:
- name: http
port: 80
Expand Down
5 changes: 0 additions & 5 deletions helm-chart/sefaria-project/templates/service/nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ metadata:
labels:
deployEnv: "{{ .Values.deployEnv }}"
app: nginx-{{ .Values.deployEnv }}
sandbox: "{{ .Values.sandbox }}"
{{- if eq .Values.sandbox "true" }}
sandbox-name: "{{ .Values.deployEnv }}"
{{- end }}
spec:
type: {{ if eq .Values.sandbox "true" }}ClusterIP{{ else }}NodePort{{ end }}
ports:
- name: http
port: 80
Expand Down
20 changes: 11 additions & 9 deletions helm-chart/sefaria-project/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# ID.)
releaseImageTag:

# Setting this to true will make this a sandbox environment. It'll set the
# following:
# - nodeAffinity for the Monitor, Nodejs, Redis, Varnish, Web & Nginx pod to
# schedule opn node where preemptible=true
# - Set appropriate labels to Nginx pod
# - Requests images with the tag "sandbox-<releaseImageTag>"
sandbox: "false"

# This value sets the name of the environment and it's associated objects. Some
Expand All @@ -22,10 +16,15 @@ deployEnv: "dev"
# tags that help ArgoCD do blue green deployments.
previousServicesCount: "3"

# runs post-promotion job with slack hook to alert when deployment is complete
deploymentMessage: false

# write the full path to the back up if you want to start the environment from
# a specific backup else leave blank.
restore:
enabled: true
dynamicName: true
cleanup: true
bucket: sefaria-mongo-backup
# tarball:
serviceAccount: database-backup-read
Expand Down Expand Up @@ -175,6 +174,8 @@ redis:
limits:
memory: "500Mi"
cpu: "120m"
# enable pod disruption budget
pdb: false

nodejs:
containerImage:
Expand Down Expand Up @@ -250,7 +251,7 @@ ingress:
# If you're using a refenrece to an existing secret then the data: section
# should be commented out and vice-versa.
# Reference to an existing secret in the cluster
# "cauldron-wildcard-letsencrypt" is for sandboxes, wildcard cert managed
# "cauldron-wildcard-letsencrypt" is for cauldrons, wildcard cert managed
# via infrastructure
ref:
# for local testing purposes or CI pipeline use input a value
Expand All @@ -276,6 +277,7 @@ nginx:
tag: latest
# set to search-democracy for democracy
SEARCH_HOST: elasticsearch-es-default.elasticsearch
disableScraping: true
# key-pair values to load into nginx pod environment. Takes precedence over global localsettings
localsettings:
# APP: nginx
Expand Down Expand Up @@ -396,15 +398,15 @@ cronJobs:
enabled: false

localSettings:
DEBUG: "False"
DEBUG: true
DOMAIN_LANGUAGE: {}
# https://www.sefaria.org: english
# https://www.sefaria.org.il: hebrew
MONGO_HOST: "mongo"
APSCHEDULER_NAME: "apscheduler-{{ .Values.deployEnv }}"
TURN_SERVER: ''
USE_CLOUDFLARE: false
FRONT_END_URL: "http://www.sefaria.org" # Use "http://${ENV_NAME}.sandbox.sefaria.org" in sandboxes and cauldrons
FRONT_END_URL: "http://www.sefaria.org" # Use "http://${ENV_NAME}.cauldron.sefaria.org" in cauldrons
OFFLINE: "False"
DOWN_FOR_MAINTENANCE: "False"
MAINTENANCE_MESSAGE: "Sefaria is down for scheduled maintenance. We expect to be back online within 15 minutes. Thank you for your patience."
Expand Down

0 comments on commit 225eb87

Please sign in to comment.