Skip to content

Commit

Permalink
platform-api: multisite support
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxpiper committed May 7, 2023
1 parent bfad053 commit d148f29
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 6 deletions.
1 change: 1 addition & 0 deletions charts/platform-api/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests
2 changes: 1 addition & 1 deletion charts/platform-api/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
name: ushahidi-platform-api
version: 0.0.1-alpha.14
version: 0.0.1-alpha.15
icon: https://github.ushahidi.org/helm-charts/icon.png
144 changes: 143 additions & 1 deletion charts/platform-api/templates/api-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ spec:
port: 8080
{{- end }}
env:
- name: APP_ENV
value: {{ .Values.config.appenv | quote }}
- name: APP_KEY
{{- if .Values.config.appkey }}
value: {{ .Values.config.appkey | quote }}
Expand Down Expand Up @@ -165,7 +167,41 @@ spec:
- name: DOCKERIZE_WAIT_FOR_redis
value: "tcp://{{ .Values.config.redis.host }}:{{ .Values.config.redis.port }}"
- name: PHP_EXEC_TIME_LIMIT
value: {{ .Values.api.params.php_exec_time_limit | quote }}
value: {{ .Values.api.params.php_exec_time_limit | quote }}
{{- if .Values.config.shared_secret }}
- name: PLATFORM_SHARED_SECRET
value: {{ .Values.config.shared_secret | quote }}
{{- end }}
{{- if .Values.config.shared_secret_ref }}
- name: PLATFORM_SHARED_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.config.shared_secret_ref.name }}
key: {{ .Values.config.shared_secret_ref.key }}
{{- end }}
{{- if .Values.config.rackspace_filesystem }}
- name: FILESYSTEM_DRIVER
value: rackspace
- name: RS_REGION
value: {{ .Values.config.rackspace_filesystem.region | quote }}
- name: RS_CONTAINER
value: {{ .Values.config.rackspace_filesystem.container | quote }}
- name: RS_USERNAME
value: {{ .Values.config.rackspace_filesystem.username | quote }}
{{- if .Values.config.rackspace_filesystem.apikey }}
- name: RS_APIKEY
value: {{ .Values.config.rackspace_filesystem.apikey | quote }}
{{- end }}
{{- if .Values.config.rackspace_filesystem.apikey_secret }}
- name: RS_APIKEY
valueFrom:
secretKeyRef:
name: {{ .Values.config.rackspace_filesystem.apikey_secret.name }}
key: {{ .Values.config.rackspace_filesystem.apikey_secret.key }}
{{- end }}
{{- end }}
# {{- if .Values.config.s3_filesystem }}
# {{- end }}
- { name: ENABLE_NGINX, value: "true" }
- { name: ENABLE_PHPFPM, value: "true" }
- { name: ENABLE_PLATFORM_TASKS, value: "false" }
Expand All @@ -182,6 +218,19 @@ spec:
{{- if .Values.config.passport_keys_secret }}
- { name: PASSPORT_KEYS_PATH, value: "/var/www/.cfg/passport" }
{{- end }}
{{- if .Values.config.ush_analytics_prefix }}
- name: USH_ANALYTICS_PREFIX
value: {{ .Values.config.ush_analytics_prefix | quote }}
{{- end }}
{{- if .Values.config.multisite.enabled }}
- name: MULTISITE_DOMAIN
value: {{ .Values.config.multisite.api_domain | quote }}
- name: MULTISITE_CLIENT_DOMAIN
value: {{ .Values.config.multisite.domain | quote }}
- name: MULTISITE_EMAIL
value: {{ .Values.config.multisite.email | quote }}
{{- end }}

image: {{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}
imagePullPolicy: Always
name: api
Expand Down Expand Up @@ -298,6 +347,8 @@ spec:
- /entrypoint.CES.sh
- start
env:
- name: APP_ENV
value: {{ .Values.config.appenv | quote }}
- name: APP_KEY
{{- if .Values.config.appkey }}
value: {{ .Values.config.appkey | quote }}
Expand Down Expand Up @@ -395,6 +446,40 @@ spec:
value: "tcp://{{ .Values.config.db.host }}:{{ .Values.config.db.port }}"
- name: DOCKERIZE_WAIT_FOR_redis
value: "tcp://{{ .Values.config.redis.host }}:{{ .Values.config.redis.port }}"
{{- if .Values.config.shared_secret }}
- name: PLATFORM_SHARED_SECRET
value: {{ .Values.config.shared_secret | quote }}
{{- end }}
{{- if .Values.config.shared_secret_ref }}
- name: PLATFORM_SHARED_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.config.shared_secret_ref.name }}
key: {{ .Values.config.shared_secret_ref.key }}
{{- end }}
{{- if .Values.config.rackspace_filesystem }}
- name: FILESYSTEM_DRIVER
value: rackspace
- name: RS_REGION
value: {{ .Values.config.rackspace_filesystem.region | quote }}
- name: RS_CONTAINER
value: {{ .Values.config.rackspace_filesystem.container | quote }}
- name: RS_USERNAME
value: {{ .Values.config.rackspace_filesystem.username | quote }}
{{- if .Values.config.rackspace_filesystem.apikey }}
- name: RS_APIKEY
value: {{ .Values.config.rackspace_filesystem.apikey | quote }}
{{- end }}
{{- if .Values.config.rackspace_filesystem.apikey_secret }}
- name: RS_APIKEY
valueFrom:
secretKeyRef:
name: {{ .Values.config.rackspace_filesystem.apikey_secret.name }}
key: {{ .Values.config.rackspace_filesystem.apikey_secret.key }}
{{- end }}
{{- end }}
# {{- if .Values.config.s3_filesystem }}
# {{- end }}
- { name: ENABLE_NGINX, value: "false" }
- { name: ENABLE_PHPFPM, value: "false" }
- { name: ENABLE_PLATFORM_TASKS, value: "false" }
Expand All @@ -411,6 +496,19 @@ spec:
{{- if .Values.config.passport_keys_secret }}
- { name: PASSPORT_KEYS_PATH, value: "/var/www/.cfg/passport" }
{{- end }}
{{- if .Values.config.ush_analytics_prefix }}
- name: USH_ANALYTICS_PREFIX
value: {{ .Values.config.ush_analytics_prefix | quote }}
{{- end }}
{{- if .Values.config.multisite.enabled }}
- name: MULTISITE_DOMAIN
value: {{ .Values.config.multisite.api_domain | quote }}
- name: MULTISITE_CLIENT_DOMAIN
value: {{ .Values.config.multisite.domain | quote }}
- name: MULTISITE_EMAIL
value: {{ .Values.config.multisite.email | quote }}
{{- end }}

image: {{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}
imagePullPolicy: Always
name: worker
Expand Down Expand Up @@ -462,6 +560,8 @@ spec:
terminationGracePeriodSeconds: 15

# crond deployment (re-ocurring jobs)
# disabled for multi-site
{{- if not (.Values.config.multisite.enabled | default false) }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -504,6 +604,8 @@ spec:
- /entrypoint.CES.sh
- start
env:
- name: APP_ENV
value: {{ .Values.config.appenv | quote }}
- name: APP_KEY
{{- if .Values.config.appkey }}
value: {{ .Values.config.appkey | quote }}
Expand Down Expand Up @@ -601,6 +703,40 @@ spec:
value: "tcp://{{ .Values.config.db.host }}:{{ .Values.config.db.port }}"
- name: DOCKERIZE_WAIT_FOR_redis
value: "tcp://{{ .Values.config.redis.host }}:{{ .Values.config.redis.port }}"
{{- if .Values.config.shared_secret }}
- name: PLATFORM_SHARED_SECRET
value: {{ .Values.config.shared_secret | quote }}
{{- end }}
{{- if .Values.config.shared_secret_ref }}
- name: PLATFORM_SHARED_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.config.shared_secret_ref.name }}
key: {{ .Values.config.shared_secret_ref.key }}
{{- end }}
{{- if .Values.config.rackspace_filesystem }}
- name: FILESYSTEM_DRIVER
value: rackspace
- name: RS_REGION
value: {{ .Values.config.rackspace_filesystem.region | quote }}
- name: RS_CONTAINER
value: {{ .Values.config.rackspace_filesystem.container | quote }}
- name: RS_USERNAME
value: {{ .Values.config.rackspace_filesystem.username | quote }}
{{- if .Values.config.rackspace_filesystem.apikey }}
- name: RS_APIKEY
value: {{ .Values.config.rackspace_filesystem.apikey | quote }}
{{- end }}
{{- if .Values.config.rackspace_filesystem.apikey_secret }}
- name: RS_APIKEY
valueFrom:
secretKeyRef:
name: {{ .Values.config.rackspace_filesystem.apikey_secret.name }}
key: {{ .Values.config.rackspace_filesystem.apikey_secret.key }}
{{- end }}
{{- end }}
# {{- if .Values.config.s3_filesystem }}
# {{- end }}
- { name: ENABLE_NGINX, value: "false" }
- { name: ENABLE_PHPFPM, value: "false" }
- { name: ENABLE_PLATFORM_TASKS, value: "true" }
Expand All @@ -612,6 +748,11 @@ spec:
{{- if .Values.config.passport_keys_secret }}
- { name: PASSPORT_KEYS_PATH, value: "/var/www/.cfg/passport" }
{{- end }}
{{- if .Values.config.ush_analytics_prefix }}
- name: USH_ANALYTICS_PREFIX
value: {{ .Values.config.ush_analytics_prefix | quote }}
{{- end }}

image: {{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}
imagePullPolicy: Always
name: worker
Expand Down Expand Up @@ -661,6 +802,7 @@ spec:
{{- end }}
{{- end }}
terminationGracePeriodSeconds: 15
{{- end }}

{{- if .Values.api.ingress.enabled }}
---
Expand Down
66 changes: 66 additions & 0 deletions charts/platform-api/templates/memcached.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{- if .Values.memcached.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {}
labels:
app: platform
service: memcached
name: memcached

spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: platform
service: memcached
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: platform
service: memcached
spec:
containers:
- env: []
image: memcached:1-alpine
imagePullPolicy: Always
name: memcached
ports:
- containerPort: 11211
name: mysql
protocol: TCP
resources:
limits:
cpu: {{ .Values.memcached.limits.cpu }}
memory: {{ .Values.memcached.limits.memory }}
requests:
cpu: {{ .Values.memcached.requests.cpu }}
memory: {{ .Values.memcached.requests.memory }}
terminationGracePeriodSeconds: 5

---
apiVersion: v1
kind: Service
metadata:
labels:
app: platform
service: memcached
name: memcached
spec:
ports:
- name: memcached
port: 11211
protocol: TCP
targetPort: 11211
selector:
app: platform
service: memcached
type: ClusterIP
{{- end }}
60 changes: 56 additions & 4 deletions charts/platform-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,32 @@ image:
tag: latest

config:
appenv: staging
timezone: UTC
hdx_url: https://data.humdata.org/

# appkey:
# appkey_secret:
# name:
# key:
timezone: UTC
hdx_url: https://data.humdata.org/

# -- used for "signature authentication"
# shared_secret:
# shared_secret_ref:
# name:
# key:

# ush_analytics_prefix:

## this is mostly a placeholder for now, all that enabling multisite
## does is disabling the database migrations
## it also disables liveness checks since we don't have a proper endpoint
## that is independent of the backend finding the deployment
multisite:
enabled: false
# domain:
# api_domain:
# email:
##
db:
host: mysql
Expand All @@ -32,12 +46,15 @@ config:
redis:
host: redis
port: 6379
memcached:
host: memcached
port: 11211
drivers:
cache: redis
ratelimiter_cache: redis
queue: redis
filesystem: local
mail: log # -> e-mail disabled by default
# filesystem: local
# mail: log # -> e-mail disabled by default
mail_from:
address: [email protected]
name: "Platform Deployment Admin"
Expand All @@ -56,6 +73,30 @@ config:
# secret_ref:
# name:
# key:
#
# rackspace_filesystem:
# region:
# container:
# username:
# apikey:
# apikey_secret:
# name:
# key:
# TODO
# s3_filesystem:
# endpoint:
# region:
# bucket:
# access_key_id:
# access_key_id_secret:
# name:
# key:
# secret_access_key:
# secret_access_key_secret:
# name:
# key:


##
## Additional settings provided in .env file, note that this only works for
## versions after commit
Expand Down Expand Up @@ -153,3 +194,14 @@ redis:
requests:
cpu: "10m"
memory: "64Mi"

# This provides a compatible memcached server
memcached:
## Set to true to enable
enabled: false
limits:
cpu: "1"
memory: "128Mi"
requests:
cpu: "10m"
memory: "128Mi"

0 comments on commit d148f29

Please sign in to comment.