Cloud Naming Convention

Cloud Naming Convention

Thu, Oct 10, 2019
cloud
/
gcp
/
structure
/
terraform

Constant naming approach is crucial and could presumably furthermore be an very crucial piece of any
cloud effort. Sadly it’s in general lost sight of. It could per chance seem fancy a luxury whereas you
flee about a “pet” servers, but it fleet turns into crucial because the series of
managed resources grows. It’s the first step in achieving even general ranges
of consistency and prerequisite to setting up any fashion of cloud governance.

After reading this article, you’ll hopefully know how to gather from:

1
2
3
4
5
6
$ gcloud container clusters checklist 
    --layout 'value(title)'
k8s-cluster
k8s-cluster
k8s-cluster
k8s-cluster

to something fancy:

1
2
3
4
5
6
$ gcloud container clusters checklist 
    --layout 'value(title)'
ste-blog-p-kcl-euwe4-major
ste-webshop-d-kcl-euwe4-major
ste-webshop-p-kcl-euwe4-major
ste-webshop-p-kcl-usce1-major

The latter will fleet explain us what fashion of resources are we dealing with, to
which venture and atmosphere they belong, where are they positioned and whether
they’re functionally connected to every different.

Benefits

Constant and descriptive naming of resources has many advantages:

  • Signifies the function and possession of a handy resource.
  • Helps formalize expectations and promote consistency within an infrastructure.
  • Prevents title clashes when handy resource names needs to be irregular.
  • Makes resources more easy to stumble on.
  • Reduces effort to worship code and permits developers to heart of attention on more crucial aspects than arguing over naming requirements.
  • Permits to style and filter resources fleet.
  • Is a prerequisite for setting up any successful cloud governance and
    automatic coverage overview or enforcement.



I’m no longer slightly obvious after I first came upon this quote, but it
since became one of my favourites. Martin Fowler attributes it to Phil
Karlton
.

There are most productive two interesting things in
Computer Science: cache invalidation and naming things.

Indispensable Properties

Perfect naming conference need to provide clarity and work in every directions:

  • Clearly sing how newly created resources could presumably furthermore nonetheless be named.
  • Establish and existing the reason and possession of present resources.

We’ll heart of attention on how a naming conference for cloud-level resources could presumably furthermore nonetheless understand
fancy. GCP is historical in our examples, however the ideas and methods are generic
and is more likely to be easily tailored to different cloud suppliers.

Naming Restrictions

When designing your naming conference, you have to presumably furthermore nonetheless bear in mind barriers
imposed by the cloud provider. Each handy resource comes with a local of naming
restrictions. The guideline of thumb is to relieve it immediate and straightforward (employ most productive letters
and numbers for individual formula, relieve - as separator).

GCP limits title size for rather a lot of of the resources to 62 or 63 characters,
Mission IDs are restricted to 30. Sources must have irregular names, both
globally or within a given scope. Some resources have additional constraints
to place in mind (e.g. GCP Projects can’t be straight away deleted).

Global Naming Sample

First we build naming sample that all straight away managed resources could presumably furthermore nonetheless
apply – Global Naming Sample.

[prefix]-[project]-[env]-[resource]-[location]-[description]-[suffix]

Ingredient Description Req. Constraints
prefix Mounted prefix len 3, mounted
venture Mission title len 4-10, a-z0-9
env . Ambiance len 1, a-z, enum
handy resource Resource style len 3, a-z, enum
region Resource region len 1-6, a-z0-9
description Extra description len 1-20, a-z0-9
suffix Random suffix len 4, a-z0-9

Let’s lunge over the individual formula more intimately.

Mounted Prefix

Here’s a mounted value prefix historical for all resources. In general some fashion of abbreviation for your organization title.

Mission Establish

Here isn’t the same as a GCP Mission. In general one Mission
can have more than one GCP Projects.

We’re the usage of flat hierarchy and Mission serves because the major mechanism of organizing
resources into groups. I fancy the usage of flat hierarchy as it’s quite celebrated and
flexible to match rather famous any organizational structure. That you can place in mind
replacing this with some different fashion of crew (e.g. team, product), but in my
skills it never slightly works in the stop.

Ambiance

Sources belong to deployment environments. It’s handy to construct a
usual space of names historical all one of the best likely method thru your organization.

Resource Form

I’ve tried assorted mechanisms over the time to originate the
abbreviation for resources – most fixed outcomes are carried out if the names are
in step with the API handy resource names.

Abbreviation of the given handy resource style. In GCP I are inclined to employ three letters.

For better and more continually historical APIs (e.g. Compute, Kubernetes) first letter
stands for the API and the rest two for the handy resource style. For APIs with fewer
resources, it’s the slightly rather a lot of manner spherical. I do know here is no longer a in reality deterministic
rule, but this would presumably furthermore repeatedly be a compromise to it immediate and usable.

Resource Field

Field is required when there’s a possibility to create a given handy resource in
different locations.

  • Regional – 5 letter acronym (two letters for the continent, two for
    cardinal directions, 1 digit)
  • Zonal – six letters – Regional + zone
  • Globalg
  • Multi- and Dual-regional – apply GCP’s private naming (two letters for
    multi and 4 letters for twin-regional)

Extra Description

A high level plan historical to distinguish between resources of the the same style but
different roles. As an example a crew of servers with an even reason –
frontend and backend. This will furthermore nonetheless no longer be historical to distinguish
between more than one cases of the the same reason handy resource, employ suffix
instead.

It’s furthermore handy to agree on generic keywords historical for description, when there
is no better, more specific, term available. This avoids many assorted names
fancy major, core, usual, this and the same. On the entire splendid approach is to employ
the Latin ordinal sequence, i.e. major, secondary, tertiary, and so forth.

Random Suffix

I on the entire employ a 2-byte number represented in hexadecimal form

  • splendid for readability and simply generated with Terraform random_id
    handy resource.
    Speak Suffix to distinguish handy resource from its peers when there are more than one cases, or
    when there’s a requirement for uniqueness.

Examples

Let’s lunge over several fat examples of how resources could presumably furthermore nonetheless be named basically based totally
on the above established sample.

The total examples employ prefix ste and belong to Production (p) atmosphere of
venture blog.

  • Role of functionally connected Compute Instances
    • ste-blog-p-cin-euwe1a-nginx-408f
    • ste-blog-p-cin-euwe1a-nginx-c338
    • ste-blog-p-cin-euwe1a-nginx-d7aa
  • VPC (Network) and Subnet
    • ste-blog-p-cne-major
    • ste-blog-p-csn-euwe1-major
  • GKE Regional Cluster and Node Pool
    • ste-blog-p-kcl-usce1-major
    • ste-blog-p-knp-usce1-major-cbe7

GCP Projects

Projects (and Folders) are regarded as handy resource containers for the reason of
this naming conference and due to the this reality lunge away out the handy resource piece of the title.

You need to per chance be in a place to safe GCP does this by default for
initiatives created through console – e.g. like a flash-depot-253717.

Mission IDs in GCP want to be globally irregular and could presumably no longer be deleted straight away.
Here is miserable for automation, as you have to presumably’t create a venture with the the same
title splendid after it has been deleted. And that’s why we encompass the irregular random
suffix piece.

Folders: We don’t employ GCP folders to rearrange initiatives. I
on the entire focus on that retaining it easy and flat turns out to be handy more in general than
no longer. Nonetheless, whenever you fancy to need to additional structure your resources, place in mind including
an additional ingredient to your naming sample, comparable to [org_group]. Folders
can then apply [prefix]-[org-group] sample.

GCP furthermore permits configuring Mission Establish. I counsel to space this to the the same value
as Mission ID and ignore it. To your entire luminous capabilities you’ll
reference the Projects by their IDs.

GCP Projects will due to the this reality be named following the
[prefix]-[project]-[env]-[suffix] sample.

xkcd – Permanence by Randall Munroe

Exceptions

There will repeatedly be exceptions where it’s no longer likely to apply the
Global Naming Sample (as an illustration handy resource does no longer permit - in the
title) or when it merely doesn’t form sense. A subset of the
fat sample could presumably furthermore nonetheless be historical if likely and all exceptions documented.

Service Accounts

Service accounts apply the [resource]-[description] sample most productive, because the
venture is already incorporated in the piece after @ and due to the this reality there’s no need
to repeat that bit,

IAM and Groups

Here’s a fancy topic, presumably for one other article, but you have to presumably furthermore nonetheless build a
naming conference for groups and a approach on how to construct permissions. As a
rule of thumb, never build permissions on to participants, but to groups
most productive.

Labelling Sources

That you can furthermore nonetheless furthermore quilt the usage of labels (or tags). An very best likely one is so that you just have to add
info to additional categorize your resources, comparable to value-heart. Labels
are furthermore handy in conditions whereas you have to presumably’t arrange handy resource names straight away,
but you have to presumably arrange a local of labels that is propagated to the child resources (e.g.
GKE Cluster labels or Occasion Groups).

Plot no longer duplicate info already contained for your naming conference (such
as venture) or create mountainous numbers of irregular labels with info that can
be got from the objects themselves (comparable to creationTimestamp).

DNS

DNS naming conference all one of the best likely method thru your infrastructure is yet again the next topic, but you
could presumably furthermore nonetheless positively have one. A straightforward approach could presumably be growing a subdomain for every
GCP venture in the [project]-[env]. form. DNS records
created for given resources could presumably furthermore nonetheless then apply the
[resource]-[resource_location]-[description]-[suffix] piece of the Global
Naming sample and due to the this reality safe the handy resource title.

This permits for straightforward subdomain delegation to individual GCP initiatives.

Summary

That you can furthermore nonetheless build a fixed naming conference as one of many first things
whereas you begin the usage of cloud or on a recent venture. It’s one of those things
that are in point of fact easy to assemble in the initiating, but method more worthy to fix
in a while. And you’ll abet from it day by day.

The major to success with naming conventions is setting up them early on and
ruthlessly following all one of the best likely method thru your entire infrastructure. Automation helps loads.

As traditional, there’s no silver bullet and the categorical naming conference
could presumably furthermore nonetheless repeatedly be tailored to your atmosphere. The first point is having one! And
I am hoping this put up gives you a head begin.

Thanks for making it your entire manner till here. I wouldn’t blame you whenever you focus on
by now that I if truth be told have a serious OCD (and I doubtlessly assemble), but are attempting to work in an
atmosphere with 120 Kubernetes clusters and each single one of them named
merely factual cluster!

Perfect success for your cloud poke and I would purchase to listen to about your skills
with naming things. You need to per chance be in a place to apply me on
@stepanstipl.

References

  1. GCP – Increasing and Managing Projects: https://cloud.google.com/handy resource-manager/clinical doctors/growing-managing-initiatives#identifying_projects
  2. GCP – Most efficient practices for venture organizations: https://cloud.google.com/clinical doctors/venture/easiest-practices-for-venture-organizations
  3. GCE API – REST reference: https://cloud.google.com/compute/clinical doctors/reference/relaxation/v1/
  4. GKE API – REST reference: https://cloud.google.com/kubernetes-engine/clinical doctors/reference/relaxation/
  5. GKE – Increasing and managing labels:
    https://cloud.google.com/kubernetes-engine/clinical doctors/how-to/growing-managing-labels
  6. Azure – Recommended naming and tagging conventions:
    https://clinical doctors.microsoft.com/en-us/azure/cloud-adoption-framework/ready/concerns/naming-and-tagging
  7. AWS – Tagging Strategies:
    https://aws.amazon.com/answers/legend-administration/aws-tagging-methods/

Read Extra

Leave a Reply

Your email address will not be published. Required fields are marked *