GCP 자습서 시도 'VPC 만들기 및 삭제'

6498 단어 튜토리얼vpcgcp

제목



표제의 튜토리얼을 시험해 보자.

【참조】
htps : // c ぉ d. 오, ぇ. 이 m/vpc/도cs/우신 g-vpc? 아우테세 r = 1 & hl =

전제


  • GCP 환경이 유지됨.
  • gcloud 명령이 설치되었습니다.

  • Virtual Private Cloud(VPC)


  • VPC 네트워크에는 "자동 모드"와 "사용자 정의 모드"가 있습니다.
  • 1 프로젝트에 대해 5 네트워크까지 만들 수 있다. (※ 기본값 포함)
  • 네트워크 모드를 자동에서 사용자 정의로 전환합니다. (단방향 전용)
  • 서브넷의 IP 범위를 확장할 수 있습니다. 축소는 할 수 없다.

  • 자동 모드 VPC 네트워크 생성


    
    $ gcloud compute networks create auto-network1 --subnet-mode auto
    
    
    Created [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/global/networks/auto-network1].
    NAME           SUBNET_MODE  BGP_ROUTING_MODE  IPV4_RANGE  GATEWAY_IPV4
    auto-network1  AUTO         REGIONAL
    
    Instances on this network will not be reachable until firewall rules
    are created. As an example, you can allow all internal traffic between
    instances as well as SSH, RDP, and ICMP by running:
    
    $ gcloud compute firewall-rules create  --network auto-network1 --allow tcp,udp,icmp --source-ranges 
    $ gcloud compute firewall-rules create  --network auto-network1 --allow tcp:22,tcp:3389,icmp
    

    작성 결과



    각 지역마다 서브넷이 하나씩 만들어집니다.


    아시아 지역에 대해 자세히 알아보기





    맞춤 서브넷을 사용하여 VPC 네트워크 생성


    
    $ gcloud compute networks create custom-network1 --subnet-mode custom
    
    
    Created [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/global/networks/custom-network1].
    NAME             SUBNET_MODE  BGP_ROUTING_MODE  IPV4_RANGE  GATEWAY_IPV4
    custom-network1  CUSTOM       REGIONAL
    
    Instances on this network will not be reachable until firewall rules
    are created. As an example, you can allow all internal traffic between
    instances as well as SSH, RDP, and ICMP by running:
    
    $ gcloud compute firewall-rules create  --network custom-network1 --allow tcp,udp,icmp --source-ranges 
    $ gcloud compute firewall-rules create  --network custom-network1 --allow tcp:22,tcp:3389,icmp
    

    작성 결과



    사용자 정의의 경우 서브넷은 마음대로 만들 수 없습니다.


    커스텀 서브넷의 리전 3개에 대한 서브넷 생성


    
    $ gcloud compute networks subnets create subnets-us-central-192 --network custom-network1 --region us-central1 --range 192.168.1.0/24
    $ gcloud compute networks subnets create subnets-europe-west-192 --network custom-network1 --region europe-west1 --range 192.168.5.0/24
    $ gcloud compute networks subnets create subnets-asia-east-192 --network custom-network1 --region asia-east1 --range 192.168.7.0/24
    
    
    Created [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/regions/us-central1/subnetworks/subnets-us-central-192].
    NAME                    REGION       NETWORK          RANGE
    subnets-us-central-192  us-central1  custom-network1  192.168.1.0/24
    
    Created [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/regions/europe-west1/subnetworks/subnets-europe-west-192].
    NAME                     REGION        NETWORK          RANGE
    subnets-europe-west-192  europe-west1  custom-network1  192.168.5.0/24
    
    Created [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/regions/asia-east1/subnetworks/subnets-asia-east-192].
    NAME                   REGION      NETWORK          RANGE
    subnets-asia-east-192  asia-east1  custom-network1  192.168.7.0/24
    

    작성 결과 확인


    
    $ gcloud compute networks subnets list | grep custom-network1
    subnets-asia-east-192    asia-east1               custom-network1  192.168.7.0/24
    subnets-europe-west-192  europe-west1             custom-network1  192.168.5.0/24
    subnets-us-central-192   us-central1              custom-network1  192.168.1.0/24
    
    
    $ gcloud compute networks subnets describe subnets-asia-east-192 --region asia-east1
    creationTimestamp: '2018-08-09T08:36:58.521-07:00'
    fingerprint: XXX-XXXXXXXX
    gatewayAddress: 192.168.7.1
    id: '1111111111111111111'
    ipCidrRange: 192.168.7.0/24
    kind: compute#subnetwork
    name: subnets-asia-east-192
    network: https://www.googleapis.com/compute/v1/projects/XXXXXXXX/global/networks/custom-network1
    privateIpGoogleAccess: false
    region: https://www.googleapis.com/compute/v1/projects/XXXXXXXX/regions/asia-east1
    selfLink: https://www.googleapis.com/compute/v1/projects/XXXXXXXX/regions/asia-east1/subnetworks/subnets-asia-east-192
    

    작성한 리전마다 서브넷이 하나씩 만들어진다.


    미국 중앙 지역에 대해 자세히 알아보기





    맞춤 서브넷 삭제



    자동으로 생성된 서브넷은 개별적으로 삭제할 수 없습니다. 삭제하려면 VPC 네트워크 전체 삭제가 필요.
    
    $ gcloud compute networks subnets delete subnets-asia-east-192 --region asia-east1
    
    
    The following subnetworks will be deleted:
     - [subnets-asia-east-192] in [asia-east1]
    
    Do you want to continue (Y/n)?  y
    
    Deleted [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/regions/asia-east1/subnetworks/subnets-asia-east-192].
    

    삭제 결과





    VPC 네트워크 삭제


    
    $ gcloud compute networks delete auto-network1
    
    
    The following networks will be deleted:
     - [auto-network1]
    
    Do you want to continue (Y/n)?  y
    
    Deleted [https://www.googleapis.com/compute/v1/projects/XXXXXXXX/global/networks/auto-network1].
    

    좋은 웹페이지 즐겨찾기