项目作者: prestonceo

项目描述 :
Networking & Monitoring on google cloud with stack driver and CLI
高级语言:
项目地址: git://github.com/prestonceo/Networking-on-google-cloud.git
创建时间: 2018-03-22T21:52:06Z
项目社区:https://github.com/prestonceo/Networking-on-google-cloud

开源协议:

下载


Networking-on-google-cloud

You can use these commands for playground purposes on the google cloud platform. This should be considered a reference and by no means should you use this as a guide for production purposes.

Creating a subnet with a address range, the first command creates the name of the subnet and uses custom subnet creation. GCP does allow automatic subnet creation as an option and Creates the subnets for you (optional).

  1. # creates the name of the network and the subnet mode to custom
  2. gcloud compute --your-project-id networks create subnet-east-1 --mode=custom
  1. # creates the subnet-east-vpn subnet with a region us west 1 with a subnet address range specified
  2. gcloud compute --your-project-id networks subnets create subnet-east-vpn --network=subnet-east-1 --region=us-west1 --range=10.128.0.0/20

firewall rule creates the subnet name “subnet-west-secure” the direction is ingress meaning the traffic that is allowed in. as you can see we created a firewall rule specifying the network as subnet-demo-gcp, followed by the allowed ports ssh, http

  1. gcloud compute --your-project-id firewall-rules create subnet-west-secure --direction=INGRESS --priority=1000 --network=subnet-demo-gcp --action=ALLOW --rules=tcp:22,tcp80 --source-ranges=10.138.0.0/20
  1. you probably noticed in the first part of the demonstration there’s a network subnet-east-1, the firewall was created for a different subnet, which is network subnet-demo-gcp
  1. When creating firewall rules, you can specify for the firewall rule to be subnet specific, project wide or for specific IP ranges.
  1. gcloud config set project <PROJECT_ID_GOES_HERE> #sets the specified project
  1. gcloud compute instances list #output list of instances

understanding the basics

Networks can contain one or more subnets in any given region, when using custom mode this goves you control over the subnet region instead of GCP choosing the region for you.

when creating a subnet you must choose the lowest subnet for the mask, but don’t worry google requires this but you must know what the lowest subnet is for the mask you choose.

Monitoring & Logging with Stackdriver

Stackdriver is used for monitoring, logging, and keeping a close eye on your resources, the amount of features and capabilities offered by stack driver is beyond the scope of this reference. but i do recommend you trying out the tutorials on codelabs

  1. gcloud compute ssh "YOUR_INSTANCE_NAME_HERE
  1. curl -sSO "https://dl.google.com/cloudagents/install-logging-agent.sh" #download the logging agent installation
  1. sudo bash install-logging-agent.sh #run the script

remove the logging agent and fluentd

  1. sudo service google-fluentd stop
  2. sudo apt-get remove google-fluentd google-fluentd-catch-all-config
  1. gcloud projects list #get projects list
  1. gcloud compute instances list #get instances status