This tutorial is adapted from Web Age course Google Cloud Platform Fundamentals.
1.1 The Cloud Resource Manager Hierarchy
Follow this guide (https://cloud.google.com/docs/enterprise/best-practices-for-enterprise-organizations) for best practices on establishing your organization’s cloud presence.
1.2 A Simplified Google Cloud Resource Hierarchy Diagram
Source: https://cloud.google.com/resource-manager/img/gsuite-organization-mapping.png
1.3 An Extended Google Cloud Resource Hierarchy Diagram
Source: https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy
1.4 Creating a Project Programmatically with gcloud
gcloud projects create PROJECT_ID
gcloud projects create PROJECT_ID --organization=ORG_ID
1.5 Creating a Project with Web API
POST https://cloudresourcemanager.googleapis.com/v1/projects/ Authorization: ************* Content-Type: application/json { "projectId": "your_project_id", "name": "your project name " }
Notes:
Here is part of functionally equivalent Python code for creating a project:
from googleapiclient import discovery
from oauth2client.client import OAuth2Credentials as creds
crm = discovery.build(
'cloudresourcemanager', 'v1', http=creds.authorize(httplib2.Http()))
operation = crm.projects().create(
body={
'project_id': 'your_project_id',
'name': 'your project name'
}).execute()
1.6 Resource Manager Features and Components
- Organization
- Represents an organization such as your company and is the root node in the GCP resource hierarchy
- Organization policies
- Programmatically restrict configurations across your entire cloud resource hierarchy
- Cloud IAM policies
- Create and manage IAM access control policies for your organization and projects dealing with VM management, logs, etc.
- Asset inventory
- A fully-managed metadata inventory service that helps to monitor all your GCP and Anthos resources and policies. Supports resource metadata analysis, audit, and compliance tasks
- Create, update, delete projects
- Create, update, and delete projects that belong to your organization. You can also undelete projects in the “pending deletion” state; you can also obtain a list of all projects in the organization
- Cloud folders
- Cloud folders help organize your resources and configure IAM policies that will apply to all child resources under those folders
- Cloud console and API access
- Resource Manager can be accessed through the GCP Console in the Admin section, via Resource Manager API, or using the gcloud command-line tool
Google Workspace and Cloud Identity customers have access to additional features of the resource hierarchy with an added benefits such as centralized visibility and control, and further grouping mechanisms, such as folders.
1.7 Quotas and Capacity Planning
Google Cloud projects are assigned quotas that apply hard limits on the consumption of a particular resource or API and help protect cloud customers from overspending their cloud budgets because of insufficiently reserved capacity. Make sure you provide sufficient capacity by setting your own resource limits for your projects in advance to avoid unexpected resource throttling. If the allocated project quotas are insufficient, use the Quotas section of the Cloud Console. If you require a capacity beyond the maximum allowed quotas, contact your Google Cloud sales team.
1.8 Understanding Quotas
- Rate quotas, such as the number of API requests per day. This quota gets reset after a service-specific time interval
- Allocation quotas, such as the number of VM instances, the size of a GKE cluster, or load balancers used by your project. These quotas do not get reset over time
1.9 Getting Quotas Using gcloud ( Alpha)
gcloud alpha services quota list \ --service=YOUR_SERVICE_NAME.googleapis.com \ --consumer=projects/YOUR_PROJECT_ID
--consumer=organizations/YOUR_ORG_ID
1.10 Understanding Resource Labels
1.11 Common Uses of Labels
Google recommends the following uses cases for labels:
- Environment or stage labels
- E.g., env:prod
- Team or cost center labels
- E.g. group:analytics. This type of labeling can help with cost accounting or budgeting
- System component labels
- E.g. web_component:frontend
- State labels
- E.g. state:active
- VM labels:
- A label can be attached to a virtual machine. Virtual machine tags that you defined in the past will appear as a label without a value
1.12 Creating a Label with the Resource Manager API
POST https://cloudresourcemanager.googleapis.com/v1beta1/projects { "labels": { "team": "dream" }, "name": "our_project_name", "projectId": "our_project_id" }
1.13 Budget Alerts
1.14 Budget Alerts Diagram
Source: https://cloud.google.com/billing/docs/how-to/budgets
1.15 Creating a Budget
1.16 The Budget API
https://billingbudgets.googleapis.com
1.17 Setting Up Alert Threshold Rules in the Cloud Console
Source: https://cloud.google.com/blog/products/management-tools/monitor-cloud-costs-and-create-budgets-at-scale
1.18 Summary
- Cloud Resource Manager Hierarchy
- Understanding quotas
- Budget alerts