Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
saliceti committed Apr 3, 2024
1 parent 9652d16 commit ac06fcf
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 25 deletions.
File renamed without changes.
17 changes: 17 additions & 0 deletions service_unavailable_page/manifests/ingress_external_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: review-colin.apply-for-teacher-training.service.gov.uk
namespace: bat-qa
spec:
ingressClassName: nginx
rules:
- host: review-colin.apply-for-teacher-training.service.gov.uk
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: apply-review-9252
port:
number: 80
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: review-colin.apply-for-teacher-training.service.gov.uk-maintenance
name: review-colin.apply-for-teacher-training.service.gov.uk
namespace: bat-qa
spec:
ingressClassName: nginx
Expand Down
17 changes: 17 additions & 0 deletions service_unavailable_page/manifests/ingress_internal_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apply-review-9252.test.teacherservices.cloud
namespace: bat-qa
spec:
ingressClassName: nginx
rules:
- host: apply-review-9252.test.teacherservices.cloud
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: apply-review-9252
port:
number: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apply-review-9252.test.teacherservices.cloud
namespace: bat-qa
spec:
ingressClassName: nginx
rules:
- host: apply-review-9252.test.teacherservices.cloud
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: apply-teacher-training-maintenance
port:
number: 80
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apply-teacher-training-maintenance
name: apply-teacher-training-maintenance.test.teacherservices.cloud
namespace: bat-qa
spec:
ingressClassName: nginx
Expand Down
17 changes: 17 additions & 0 deletions service_unavailable_page/manifests/ingress_temp_to_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apply-teacher-training-temp.test.teacherservices.cloud
namespace: bat-qa
spec:
ingressClassName: nginx
rules:
- host: apply-teacher-training-temp.test.teacherservices.cloud
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: apply-review-9252
port:
number: 80
19 changes: 16 additions & 3 deletions service_unavailable_page/scripts/failback.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
echo Recreate external ingress using terraform
set -eu

echo Delete external ingress pointing at the maintenance app
kubectl delete -f service_unavailable_page/manifests/ingress_external.yml
echo Reconfigure ingresses using terraform
kubectl apply -f service_unavailable_page/manifests/ingress_external_main.yml
kubectl apply -f service_unavailable_page/manifests/ingress_internal_main.yml

echo Delete temp ingress
kubectl delete -f service_unavailable_page/manifests/ingress_temp_to_main.yml

echo Delete maintenance ingress
kubectl delete -f service_unavailable_page/manifests/ingress_maintenance.yml

echo Delete maintenance service
kubectl delete -f service_unavailable_page/manifests/service_maintenance.yml

echo Delete maintenance app
kubectl delete -f service_unavailable_page/manifests/deployment_maintenance.yml
30 changes: 26 additions & 4 deletions service_unavailable_page/scripts/failover.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
echo Delete external ingress
kubectl -n bat-qa delete ingress review-colin.apply-for-teacher-training.service.gov.uk
set -eu

echo Create new external ingress pointing at the maintenance app
kubectl apply -f service_unavailable_page/manifests/ingress_external.yml
### Deploy maintenance app ###
echo Create maintenance deployment
kubectl apply -f service_unavailable_page/manifests/deployment_maintenance.yml
kubectl create deployment apply-teacher-training-maintenance \
--image ghcr.io/dfe-digital/apply-teacher-training-maintenance:ee1bba7d04e845d44fe2fe4ab77fc2acab485aa6 \
--port 80 \
--replicas 2 \



echo Create maintenance service
kubectl apply -f service_unavailable_page/manifests/service_maintenance.yml

echo Create maintenance ingress
kubectl apply -f service_unavailable_page/manifests/ingress_maintenance.yml

### Change ingress ###
echo Configure external ingress to point at the maintenance app
kubectl apply -f service_unavailable_page/manifests/ingress_external_maintenance.yml

echo Configure internal ingress to point at the maintenance app
kubectl apply -f service_unavailable_page/manifests/ingress_internal_maintenance.yml

echo Create temp ingress
kubectl apply -f service_unavailable_page/manifests/ingress_temp_to_main.yml
27 changes: 13 additions & 14 deletions terraform/aks/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions terraform/aks/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module "web_application" {
command = local.webapp_startup_command
probe_path = "/check"
web_external_hostnames = var.gov_uk_host_names
# maintenance_app_name = local.maintenance_app_name
# maintenance_app_port = local.maintenance_app_port
maintenance_service_name = var.enable_maintenance ? "apply-teacher-training-maintenance" : null
}

module "main_worker" {
Expand Down
8 changes: 8 additions & 0 deletions terraform/aks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ variable "alert_window_size" {
description = "The period of time that is used to monitor alert activity e.g PT1M, PT5M, PT15M, PT30M, PT1H, PT6H or PT12H"
}

variable "enable_maintenance" {
type = bool
default = false
}

locals {
app_name_suffix = var.app_name_suffix != null ? var.app_name_suffix : var.app_environment

Expand All @@ -93,4 +98,7 @@ locals {
webapp_startup_command = var.webapp_startup_command == null ? null : ["/bin/sh", "-c", var.webapp_startup_command]
postgres_service_name = "apply-postgres-${var.app_environment}"
database_url = "postgres://${module.postgres.username}:${module.postgres.password}@${module.postgres.host}:${module.postgres.port}/${local.postgres_service_name}"

maintenance_app_name = var.enable_maintenance ? "apply-teacher-training-maintenance" : null
maintenance_app_port = var.enable_maintenance ? 80 : null
}
3 changes: 2 additions & 1 deletion terraform/aks/workspace_variables/review_aks.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"webapp_startup_command": "bundle exec rails db:prepare && bundle exec rails server -b 0.0.0.0",
"gov_uk_host_names": [
"review-colin.apply-for-teacher-training.service.gov.uk"
]
],
"enable_maintenance": false
}
2 changes: 1 addition & 1 deletion terraform/aks/workspace_variables/review_aks_Terrafile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aks:
source: "https://github.com/DFE-Digital/terraform-modules"
version: "main"
version: "1684-spike-maintenance-page-ingress"

0 comments on commit ac06fcf

Please sign in to comment.