cloud-barista / cb-tumblebug

Cloud-Barista Multi-Cloud Infra Management Framework
Apache License 2.0
56 stars 52 forks source link

Add a utility function to design vNets and subnets initially #1793

Closed yunkon-kim closed 2 months ago

yunkon-kim commented 2 months ago

I hope this PR will make vNet and subnet design a bit easier. There's an option to consider supernetting :-)

Let me show the API with just a screenshot and req/res bodies :-)

image

Request body

{
    "targetPrivateNetwork": "10.0.0.0/8",
    "supernettingEnabled": "true",
    "cspRegions": [
        {
            "connectionName": "aws-ap-northeast-2",
            "neededVNets": [
                {
                    "subnetCount": 5,
                    "subnetSize": 260,
                    "zoneSelectionMethod": "firstTwoZones"
                },
                {
                    "subnetCount": 2,
                    "subnetSize": 100,
                    "zoneSelectionMethod": "firstTwoZones"
                }
            ]
        },
        {
            "connectionName": "gcp-asia-northeast2",
            "neededVNets": [
                {
                    "subnetCount": 3,
                    "subnetSize": 200,
                    "zoneSelectionMethod": "firstTwoZones"
                }
            ]
        },
        {
            "connectionName": "azure-koreacentral",
            "neededVNets": [
                {
                    "subnetCount": 2,
                    "subnetSize": 1000,
                    "zoneSelectionMethod": "firstTwoZones"
                }
            ]
        }
    ]
}

Response body

{
  "rootNetworkCIDR": "10.0.0.0/20",
  "vNetReqList": [
    {
      "name": "vnet00",
      "connectionName": "aws-ap-northeast-2",
      "cidrBlock": "10.0.0.0/21",
      "subnetInfoList": [
        {
          "name": "subnet00",
          "ipv4_CIDR": "10.0.0.0/24",
          "zone": "ap-northeast-2a",
          "description": "subnet00 designed by util/vNet/design"
        },
        {
          "name": "subnet01",
          "ipv4_CIDR": "10.0.1.0/24",
          "zone": "ap-northeast-2b",
          "description": "subnet01 designed by util/vNet/design"
        },
        {
          "name": "subnet02",
          "ipv4_CIDR": "10.0.2.0/24",
          "zone": "ap-northeast-2a",
          "description": "subnet02 designed by util/vNet/design"
        },
        {
          "name": "subnet03",
          "ipv4_CIDR": "10.0.3.0/24",
          "zone": "ap-northeast-2b",
          "description": "subnet03 designed by util/vNet/design"
        },
        {
          "name": "subnet04",
          "ipv4_CIDR": "10.0.4.0/24",
          "zone": "ap-northeast-2a",
          "description": "subnet04 designed by util/vNet/design"
        },
        {
          "name": "subnet05-reserved",
          "ipv4_CIDR": "10.0.5.0/24",
          "zone": "ap-northeast-2b",
          "description": "subnet05-reserved designed by util/vNet/design"
        },
        {
          "name": "subnet06-reserved",
          "ipv4_CIDR": "10.0.6.0/24",
          "zone": "ap-northeast-2a",
          "description": "subnet06-reserved designed by util/vNet/design"
        },
        {
          "name": "subnet07-reserved",
          "ipv4_CIDR": "10.0.7.0/24",
          "zone": "ap-northeast-2b",
          "description": "subnet07-reserved designed by util/vNet/design"
        }
      ],
      "description": "vnet00 designed by util/vNet/design"
    },
    {
      "name": "vnet00",
      "connectionName": "aws-ap-northeast-2",
      "cidrBlock": "10.0.8.0/24",
      "subnetInfoList": [
        {
          "name": "subnet00",
          "ipv4_CIDR": "10.0.8.0/25",
          "zone": "ap-northeast-2a",
          "description": "subnet00 designed by util/vNet/design"
        },
        {
          "name": "subnet01",
          "ipv4_CIDR": "10.0.8.128/25",
          "zone": "ap-northeast-2b",
          "description": "subnet01 designed by util/vNet/design"
        }
      ],
      "description": "vnet00 designed by util/vNet/design"
    },
    {
      "name": "vnet00",
      "connectionName": "gcp-asia-northeast2",
      "cidrBlock": "10.0.9.0/22",
      "subnetInfoList": [
        {
          "name": "subnet00",
          "ipv4_CIDR": "10.0.9.0/24",
          "zone": "asia-northeast2-a",
          "description": "subnet00 designed by util/vNet/design"
        },
        {
          "name": "subnet01",
          "ipv4_CIDR": "10.0.10.0/24",
          "zone": "asia-northeast2-b",
          "description": "subnet01 designed by util/vNet/design"
        },
        {
          "name": "subnet02",
          "ipv4_CIDR": "10.0.11.0/24",
          "zone": "asia-northeast2-a",
          "description": "subnet02 designed by util/vNet/design"
        },
        {
          "name": "subnet03-reserved",
          "ipv4_CIDR": "10.0.12.0/24",
          "zone": "asia-northeast2-b",
          "description": "subnet03-reserved designed by util/vNet/design"
        }
      ],
      "description": "vnet00 designed by util/vNet/design"
    },
    {
      "name": "vnet00",
      "connectionName": "azure-koreacentral",
      "cidrBlock": "10.0.13.0/21",
      "subnetInfoList": [
        {
          "name": "subnet00",
          "ipv4_CIDR": "10.0.13.0/22",
          "zone": "1",
          "description": "subnet00 designed by util/vNet/design"
        },
        {
          "name": "subnet01",
          "ipv4_CIDR": "10.0.17.0/22",
          "zone": "2",
          "description": "subnet01 designed by util/vNet/design"
        }
      ],
      "description": "vnet00 designed by util/vNet/design"
    }
  ]
}
yunkon-kim commented 2 months ago

/approve