- terraform 1.2.8+
- kubectl 1.22+
- gcloud cli
- Google Cloud Account access
- Enable Google APIs (gcloud services enable):
- artifactregistry.googleapis.com
- compute.googleapis.com
- container.googleapis.com
- servicenetworking.googleapis.com
- file.googleapis.com
- sqladmin.googleapis.com
Build the image from this repository Push to Artifact Registry and pass image_name and image_tag to Terraform variable, then:
terraform init
terraform plan
terraform apply
Initialize kubectl access with:
gcloud container clusters get-credentials gke-moodle-tf --region us-central1
After that, deploy kubernetes application using:
kubectl create namespace moodle
kubectl apply -k manifests/overlays/development
Reset admin password:
kubectl -n moodle get pods # select one of the pods "moodle-xxx" kubectl -n moodle exec -ti (pod_name) -c php-fpm -- \ php /var/www/html/admin/cli/reset_password.php \ --username=admin \ --password=(new_password) \ --ignore-password-policy
From terraform output
, open http://${loadbalancer_ip_address}, login with credentials admin:new_password
(Provisioning of Load Balancer can take up to 10 minutes)
You can modify contents of manifests/overlays/development/serverconfig to your requirements, if you like, however, default values are recommended.
- default.conf: nginx server block configuration.
- php.ini: default configuration for PHP.
- www.conf: default pool directives for PHP-FPM.
Please consider config.php file will be overwritten after terraform apply
. It is better to modify this file AFTER terraform apply
.
To apply changes, run kubectl apply -k manifests/overlays/development
again.
Run kubectl delete namespace moodle
then terraform destroy
.