GCP Multi-Network

It’s likely that your platform is comprised of multiple environments. You can map these environment in your namespaces.

In this example, I’ve two application environments setup in GCP - “prod” and “dev”. Both environments have been built from the same Terraform template - they are identical.

Note

For further configuration details, please refer to the documentation.

Tree Hierarchy

The tree hierarchy below is generated by invoking Bcome’s tree command:

▐▆   Namespace tree wbz
│
├───╸ collection dev
│         ├───╸ inventory all
│         │         ├───╸ server bastion
│         │         ├───╸ server puppet
│         │         └───╸ server wbzsite_app_rvf8
│         │
│         ├───╸ inventory-subselect wbzsite
│         │         └───╸ server app_rvf8
│         │
│         └───╸ inventory-subselect xops
│                   ├───╸ server bastion
│                   └───╸ server puppet
│
│
└───╸ collection prod
          ├───╸ inventory all
          │         ├───╸ server bastion
          │         ├───╸ server puppet
          │         └───╸ server wbzsite_app_sq6v
          │
          ├───╸ inventory-subselect wbzsite
          │         └───╸ server app_sq6v
          │
          └───╸ inventory-subselect xops
                    ├───╸ server bastion
                    └───╸ server puppet

Network Configuration

Below is an example multi-network GCP configuration: two networks, corresponding to development & production application environments, are configured.

---
wbz:
  type: collection
  description: Entire WBZ estate
  ssh_settings: {}

  network:
    type: gcp
    project: wbznet
    authentication_scheme: oauth
    secrets_filename: wbz-net-oauth-secrets.json
    service_scopes:
    - https://www.googleapis.com/auth/compute.readonly
    - https://www.googleapis.com/auth/cloud-platform

wbz:prod:
  type: collection
  description: GCP Production
  ssh_settings:
    proxy:
      - host_lookup: by_bcome_namespace
        namespace: prod:xops:bastion
  network:
    filters: status:running AND labels.environment=prod-net
    zone: europe-west1-b

wbz:prod:all:
  hidden: false
  type: inventory
  description: All Production environment
  override_identifier: "prod_net_(.+)"

wbz:prod:xops:
  type: inventory-subselect
  subselect_from: prod:all
  description: Operations namespace
  filters:
    by_label:
      group: operations

wbz:prod:wbzsite:
  type: inventory-subselect
  subselect_from: prod:all
  description: Frontend wbzsite
  override_identifier: "wbzsite_(.+)"
  filters:
    by_label:
      group: application
      function: frontend-wbzsite

wbz:dev:
  type: collection
  description: GCP Development
  ssh_settings:
    proxy:
      - host_lookup: by_bcome_namespace
        namespace: dev:xops:bastion
  network:
    filters: status:running AND labels.environment=dev-net
    zone: europe-west1-c

wbz:dev:all:
  hidden: false
  type: inventory
  description: All Development enviornment
  override_identifier: "dev_net_(.+)"

wbz:dev:xops:
  type: inventory-subselect
  subselect_from: dev:all
  description: Operations namespace
  filters:
    by_label:
      group: operations

wbz:dev:wbzsite:
  type: inventory-subselect
  subselect_from: dev:all
  description: Frontend wbzsite
  override_identifier: "wbzsite_(.+)"
  filters:
    by_label:
      group: application
      function: frontend-wbzsite

Ascii Cast

The following Asciicast presents a quick run-through of navigating the namespace configuration.

Note

To replay this Asciicast in your own terminal, install the asciinema package from https://asciinema.org/, and then enter the following in your terminal:

asciinema play https://asciinema.org/a/gFl72t4mFX42djQDdJIxVQtp5