0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GCPの構成図をGraphvizで描く

Posted at

最近、GCPで環境を作ることになったのだけどCloud Deployment Managerが中々便利。IaCはすばらです。

ただ、構成図をいちいち描くのがめんどくさい。今の所draw.ioやパワポで描いてるのだけど実設定との整合性を取らなくなるのは火を見るより明らか。サボる自信がある。

なので、Cloud Deployment Managerをビジュアルに表示するツールくらい当然あるだろうと探してみたのだけど意外と無い。AWSだとCloudMapperってのがあるみたいだけどGCPは対応してなさそう。

と言うわけで仕方無いから作ってみようかと思い立ったので、まずは手始めにGraphvizでGCPの構成図を描いてみました。

こんな感じの良くありそうな構成図を描いてみます。
gcp.png

元のdotファイルはこんな感じ。

digraph G {
  layout=dot;


  labeljust=l;
  color=white;

  internet [
      label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/internet.png" /></td><td>Internet</td></tr></table>>,
      shape=record, color=black, style = "filled", fillcolor=white
  ];
  subgraph cluster_gcp {
    label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/Extras/Google Cloud Platform.png" /></td><td>Google Cloud</td></tr></table>>;
    bgcolor=lightgrey;
    subgraph cluster_vpc1 {
      label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/Networking/Virtual Private Cloud.png" /></td><td>Virtual Private Cloud</td></tr></table>>;
      bgcolor="#e1f6fe";
      subgraph cluster_region1 {
        label="Region 1";
        bgcolor="#e2ffec";

        internet_gw [ 
          label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/Networking/Cloud Load Balancing.png" /></td><td>Internet Gateway</td></tr></table>>,
          shape=record, 
          color=black, 
          style = "filled", 
          fillcolor=white
        ];

        subgraph cluster_zonea {
          label="Zone a";
          style="dashed"
          color=green;
          subgraph cluster_subnet1 {
            label="subnet: 10.0.0.0/24";
            bgcolor="#ede7f7";
            style="solid";
            color=white;

            compute1 [ 
              label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/Compute/Compute Engine.png" /></td><td>10.0.0.1</td></tr></table>>,
              shape=record, 
              color=black, 
              style = "filled", 
              fillcolor=white
            ];
            compute2 [ 
              label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/Compute/Compute Engine.png" /></td><td>10.0.0.2</td></tr></table>>,
              shape=record, 
              color=black, 
              style = "filled", 
              fillcolor=white
            ];
          }    
        }
      }
    }
  }

  internet -> internet_gw;
  internet_gw -> compute1;
  internet_gw -> compute2;

}

改善するところは多そうだけど、とりあえずそれっぽく描けた感じですね。Graphviz便利ですね。

まとめ

割とGCPの構成図っぽいものが簡単に描けました。

あとは、肝心のCloud Deployment Managerとの連携なんだけど、Deployment Managerのスクリプトを解析するのはちょっと大変そうだから、JSONかYAMLでサブセット言語を作ってそこからDOTファイルとDeployment ManagerのYAMLを作るのがとりあえず良いかも。

それではHappy Hacking!

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?