PolarSPARC

Elastic Cloud Infrastructure: Scaling and Automation - Summary Notes - Part 3


Bhaskar S 11/09/2019


Deployment Manager

Managed Services

BigQuery

Cloud Dataflow

Cloud Dataprep

Cloud Dataproc

Hands-on with Deployment Manager

Display a list of the available network resource types

gcloud deployment-manager types list | grep network

The following will be the typical output:

Output.1

compute.beta.subnetwork
compute.alpha.subnetwork
compute.v1.subnetwork
compute.beta.network
compute.v1.network
compute.alpha.network

Display a list of the available firewall resource types

gcloud deployment-manager types list | grep firewall

The following will be the typical output:

Output.2

compute.v1.firewall
compute.alpha.firewall
compute.beta.firewall

Display a list of the available instance resource types

gcloud deployment-manager types list | grep instance

The following will be the typical output:

Output.3

spanner.v1.instance
compute.v1.instanceGroupManager
sqladmin.v1beta4.instance
compute.alpha.instanceGroup
bigtableadmin.v2.instance
compute.v1.instanceGroup
compute.beta.instanceGroupManager
compute.alpha.instanceTemplate
compute.v1.instanceTemplate
compute.beta.instance
bigtableadmin.v2.instance.table
compute.beta.instanceTemplate
compute.alpha.instanceGroupManager
compute.beta.instanceGroup
compute.v1.instance
compute.alpha.instance

The following is an example instance creation template called instance-template.jinja using Jinja:

instance-template.jinja
resources:
- name: {{ env["name"] }}
  type: compute.v1.instance  
  properties:
     machineType: zones/{{ properties["zone"] }}/machineTypes/{{ properties["machineType"] }}
     zone: {{ properties["zone"] }}
     networkInterfaces:
      - network: {{ properties["network"] }}
        subnetwork: {{ properties["subnetwork"] }}
        accessConfigs:
        - name: External NAT
          type: ONE_TO_ONE_NAT
     disks:
      - deviceName: {{ env["name"] }}
        type: PERSISTENT
        boot: true
        autoDelete: true
        initializeParams:
          sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9

The following is an example Deployment Manager template called config.yaml in YAML format:

config.yaml
imports:
- path: instance-template.jinja

resources:
# Create the auto-mode network
- name: mynetwork
  type: compute.v1.network
  properties:
    autoCreateSubnetworks: true

# Create the mynet-us-vm instance
- name: mynet-us-vm
  type: instance-template.jinja
  properties:
    zone: us-central1-a
    machineType: n1-standard-1
    network: $(ref.mynetwork.selfLink)
    subnetwork: regions/us-central1/subnetworks/mynetwork
    
# Create the mynet-eu-vm instance
- name: mynet-eu-vm
  type: instance-template.jinja
  properties:
    zone: europe-west1-d
    machineType: n1-standard-1
    network: $(ref.mynetwork.selfLink)  
    subnetwork: regions/europe-west1/subnetworks/mynetwork

# Create the firewall rule
- name: mynetwork-allow-http-ssh-rdp-icmp
  type: compute.v1.firewall
  properties:
      network: $(ref.mynetwork.selfLink)
      sourceRanges: ["0.0.0.0/0"]
      allowed:
      - IPProtocol: TCP
        ports: [22, 80, 3389]
      - IPProtocol: ICMP

Create a deployment called dminfra without actually instantiating the underlying resources based on a provided config file

gcloud deployment-manager deployments create dminfra --config=config.yaml --preview

The following will be the typical output:

Output.4

The fingerprint of the deployment is 1XwQ4k1HSewzjUzugVP9Hg==
Waiting for create [operation-1572807933118-59675e22749d1-f439e19d-6130d205]...done.
Create operation operation-1572807933118-59675e22749d1-f439e19d-6130d205 completed successfully.
NAME                               TYPE                 STATE       ERRORS  INTENT
mynet-eu-vm                        compute.v1.instance  IN_PREVIEW  []      CREATE_OR_ACQUIRE
mynet-us-vm                        compute.v1.instance  IN_PREVIEW  []      CREATE_OR_ACQUIRE
mynetwork                          compute.v1.network   IN_PREVIEW  []      CREATE_OR_ACQUIRE
mynetwork-allow-http-ssh-rdp-icmp  compute.v1.firewall  IN_PREVIEW  []      CREATE_OR_ACQUIRE

Update the deployment named dminfra and actually instantiate the underlying resources

gcloud deployment-manager deployments update dminfra

The following will be the typical output:

Output.5

The fingerprint of the deployment is 1s9PcYLCzo_AMUMdNNS9Fg==
Waiting for update [operation-1572808086835-59675eb50d159-fc91a93e-09cf08db]...done.
Update operation operation-1572808086835-59675eb50d159-fc91a93e-09cf08db completed successfully.
NAME                               TYPE                 STATE      ERRORS  INTENT
mynet-eu-vm                        compute.v1.instance  COMPLETED  []
mynet-us-vm                        compute.v1.instance  COMPLETED  []
mynetwork                          compute.v1.network   COMPLETED  []
mynetwork-allow-http-ssh-rdp-icmp  compute.v1.firewall  COMPLETED  []

References

Coursera - Elastic Cloud Infrastructure: Scaling and Automation

Elastic Cloud Infrastructure: Scaling and Automation - Summary Notes - Part 1

Elastic Cloud Infrastructure: Scaling and Automation - Summary Notes - Part 2



© PolarSPARC