Skip to content

Commit

Permalink
Merge branch 'memory-allocation' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
brown-a2 committed Nov 8, 2024
2 parents a3b3c1a + 4368efb commit 84dee68
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 48 deletions.
12 changes: 12 additions & 0 deletions helm_deploy/wordpress/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "wp.replicaCount" -}}
{{- if eq .Values.configmap.envtype "staging" -}}
{{ .Values.replicaCount.staging }}
{{- else if eq .Values.configmap.envtype "dev" -}}
{{ .Values.replicaCount.dev }}
{{- else if eq .Values.configmap.envtype "demo" -}}
{{ .Values.replicaCount.demo }}
{{- else -}}
{{ .Values.replicaCount.prod }}
{{- end -}}
{{- end }}
54 changes: 28 additions & 26 deletions helm_deploy/wordpress/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ metadata:
labels:
app: wordpress
spec:
{{- if eq .Values.configmap.envtype "staging" }}
replicas: {{ .Values.wp.image.replicaCount.staging }}
{{ else if eq .Values.configmap.envtype "dev" }}
replicas: {{ .Values.wp.image.replicaCount.dev }}
{{ else if eq .Values.configmap.envtype "demo" }}
replicas: {{ .Values.wp.image.replicaCount.demo }}
{{ else }}
replicas: {{ .Values.wp.image.replicaCount.prod }}
{{- end }}
replicas: {{ include "wp.replicaCount" . }}
selector:
matchLabels:
app: wordpress
Expand All @@ -32,17 +24,18 @@ spec:
spec:
terminationGracePeriodSeconds: 35
serviceAccountName: hale-platform-{{ .Values.configmap.envtype }}-service

containers:
- image: {{ .Values.wp.image.repository }}
- name: wordpress
image: {{ .Values.wp.image.repository }}
imagePullPolicy: {{ .Values.wp.image.imagePullPolicy }}
name: wordpress
resources:
requests:
cpu: {{ index .Values.wp.resources .Values.configmap.envtype "requests" "cpu" }}
memory: {{ index .Values.wp.resources .Values.configmap.envtype "requests" "memory" }}
limits:
cpu: {{ index .Values.wp.resources .Values.configmap.envtype "requests" "cpu" }}
memory: {{ index .Values.wp.resources .Values.configmap.envtype "requests" "memory" }}
cpu: {{ index .Values.wp.resources .Values.configmap.envtype "limits" "cpu" }}
memory: {{ index .Values.wp.resources .Values.configmap.envtype "limits" "memory" }}
env:
- name: PHP_INI_SCAN_DIR
value: :/usr/local/etc/php/conf.custom
Expand All @@ -58,25 +51,27 @@ spec:
name: hale-wp-config-{{ .Release.Revision }}
- secretRef:
name: hale-wp-secrets-{{ .Release.Revision }}
{{- if or (eq .Values.configmap.envtype "prod") (eq .Values.configmap.envtype "staging") }}

{{- if or (eq .Values.configmap.envtype "prod") (eq .Values.configmap.envtype "staging") }}
readinessProbe:
exec:
command:
- /bin/sh
- -c
- |
if [ -f /var/www/html/wp-load.php ] && ps aux | grep -q "[p]hp-fpm"
then
exit 0
else
exit 1
fi
- /bin/sh
- -c
- |
if [ -f /var/www/html/wp-load.php ] && ps aux | grep -q "[p]hp-fpm"
then
exit 0
else
exit 1
fi
initialDelaySeconds: 30
periodSeconds: 3
timeoutSeconds: 10
successThreshold: 1
failureThreshold: 3
{{- end }}
{{- end }}

- name: nginx
image: {{ .Values.nginx.image.repository }}
imagePullPolicy: {{ .Values.nginx.image.imagePullPolicy }}
Expand All @@ -85,14 +80,20 @@ spec:
cpu: {{ index .Values.nginx.resources .Values.configmap.envtype "requests" "cpu" }}
memory: {{ index .Values.nginx.resources .Values.configmap.envtype "requests" "memory" }}
limits:
<<<<<<< HEAD
cpu: {{ index .Values.nginx.resources .Values.configmap.envtype "requests" "cpu" }}
memory: {{ index .Values.nginx.resources .Values.configmap.envtype "requests" "memory" }}
=======
cpu: {{ index .Values.nginx.resources .Values.configmap.envtype "limits" "cpu" }}
memory: {{ index .Values.nginx.resources .Values.configmap.envtype "limits" "memory" }}
>>>>>>> memory-allocation
ports:
- containerPort: 8080
volumeMounts:
- name: wordpress-volume-file-mount
mountPath: /var/www/html
{{- if or (eq .Values.configmap.envtype "prod") (eq .Values.configmap.envtype "staging") }}

{{- if or (eq .Values.configmap.envtype "prod") (eq .Values.configmap.envtype "staging") }}
readinessProbe:
exec:
command:
Expand All @@ -109,7 +110,8 @@ spec:
timeoutSeconds: 10
successThreshold: 1
failureThreshold: 3
{{- end }}
{{- end }}

volumes:
- name: wordpress-volume-file-mount
emptyDir: {}
Expand Down
63 changes: 41 additions & 22 deletions helm_deploy/wordpress/values.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Default values for wordpress.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
## Default values for WordPress Multisite installation.
## This is a YAML-formatted file.
## Declare variables to be passed into your templates.

# Empty strings mean value is overwritten and populated when run by GitAction
# during deployment
## Empty strings mean value is overwritten and populated when run by GitAction
## during deployment

## @param root domain
##
domain: ""

## @param NGINX config
##
nginx:
image:
repository: ""
imagePullPolicy: Always

# Apply pod level resource allocation
# Apply container level resource allocation
resources:
dev:
limits:
Expand All @@ -36,26 +40,21 @@ nginx:
cpu: "50m"
memory: "150Mi"
prod:
requests:
cpu: "100m"
memory: "300Mi"
limits:
cpu: "200m"
cpu: "500m"
memory: "500Mi"
requests:
cpu: "100m"
memory: "200Mi"

## @param Wordpress specific paramaters
##
wp:
image:
repository: ""
imagePullPolicy: Always

# Default if HPA is not turned on
replicaCount:
prod: 3
staging: 2
dev: 1
demo: 2

# Apply pod level resource allocation
# Apply container level resource allocation
resources:
dev:
limits:
Expand All @@ -79,20 +78,35 @@ wp:
cpu: "150m"
memory: "1500Mi"
prod:
limits:
cpu: "1500m"
memory: "3500Mi"
requests:
cpu: "500m"
memory: "1500Mi"
limits:
cpu: "1000m"
memory: "2500Mi"

## @param Horizontal Pod Autoscaler
##
hpa:
enabled: true

## @param Manage replica count
## Default settings when HPA is not turned on
##
replicaCount:
prod: 3
staging: 2
dev: 1
demo: 2

## @param Turn on/off cron tasks
##
cron:
feedparser:
enabled: true

## @param Manage traffic/domains via NGINX ingress
##
ingress:
enabled: true
metadata:
Expand Down Expand Up @@ -226,13 +240,16 @@ ingress:
- name: www.legalaidlearning.justice.gov.uk
certName: legalaidlearning-www-cert


## @param Non-secret env variables
##
configmap:
servername: ""
envtype: ""
s3useprofile: "true"
sentrydns: ""

## @param secrets passed in via GitActions
##
secrets:
enabled: true
wpdbuser: ""
Expand All @@ -256,6 +273,8 @@ secrets:
avatureFeedUserName: ""
avatureFeedUserPassword: ""

## @param Toggle alerts on/off
##
alertSecrets:
enabled: true
slackWebhookUrl: ""
Expand Down

0 comments on commit 84dee68

Please sign in to comment.