This repository manages the AWS resources needed to build the community version as code in terraform and deploys them using helm.
By writing the AWS resources required for Hubs Community edition as IaC in terraform, resources can be built in one shot with terraform apply.
This is useful for preventing simple mistakes in configuring manually in the AWS console and for deploying to multiple environments.
This repository depends on mozilla-hubs-ce-chart.
This repository is based on the following document. These documents may be updated.
- Hubs Community Edition Is Here!
- Deploying Mozilla Hubs CE on AWS with Ease: A Guide to the Scale Edition Helm Chart
- Deploying Community Edition on AWS with Alex Griggs' Helm Chart
- MacBook Pro
- CPU: Apple M3 Pro
- macOS: Sonoma 14.2.1
This is only my confirmed environment, so other environments can be deployed.
Configure your DNS according to Step 1: Configuring your DNS on AWS's Route53
-
Create S3 bucket for infrastructure state management files (tfstate)
-
Execute the following commands in a terminal {environment}: AWS Environment Name (ex. develop)
aws s3api create-bucket --bucket ov-hubs-ce-tfstate-{environment} --region us-east-1
💡 Only when region is not us-east-1, specify
--create-bucket-configuration LocationConstraint={region}
-
-
Create tfbackend file
-
Create
{env_name}.tfbackend
touch {env_name}.tfbackend
-
Enter and update values in the
{env_name}.tfbackend
file, referring to the sample configuration file -
Create
{env_name}.tfvars
touch {env_name}.tfvars
-
Enter and update values in the
{env_name}.tfvars
file, referring to the sample configuration file. TheENV_NAME_TAG
should match the{env_name}
.💡 When adding environment variables, in addition to editing the
{env_name}.tfvars
file, it is necessary to define the variables invariables.tf
-
-
Terraform Initialize
sh terraform.sh {env_name} init
-
Format
sh terraform.sh {env_name} fmt
-
Validation
sh terraform.sh {env_name} validate
-
Build Environment
sh terraform.sh {env_name} apply
A list of resources to be created will be output. If there are no problems, enter "yes".
When the process is completed, resources such as VPCs and EKSs whose definitions are created in the AWS environment.
Configure your SMTP according to Step 2: Configuring your SMTP on AWS's Simple Email Service (SES)
💡 The helm chart configuration basically follows the document below. **[Deploying Mozilla Hubs CE on AWS with Ease: A Guide to the Scale Edition Helm Chart](https://hubs.mozilla.com/labs/deploying-mozilla-hubs-ce-on-aws-with-ease-a-guide-to-the-scale-edition-helm-chart/)**-
Setup Helm
-
Create a namespace named hcce in the EKS cluster
kubectl create ns hcce
-
Create a namespace named security in the EKS cluster
kubectl create ns security
-
Add the jetstack repository to helm and install cert-manager in the namespace security.
helm repo add jetstack https://charts.jetstack.io helm repo update helm install cert-manager jetstack/cert-manager \ --namespace security \ --set ingressShim.defaultIssuerName=letsencrypt-issuer \ --set ingressShim.defaultIssuerKind=ClusterIssuer \ --set installCRDs=true
-
Create
{env_name}-cluster-issuer.yaml
touch {env_name}-cluster-issuer.yaml
-
Update the email to the administrator's email address in
{env_name}-cluster-issuer.yaml
-
Apply Issuer to EKS
kubectl apply -f '{env_name}-cluster-issuer.yaml'
-
Get the helm chart resources for hubs ce by git clone from the repository for Mozilla Hubs CE Chart
git clone https://github.com/hubs-community/mozilla-hubs-ce-chart.git
-
Copy the event file with the following command
cp mozilla-hubs-ce-chart/values.scale.yaml {env_name}-values-event.yaml
-
update
render_helm.sh
inmozilla-hubs-ce-chart
folder-
put random strings in the following three variables in the
render_helm.sh
file.NODE_COOKIE="node-{YOUR_NODE_COOKIE_ID}" GUARDIAN_KEY="{YOUR_GUARDIAN_KEY}" PHX_KEY="{YOUR_PHX_KEY}"
-
Update DB authentication information in
render_helm.sh
fileDB_USER="postgres" DB_PASS="123456" EXT_DB_HOST="pgsql"
DB_USER
: DB_MASTER_USERNAME specified in{env_name}.tfvars
DB_PASS
: DB_MASTER_PASSWORD specified in{env_name}.tfvars
EXT_DB_HOST
: Value output when the following command is executedsh terraform.sh {env_name} output -raw rds_writer_endpoint
-
Update SMTP information in
render_helm.sh
file
Update the settings based on the information configured in "4. Configure SMTP on SES”SMTP_SERVER: SMTP endpoint SMTP_USER: SMTP username as listed in the csv you downloaded your credentials (note that this is not an IAM user) SMTP_PASS: SMTP password from the csv downloaded with the SMTP credentials
-
-
Run the edited
render_helm.sh
./mozilla-hubs-ce-chart/render_helm.sh {domain} {mail_address}
-
Check the contents of the generated . Check the contents of the
/config.yaml
file. -
Update
configs > data
in the{env_name}-values-event.yaml
file- In the
{env_name}-values-event.yaml
file, near line 118 replace the part below where it says# Get the following from render_helm.sh
Deploying Community Edition on AWS with Alex Griggs' Helm Chart
17 minutes:around 35 seconds - In the
-
Update
defaultCert > data
in the{env_name}-values-event.yaml
file -
Copy
tls.crt
,tls.key
in the/config.yaml
file. -
Replace
tls.crt
,tls.key
indefaultCert > data
near line 165 in file{env_name}-values-event.yaml
-
Also, change enabled under defaultCert from
false
totrue
-
In the file
{env_name}-values-event.yaml
, replace the following value near line 6global: domain: &HUBS_DOMAIN "{YOUR_HUBS_DOMAIN}" adminEmail: &ADMINEMAIL "{ADMIN_EMAIL_ADDRESS}"
-
Change certificate settings
-
Open
mozilla-hubs-ce-chart/charts/haproxy/templates/deployment.yaml
-
Change near line 39.
-
before
- --default-ssl-certificate={{ .Release.Namespace }}/cert-**hcce**
-
after
- --default-ssl-certificate={{ .Release.Namespace }}/cert-**{{ .Values.global.domain }}**
-
-
-
-
EFS mount settings
💡 If you do not use efs, you can run the application without following the steps below, leaving enabled: false. However, in that case, assets such as scenes and logos will be deleted when the node (EC2 instance) of the EKS cluster is deleted.-
Update the efs setting near line 17 in the file
{env_name}-values-event.yaml
enabled:
true
fileSystemId: Value output when executing
sh ./terraform.sh {env_name} output -raw efs_id
aws: efs: enabled: false isDynamicProvisioning: false fileSystemId: fs-000000000000
-
Changed to not use pgsql
-
Add the following to the last line in the file
{env_name}-values-event.yaml
# Add pgsql: enabled: false
-
-
-
helm install
helm install moz -f {env_name}-values-event.yaml ./mozilla-hubs-ce-chart --namespace=hcce
-
Check the external IP of the resource to be created in EKS
kubectl get --namespace hcce svc -w haproxy-lb
-
Update A record for the Hubs application in Route53
-
open the Route53 console
-
select "Host Zone" on the left side and select the domain you specified when deploying
-
update the values of the 4 A records created in "1. Configure DNS on Route53" as follows:
- select the target A record and click "Edit Record" displayed in the upper right corner
- update as follows and save
- record type: A
- alias: on
- traffic routing destination: alias to Application Load Balancer and Classic Load Balancer
- region: us-east-1
- load balancer: dualstack.{external IP of EKS}
Perform the above steps for all four A records ({domain}, assets.{domain}, cors.{domain}, stream.{domain})
-
-
Check the status of EKS Pod
💡 If some pods do not become Running after 10 minutes or more, there may be a problem. Please check the information of each pod and debug it by referring to the following.kubectl get pods -n hcce
-
Check logs for each pod
💡 `{pod_name}` can be found in the output of `kubectl get pods -n hcce`kubectl logs pod {pod_name} -n hcce
-
Check the information for each pod (e.g., if the pod is Pending, check this)
kubectl describe pod {pod_name} -n hcce
-
Confirm the following operations
- Access to the domain After accessing the domain, the sign-in screen appears. Can sign in by entering the administrator's e-mail address
- Can create a room
- Can listen to other users' voices in the room
- Certificate verification does not complete successfully and domain cannot be accessed
- → Temporarily turn off http → https redirects
In the file
/mozilla-hubs-ce-chart/charts/haproxy/values.yaml
change ssl-redirect from true to false at line 204ssl-redirect: "false" # true -> false
- → Temporarily turn off http → https redirects
In the file