Reliability measures how long a system performs correctly within a stated period. In infrastructure changes, it limits disruption by keeping a working backup environment ready to receive production traffic. section 9.1.2
Implement reliability during infrastructure changes by:
- Create an active environment and an idle passive environment in separate regions. section 9.1.2
- Keep resource names, regions, network ranges, and labels distinct in the passive configuration. section 9.1.2
- Reduce the active load-balancer weight to zero and set the passive weight to 100 during failover. section 9.1.2
Listing 9.2 Failover to passive sundew environment in us-west1
import blue #1
import passive #1
services_list = [
{
'version': 'blue', #2
'zone': blue.zone,
'name': f'{shared_name}-blue',
'weight': 0 #3
}, {
'version': 'passive', #2
'zone': passive.zone,
'name': f'{shared_name}-passive',
'weight': 100 #4
}
]
def _generate_backend_services(services): #5
backend_services_list = []
for service in services:
version = service['version']
weight = service['weight']
backend_services_list.append({
'backend_service': ( #6
'${google_compute_backend_service.' #6
f'{version}.id}}' #6
), #6
'weight': weight, #6
})
return backend_services_list
def load_balancer(name, default_version, services):
return [{
'google_compute_url_map': { #7
TEAM: [{
'name': name,
'path_matcher': [{
'name': 'allpaths',
'path_rule': [{ #8
'paths': [ #8
'/*' #8
], #8
'route_action': { #9
'weighted_backend_services': #9
_generate_backend_services( #9
services) #9
} #9
}]
}]
}]
}
}]
Shows the traffic-control configuration that switches requests from the failed active environment to the passive region. section 9.1.2












