-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix_column_families
- Loading branch information
Showing
20 changed files
with
374 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
blueprints/cloud-operations/network-dashboard/src/plugins/series-psa.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
'Prepares descriptors and timeseries for subnetwork-level metrics.' | ||
|
||
import collections | ||
import ipaddress | ||
import itertools | ||
import logging | ||
|
||
from . import MetricDescriptor, TimeSeries, register_timeseries | ||
|
||
DESCRIPTOR_ATTRS = { | ||
'addresses_available': 'Address limit per psa range', | ||
'addresses_used': 'Addresses used per psa range', | ||
'addresses_used_ratio': 'Addresses used ratio per psa range' | ||
} | ||
LOGGER = logging.getLogger('net-dash.timeseries.psa') | ||
|
||
|
||
def _sql_addresses(sql_instances): | ||
'Returns counts of Cloud SQL instances per PSA range.' | ||
for v in sql_instances.values(): | ||
if not v['ipAddresses']: | ||
continue | ||
# 1 IP for the instance + 1 IP for the ILB + 1 IP if HA | ||
yield v['ipAddresses'][0], 2 if v['availabilityType'] != 'REGIONAL' else 3 | ||
|
||
|
||
@register_timeseries | ||
def timeseries(resources): | ||
'Returns used/available/ratio timeseries for addresses by PSA ranges.' | ||
LOGGER.info('timeseries') | ||
for dtype, name in DESCRIPTOR_ATTRS.items(): | ||
yield MetricDescriptor(f'network/psa/{dtype}', name, | ||
('project', 'network', 'subnetwork'), | ||
dtype.endswith('ratio')) | ||
psa_nets = { | ||
k: ipaddress.ip_network('{}/{}'.format(v['address'], v['prefixLength'])) | ||
for k, v in resources['global_addresses'].items() if v['prefixLength'] | ||
} | ||
psa_counts = {} | ||
for address, ip_count in _sql_addresses(resources.get('sql_instances', {})): | ||
ip_address = ipaddress.ip_address(address) | ||
for k, v in psa_nets.items(): | ||
if ip_address in v: | ||
psa_counts[k] = psa_counts.get(k, 0) + ip_count | ||
break | ||
|
||
for k, v in psa_counts.items(): | ||
max_ips = psa_nets[k].num_addresses - 4 | ||
psa_range = resources['global_addresses'][k] | ||
labels = { | ||
'network': psa_range['network'], | ||
'project': psa_range['project_id'], | ||
'psa_range': psa_range['name'] | ||
} | ||
yield TimeSeries('network/psa/addresses_available', max_ips, labels) | ||
yield TimeSeries('network/psa/addresses_used', v, labels) | ||
yield TimeSeries('network/psa/addresses_used_ratio', | ||
0 if v == 0 else v / max_ips, labels) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
## 00-bootstrap | ||
1. How to handle requests where automation, logging and/or billing export projects are not under organization but in different folders. | ||
- Run bootstrap stage and let automation, logging and/or billing projects be created under organization. | ||
- Run resource manager stage or any other custom stage which creates the folders where these projects will reside. | ||
- Once folders are created add folder ids to varibale "project_parent_ids" in bootstrap stage and run bootstrap stage. | ||
- This step will move the projects from organization to the parent folders specificed. | ||
|
||
## cicd | ||
1. Why do we need two seperate ServiceAccounts when configuring cicd pipelines (cicd SA and IaC SA) | ||
- Having seperate service accounts helps shutdown the pipeline incase of any issues and still keep IaC SA and ability to run terraform plan/apply manually. | ||
- A pipeline can only generate a token that can get access to an SA. It cannot directly call a provider file to impersonate IaC SA. | ||
- Having providers file that allows impersonation to IaC SA allows flexibility to run terraform manually or from CICD Pipelines. | ||
<p align="center"> | ||
<img src="IaC_SA.png" alt="CICD SA and IaC SA"> | ||
</p> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.