Small world. Big idea!
Consistent naming strategy is important and should be an essential part my working. It is often overlooked at the beginning of a small project. But it quickly becomes critical as the number of managed resources grows.
Consistent and descriptive naming of resources has many benefits:
Good naming convention must provide clarity and work in both directions:
To go into detail about each resource, I need to briefly introduce the concept of organization in GCP.
Let’s begin by defining some terms that will help us understand the discussion about host projects. Some of these terms are related to Google Cloud’s Organizational Hierarchy, which consists of four tiers: organization, folders, projects, and resources, as shown in the diagram below.
Example Google Organizational Hierarchy
In addition to the organization hierarchy, there are three important terms for understanding host projects, as further described in the Google documentation on VPC terminology and concepts.
Below is a high-level diagram that shows the relationship between host projects, service projects, and stand-alone projects.
Same host, service and stand-alone project
In our example diagram, Project Alpha is a host project, sharing all network resources within that project. Project Beta is a service project that subscribes to the host project’s network services. Project Omega does not subscribe to Alpha’s network services, and is thus a stand-alone project.
Now let’s get into greater detail about the naming convention in GCP resources.
Syntax: {organization}-(type of project)-{environment}-{service description}
Value: {organization}-{h/s+p/sa}-{prod/stag/all}-{service description}
Example:
Syntax: {h/s+p/sa}-{prod/stag/all}-{service description}-{yyyy-mm-dd}
With hp is host project, sp is service project, sa is standard-alone project
Example: sp-prod-alpha-2024-01-11
Syntax: {vpc description}-vpc
Example: shared-vpc
Syntax: {type of project}-{environment}-{subnet description}-{zone}-{type of subnet}-subnet
Value: {h/s+p}-{prod/stag}-{subnet description}-{zone}-{pod/service} -subnet
Example: sp-prod-alpha-as-se1-pod-subnet
Syntax: {organization}-{source environment}-{source project description}-{source device}-{organization}-{destination environment}-{destination project description}-{destination device}-{protocol}-{port}-{action}
Value: {organization}-{prod/stag}-{project description}-{source-device}-{organization}-{prod/stag}-{project description}-{des device}-{protocol}-{port}-{action}
Example: swap-stag-alpha-nginx-beta-cicd-tcp-80-accept
Syntax: { name application}.{ name resource}.domain.{env}
Example:
Syntax: {team name}-{resources accessed}-{what your app does}
Example: [email protected]
Syntax: LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY-GITHUB-IMAGE:VERSION
Example: us-east1-docker.pkg.dev/my-project/my-repo:1.0.0
You should also cover the use of labels (or tags)
country: vn
ou: vn # The organization unit
environment: dev # uat/prod
service: gke # Describe the google services
app_name: podinfo # like a pod service running on gke
app_type: gke # such as mongodb,kafka,rabbitmq, etc
team: product