Skip to content

Commit

Permalink
Add default maintenance window (#67)
Browse files Browse the repository at this point in the history
* Adding default maintenance_window.

* Adding workaround in case of Terraform apply failure.

* Updating default kube version.

* Returning exit code 1 for failure.

* Adding Terraform fail scenario.

* Updating command.
  • Loading branch information
mishah334 authored Sep 20, 2022
1 parent 182ec7e commit c9a3331
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ jobs:
steps:
- checkout
- run: EXAMPLE=from_scratch pipeline/run_terraform.sh
- run:
command: DESTROY=1 EXAMPLE=from_scratch pipeline/run_terraform.sh
when: on_fail
- slack/notify:
event: fail
template: basic_fail_1
Expand Down
6 changes: 2 additions & 4 deletions pipeline/run_terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ TERRAFORM="${TERRAFORM:-terraform}"

"${TERRAFORM}" -v

echo "$GCP_TOKEN" > /tmp/account.json
echo "$GCP_TOKEN" >/tmp/account.json

set -xe

if [ ! -f /tmp/account.json ]; then
echo "google credential json does not exists"
fi


export GOOGLE_APPLICATION_CREDENTIALS='/tmp/account.json'


# unique deployment ID to avoid collisions in CI
# needs to be 32 characters or less and start with letter
DEPLOYMENT_ID=ci$(echo "${CIRCLE_PROJECT_REPONAME}${CIRCLE_SHA1}" | md5sum | awk '{print substr($1,0,5)}')
Expand All @@ -37,7 +35,7 @@ sed -i "s/REPLACE/$DEPLOYMENT_ID/g" backend.tf
"${TERRAFORM}" init

if [[ "$DESTROY" -eq 1 ]]; then
"${TERRAFORM}" destroy --auto-approve -var "deployment_id=$DEPLOYMENT_ID" -var "zonal=$ZONAL" -lock=false -refresh=false
"${TERRAFORM}" destroy --auto-approve -var "deployment_id=$DEPLOYMENT_ID" -var "zonal=$ZONAL" -lock=false -refresh=false
else
# this helps to fail fast in the pipeline, but it's not necessary
"${TERRAFORM}" apply --auto-approve -var "deployment_id=$DEPLOYMENT_ID" -var "zonal=$ZONAL" -lock=false --target=module.astronomer_gcp.google_service_networking_connection.private_vpc_connection
Expand Down
10 changes: 7 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ variable "dns_managed_zone" {
}

variable "kube_version_gke" {
default = "1.21.12-gke.2200"
default = "1.21.14-gke.3000"
description = "The kubernetes version to use in GKE"
}

variable "gke_release_channel" {
default = "STABLE"
default = "UNSPECIFIED"
type = string
description = "The GKE Release channel to use. Blank for none"
}
Expand Down Expand Up @@ -484,7 +484,11 @@ variable "daily_maintenance_window" {
type = list(object({
start_time = string
}))
default = []
default = [
{
start_time = "13:00"
}
]
}

variable "maintenance_exclusion" {
Expand Down

0 comments on commit c9a3331

Please sign in to comment.