めもめも

このブログに記載の内容は個人の見解であり、必ずしも所属組織の立場、戦略、意見を代表するものではありません。

Introduction to Google Cloud Platform for OpenStackers (Part II)

Disclaimer

This is not an official document of Google Cloud Platform. Please refer to the GCP web site for the official information.

cloud.google.com

Part I of this article series is here.

enakai00.hatenablog.com

In this part, I describe networking functionality of GCP compared with OpenStack Neutron.

Comparing network models

OpenStack Neutron

Using OpenStack Neutron, you can create a virtual router inside your project (tenant) which provides an independent private network. It's just like creating your home network. You can add virtual L2 switches behind the router and assign private IP subnets. The VM instances can communicate through the virtual router using private IPs.

If you want to expose VM instances to an external network, you can assign a floating IP to an instance. Floating IPs are a pool of global IP addresses secured for the project in advance. The virtual router provides the NAT operation between the floating IP and a private IP of the instance.

The Neutron's private network is transparent to Availability Zones since it's configured spanning over all Availability Zones in a Region. However, you cannot configure a virtual network spanning over multiple Regions. The virtual network is solely confined in a single Region, VM instances in different Regions need to communicate over an external network using floating IPs.

It's possible to create multiple virtual routers in a project. In this case, VM instances under different routers cannot communicate directly with private IPs. They need to communicate through an external network with floating IPs.

GCP Networking

You can define multiple "Networks" in your GCP project. The "Network" is something comparable to the virtual router in Neutron. But one important difference is that the virtual router connects all Regions through an internal network. (Please see diagrams in the following sections for more concrete images.)

In addition, there are two different types of GCP's "Network", that is, "Legacy network" and "Subnet network." Interestingly, Legacy network provides a single private subnet spanning all the Regions around the globe. You can think that the "Virtual Switch" in the following diagram corresponds to the virtual router in Neutron.

https://cloud.google.com/compute/images/subnetworks/no_subnetworks_1.svg

Looking back the history of network architecture, people have used subnets to manage network gears in different physical locations. It's not a hard requirement for the cloud network emulating subnets in the real world. In GCP networking, you can use the tag-based access control mechanism which is independent of the concept of subnets. Using Legacy network, you don't need to be bothered with subnet management any more without compromising the access control.

Having said that, ...

People still need subnets in some cases, currently, GCP uses Subnet network as default. You can create only Subnet networks from Cloud Console. You need to use gcloud command to create Legacy networks.

Subnet network has a similar concept to Neutron's virtual networks. You can create multiple subnets in each Region. However, totally different from Neutron, as all Regions are connected through an internal network, all subnets are routable each other over private IPs. You don't need to use global IPs nor the Internet for inter-region communication.

You can think that "Virtual Switch"s (corresponding to the virtual router of Neutron) are connected through the global internal network.

https://cloud.google.com/compute/images/subnetworks/subnetworks_1.svg

I will mention the GCP's internal network details in a later section.

Note that Legacy network and Subnet network are not something exclusive. Like creating multiple virtual routers in Neutron, you can create multiple "Networks", and you can mix both Legacy network and Subnet network. When you create a new project, there is a single "Network" named as "default". It has a subnet with /20 range named as "default" in each Region.

Finally, talking about global IPs, GCP provides "External IPs" as a pool of global IPs for each project. There are two types of External IP such as "Static" and "Ephemeral". The "Static" External IPs work similarly as Floating IP of Neutron. You can use them as a permanent resource. On the other hand, the "Ephemeral" ones are assigned automatically when you launch a new instance and there is no guarantee for permanent existence. In other words, when you stop and restart an instance, you may have a different global IP if you're using the "Ephemeral" one.

Firewall configuration

Neutron provides a concept of "Security Groups" for packet filtering mechanism. A Security Group contains a multiple ACLs independent of specific VM instances. Once you associate a Security Group to an instance, the ACLs are applied to it. Typically, you would define Security Groups corresponding to specific roles of instances such as web servers or DB servers. Since Neutron's virtual networks are defined in each Region, you also need to define Security Groups in each Region.

In GCP Networking, you define firewall rules in each Network which spans all Regions. It specifies a filtering rule using "rule" and "tags". "Tags" are arbitrary labels associated with instances as metadata. You can associate multiple tags to a single instance. On the other hand, "rule" is an ACL specifying an allowed packet flow using the following conditions.

  • Source: IP range, subnet, tags
  • Destination: tags

With this mechanism, you can separate "tags to specify instance roles" and "rules to specify ACL corresponding to roles". For example, once you define a rule allowing sending packets from any IP to "web-server" tag, you can add the "web-server" tag to any instances to allow TCP80 connection for them. When you define a rule without specifying tags, it allows the specified connection to all instances.

By the way, when you create a new project, the "default" network has the following predefined rules. Can you guess what kind of connections they allow? "10.128.0.0/9" is a subnet containing the underlying subnets in all Regions.

From top to bottom, it allows the following connections.

  • ICMP from any external source.
  • Any packets between all instances connected to the "default" network.
  • RDP from any external source.
  • SSH from any external source.

GCP's internal network

Google owns the global internal network to provide various services to external customers. The overall architecture is explained in the following web site.

GCP utilizes this global infrastructure to provide the dedicated global internal network. The connection to external networks are provided at multiple locations called "Edge Points of Presence (PoPs)" around the globe. When you connect to an instance running on GCP from your location, you would reach one of the PoPs at the optimum location, and be routed through the high bandwidth internal network. In addition, since each PoP provides the contents caching mechanism, you can leverage it without any special treatment if you provide external web services from App Engine or Compute Engine on GCP thorough the global load balancer service.

There are some network providers who offer dedicated network facility to connect your office network directly to GCP's network infrastructure. Please refer to the following web site for details.

cloud.google.com

What's next?

I will give a comparison between OpenStack Nova/Cinder and Compute Engine regarding VM instance management.

enakai00.hatenablog.com

Introduction to Google Cloud Platform for OpenStackers (Part I)

Disclaimer

This is not an official document of Google Cloud Platform. Please refer to the GCP web site for the official information.

cloud.google.com

GCP Basics

Google Cloud Platform provides various computing resources as a cloud service on top of Google's core infrastructure. It has several categories such as Compute, Storage and Bigdata. They offer the following core services in addition to other interesting services for Bigdata processing and analysis.

Compute
Service Description
App Engine Runtime environment for scale-out Web applications.
Compute Engine Runtime environment for virtual machines.
Container Engine Runtime environment for container application based on Kubernetes
Cloud Functions Runtime environment for asynchronous event driven functions.
Networking Common network infrastructure for all cloud services.
Storage
Service Description
Bigtable Distributed Key-Value store with HBase compatible API
Cloud SQL Managed service for MySQL database
Cloud Datastore NoSQL document database
Cloud Storage Object storage service

It also provides a common functionality for IAM (Identity & Access Management). You can use the following tools to interact with these services.

  • REST API
  • SDK (Command line interface tools such as the gcloud command.)
  • Google Cloud Console (Web portal)

The following shows a rough comparison with OpenStack's major components in terms of their functionalities.

OpenStack GCP
Keystone IAM
Horizon Cloud Console
Nova, Glance, Cinder Compute Engine
Neutron Networking
Swift Cloud Storage

Physical locations - Regions and Zones

OpenStack

When deploying OpenStack clusters in multiple locations, a single cluster managed with a dedicated controller is specified as "Region." You can define multiple "Availability Zones" inside a Region so that you can group together physical resources such as compute nodes and storage boxes. It depends on the infrastructure design how you split resources with Availability Zones. Typically, you would split them in the unit of racks or datacenter floors.

However, you need to ensure that you have a reasonable network bandwidth between Availability Zones. The best practice tells you that you'd better consolidate a single cluster (i.e. physical resources for a single Region) into a single data center to avoid problems caused by a lack of sufficient network bandwidth.

GCP

GCP also has a concept of "Regions" and "Zones" which allows users to manage geographical locations and failure zones of service resources.
. At the time of writing (July, 2016) there are four Regions around the globe, and each of them has multiple Zones. There is a more detailed description in the following official web site.

https://cloud.google.com/compute/images/zones_diagram.svg
Inside a Region, all Zones are connected with a dedicated internal network providing a bandwidth and latency comparable to one within a data center. It means you can safely deploy a (traditional tightly coupled) cluster application over multiple zones to achieve a high availability across multiple failure zones.

In addition, there has been an announcement about a plan for more Regions in coming years.

For some managed services like Bigtable and Cloud Storage, there are some patterns how you could specify the Regions and Zones to be used. Please refer to the following documents for details.

cloud.google.com

What's next?

In Part2, I'll give you a comparison between OpenStack Neutron and GCP's Networking service.

Here's Part2 now.!

enakai00.hatenablog.com

OpenStackユーザーのためのGoogle Cloud Platform入門(パート2)

前置き

これは、GCPの公式文書ではありません。公式ドキュメントについては、公式ホームページを参照ください。

Google Cloud Platform

実際に試してみたい方は、60日の無料トライアルをお試しください。(クレジットカードの登録が必要ですが、トライアル終了後は明示的に課金設定を行わない限り、勝手に課金されることはありませんので、ご安心ください。)

cloud.google.com

本記事のパート1はこちらです。

enakai00.hatenablog.com

パート2では、ネットワークの基本的な仕組みを紹介します。

ネットワークモデルの比較

OpenStack Neutronのネットワークモデル

OpenStack Neutronでは、テナント(プロジェクト)ごとに仮想ルーターを配置することで、独立したプライベートネットワークを提供します。仮想ルーターの背後に任意の数だけ仮想スイッチを用意して、それぞれにプライベートIPのサブネットを割り当てます。同一テナントのVMは、仮想ルーターを経由することで、プライベートIPによる相互通信を行います。

・参考 「絵で見てわかるクラウドインフラとAPIの仕組み」より

また、外部ネットワークから接続が必要なVMインスタンスには、フローティングIPを割り当てて、仮想ルーター上でNATを行います。フローティングIPは、それぞれのテナントで事前に確保しておく、グローバルIPアドレスのプールになります。

また、上記のプライベートネットワークは、アベイラビリティゾーンを意識せずに利用することができます。すべてのアベイラビリティゾーンにまたがる形で、仮想ネットワークが構成されていると考えることができます。ただし、リージョンをまたいで仮想ネットワークを構成することはできません。リージョンごとに個別に仮想ネットワークを構成するため、リージョン間で通信する際は、フローティングIPを用いた、外部ネットワーク経由の通信が必要となります。

また、テナント内に複数の仮想ルーターを配置する事も可能で、この場合、異なる仮想ルーターの配下にあるインスタンス同士は、直接に通信することはできなくなります。フローティングIPを用いて、外部ネットワークを介して通信する必要があります。

GCPのネットワークモデル

GCPでは、1つのプロジェクト内に複数の「ネットワーク」を定義することができます。ここで言う1つの「ネットワーク」は、Neutronで言うところの1つの「仮想ルーター」に対応すると考えることができます。ただし、Neutronと大きく異る点として、この仮想ルーターは、すべてのリージョンを内部ネットワークで直結する形で配置されます。(具体的なイメージは、この後の図を参照してください。)

また、GCPの「ネットワーク」には、「レガシー構成」と「サブネット構成」の2種類があります。レガシー構成は、なんと(!)1つのプロジェクトに対して、「全世界のすべてのリージョンにまたがった単一のプライベートなサブネット」が用意されるというGoogleらしい大胆な仮想ネットワークを提供します。下図のVirtual Switchが仮想ルーターに相当すると考えてください。

・参考 「Using Networks and Firewalls」より
https://cloud.google.com/compute/images/subnetworks/no_subnetworks_1.svg

冷静に考えると、従来のサブネットは、ネットワーク機器の物理的な配置に合わせてネットワークを分割するために考えだされたものですので、完全に仮想化されたネットワーク上でわざわざサブネットを利用する必要はありません。ファイアウォールによるアクセス制御については、後述のように「ラベル」を用いたパケットフィルタリングが利用できるので、レガシー構成を利用すれば、「サブネットの管理」という作業から開放されて、より柔軟で抽象化されたアクセス制御が実現できます。

・・・とはいえ。

そうは言ってもサブネットがないと・・・という状況もあるため、現在は「サブネット構成」のネットワークがデフォルトになっています。(Cloud Consoleからはサブネット構成のネットワークのみが作成可能で、レガシー構成のネットワークを作成する際は、gcloudコマンドを使用する必要があります。)

サブネット構成は、Neutronの仮想ネットワークに考え方が似ており、リージョンごとに複数のサブネットを用意することが可能です。ただし、Neutronと異なる点として、リージョンをまたいでのルーティングが可能になっており、プライベートIPのままでリージョン間の通信を行うことが可能です。この際、物理的なネットワーク経路として、GCPの内部ネットワークが使用されます。つまり、インターネットを経由せずに、専用線によるリージョン間通信が可能になります。

下図のように、各リージョンのVirtual Switch(仮想ルーター)がグローバルな内部ネットワークで直結されているものと考えてください。

・参考 「Using Networks and Firewalls」より
https://cloud.google.com/compute/images/subnetworks/subnetworks_1.svg

※ GCPの内部ネットワークについては、この後で詳しく説明します。

なお、レガシー構成のネットワークとサブネット構成のネットワークは、排他的なものではありません。両方の種類のネットワークを定義して利用することも可能です。新しいプロジェクトを作成した直後は、デフォルトで、「default」という名称の(サブネット構成の)「ネットワーク」が用意されており、さらに、各リージョンに「default」という名称の/20の大きさのサブネットが用意されています。

最後に、インターネットから接続するためのグローバルIPについては、Neutronと同様にリージョンごとに確保してインスタンスに割り当てます。GCPでは、「External IP」という名称になります。External IPには、「Static」と「Ephemeral」の2種類があり、Staticは(フローティングIPと同様に)永続的に確保することが可能です。一方、Ephemeralは、インスタンスを起動すると自動的に割り当てられるもので、永続性は保証されません。インスタンスを停止・起動するとIPアドレスが変化する可能性があります。グローバルIPを固定したい場合は、StaticなExternal IPを確保して割り当てる必要があります。

ファイアウォールの設定

Neutronでは、「セキュリティグループ」を用いてパケットフィルタリングを行います。1つのセキュリティグループは、複数のACLをまとめて定義したもので、インスタンスに対してセキュリティグループを適用することで、該当のACLが適用されます。セキュリティグループは、リージョンごとに定義する形になります。典型的には、インスタンスの役割ごとに対応するセキュリティグループを用意します。

一方、GCPでは、ファイアウォールルールは、「ネットワーク」ごとに定義する形になっており、「ルール」と「タグ」の組み合わせでパケットフィルタリングを行います。タグは、それぞれのインスタンスにメタデータとして付与する任意のラベルで、1つのインスタンスに複数のタグを付けることも可能です。一方、ルールは、パケットの転送を許可するACLに対応するものですが、対象のプロトコル/ポート番号に加えて、送信元と宛先を次のような条件で指定します。

・送信元:IPレンジ、サブネット、タグのいずれか
・宛先:タグ

これにより、「インスタンスの役割を示すタグ」と「役割に応じたACLを示すルール」を分離することが可能になります。たとえば、任意のソースIPからタグ「web-server」にTCP80の転送を許可するルールを事前定義しておけば、後は、TCP80での接続を許可したいインスタンスに対しては、「web-server」というタグを付けるだけでOKです。また、宛先のタグを省略したルールを定義すると、任意のインスタンスに対して許可することになります。

ちなみに、プロジェクト作成時のデフォルトでは、「default」ネットワークに対して、以下のようなルールが事前に定義されています。これは、どのような通信を許可するルールかわかるでしょうか?「10.128.0.0/9」は各リージョンのサブネットを包含する上位のサブネットになります。

これは、上から順に「外部からのicmpを許可」「defaultネットワークのサブネットに接続したインスタンス間はすべてのパケットを許可」「外部からのRDPを許可」「外部からのSSHを許可」という意味になります。

GCPの内部ネットワーク構成について

Googleは、もともと自社サービス用のグローバルネットワークを保持しており、その全体的な構成が下記のWebサイトで紹介されています。

Understand Our Infrastructure

これは、GCPのネットワークインフラにも用いられており、これによって、専用線によるグローバルな内部ネットワークを実現しています。また、インターネットとの相互接続は、世界の複数の拠点にある「Edge Points of Presence (PoPs)」で行われており、インターネットからGCP上のインスタンスに接続する際は、最適な場所のPoPから内部ネットワークに到達します。これにより、利用者の住んでいる場所とインスタンスが存在するリージョンがネットワーク的に遠い場合でも、高速な内部ネットワークを経由して、インスタンスにアクセスすることが可能になります。

また、それぞれのPoPには、コンテンツキャッシュの機能が用意されており、App EngineやCompute Engineを利用して外部向けのWebサービスを提供する際は、グローバルロードバランサーを使用することで、特別な手続き無しにコンテンツキャッシュの機能を利用することが可能です。

その他には、利用者の社内ネットワークを(インターネットを介さずに)GCPの内部ネットワークに直結するための専用線を提供するプロバイダーもあります。詳しくは、下記を参照してください。

cloud.google.com

次回予告

パート3は、Nova/CinderとCompute Engineの比較です。メタデータサーバーとcompute-image-packages(OpenStackのcloud-init的なツール)なども紹介します。

enakai00.hatenablog.com