Networking and Operations
Networking and Operations
(www.docker.com)
- Global
Resources from anywhere
VPC - Multi-tenancy
VPC shared across GCP projects
- Private and secure
IAM, firewall rules
Projects and VPCs
Project
Project
VPC #1 Subnet 2
Subnet 1
Projects and VPCs
Project
VPC #1 Subnet 2
Subnet 1
Private IP addresses
Projects and VPCs
Project
VPC #1 Subnet 2
Subnet 1
Firewall
Projects and VPCs
Project
IP Addresses
- Each VM has internal IP address
Project
VPC #1 Subnet 2
Subnet 1
Private IP addresses
Projects and VPCs
Project
VPC #1 Subnet 2
Subnet 1
Names (DNS provided)
Projects and VPCs
Project
VPC #1 Subnet 2
Subnet 1
Firewall
- Each VPC network has its own firewall controlling
access to the instances
- For example, you can create a firewall rule that allows all traffic through
port 80 to all instances, or only allows traffic from one specific IP or IP
range to one specific instance
- Action: allow or deny
It is still possible to create legacy networks through the gcloud command-line tool and the
REST API. It is not possible to create legacy networks using the Google Cloud Platform
Console.
Legacy GCP
Net works
Can refer to instances by name rather than IP
Cloud DNS
Each VM has a DNS resolver to allow this
VPC #1 Subnet 2
Subnet 1
Private IP addresses
Cloud DNS
Project
VPC #1 Subnet 2
Subnet 1
Names (DNS provided)
Cloud DNS
Managed Zone
- Maintained by Cloud
DNS
Cloud DNS
Record types -
A - Address record
MX - Mail exchange
Resource Record
Changes
Project
VPC #1 Subnet 2
Subnet 1
Names (DNS provided)
Google Cloud
Cloud
Interconnect
On-Premise
Data Center
Cloud
Interconnect Google Cloud
ISP
On-Premise
Data Center
Data-intensive applications
Cloud
Interconnect
Latency-sensitive applications
Cloud Interconnect
Providers
Google Cloud
Cloud
Interconnect
On-Premise
Data Center
CDN Interconnect
Google Cloud
CDN Service
Provider
User
High-volume egress traffic
CDN Interconnect
Frequent content updates
CDN Interconnect
Ser vice Providers
Cloud
Interconnect Google Cloud
ISP
On-Premise
Data Center
Direct Peering
Google Cloud
On-Premise
Data Center
“Free”
Direct Peering
No intermediate ASNs - control over paths etc
VPN one VPN gateway, then decrypted by the other VPN gateway
VPN
Cloud - Eliminates the need to configure static routes for VPN tunnels
Project
Load Balancer
User
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
OSI Net work Stack
User
Physical Layer
OSI Net work Stack
User
Physical Layer
- HTTP, HTTPS health checks: If your traffic is HTTP(S), then HTTP(S)
health checks provide the highest fidelity check because they verify that the
web server is up and serving traffic, not just that the instance is healthy.
Health - TCP health checks: Configure the SSL health checks if your traffic is not
Checks HTTPS but is encrypted via SSL(TLS)
- SSL (TLS) health checks: For all TCP traffic that is not HTTP(S) or
SSL(TLS), you can configure a TCP health check
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
OSI Net work Stack
User
Physical Layer
HTTP/HTTPS Load Balancing
Step 1: A global forwarding rule directs incoming requests to a target HTTP proxy
HTTP/HTTPS Load Balancing
Step 2: The target HTTP proxy checks each request against a URL map to determine
the appropriate backend service for the request
HTTP/HTTPS Load Balancing
Step 3: The backend service directs each request to an appropriate backend based on
serving capacity, zone, and instance health of its attached backends
HTTP/HTTPS Load Balancing
Step 3: (The health of each backend instance is verified using either an HTTP health
check or an HTTPS health check - if HTTPS, request is encrypted)
HTTP/HTTPS Load Balancing
Actual request distribution can happen based on either balancing RPS (requests-per-
second) or CPU utilisation - your choice
HTTP/HTTPS Load Balancing
HTTPS load balancing has a signed SSL certificate for load balancer
HTTP/HTTPS Load Balancing
BTW, must create firewall rules to allow requests from load balancer and health checker
to get through to the instances
HTTP/HTTPS Load Balancing
Session affinity: All requests from same client to same server based on either
- client IP
- cookie
HTTP/HTTPS Load Balancing
Cross-Regional Content-based
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
OSI Net work Stack
User
Physical Layer
OSI Net work Stack
User
SSL operates in
Presentation Layer
Physical Layer
- Remember the OSI network layer stack: physical, data link, network,
transport, session, presentation, application?
SSL Proxy Load - The usual combination is TCP/IP: network = IP, transport = TCP,
Balancing application = HTTP
- For secure traffic: add session layer = SSL (secure socket layer), and
application layer = HTTPS
- Use only for non-HTTP(S) SSL traffic
SSL Proxy Load - For HTTP(S), just use HTTP(S) load balancing
Balancing
- SSL connections are terminated at the global layer then proxied to the
closest available instance group
SSL Proxy Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
OSI Net work Stack
User
Physical Layer
OSI Net work Stack
User
Physical Layer
- Perform load balancing based on transport layer (TCP)
TCP Proxy Load - Allows you to use a single IP address for all users around the world.
Balancing
- Automatically routes traffic to the instances that are closest to the user.
- Advantage of transport layer load balancing:
- more intelligent routing possible than with network layer load
TCP Proxy Load balancing
Balancing - better security - TCP vulnerabilities can be patched at the load
balancer
- Do NOT use for HTTP(S)
TCP Proxy Load
Balancing - Use for specific ports only
- 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995
SSL Proxy Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
OSI Net work Stack
User
Physical Layer
OSI Net work Stack
User
Physical Layer
- Based on incoming IP protocol data, such as address, port, and protocol
type
Net work Load - Pass-through load balancer - does not proxy connections from clients
Balancing
- Use it to load balance UDP traffic, and TCP and SSL traffic on ports that
are not supported by the SSL proxy and TCP proxy load balancers
- Picks an instance based on a hash of the source IP and port, destination
IP and port, and protocol
- This means that incoming TCP connections are spread across instances
and each new connection may go to a different instance.
Load Balancing
Algorithm - Regardless of the session affinity setting, all packets for a connection are
directed to the chosen instance until the connection is closed and have no
impact on load balancing decisions for new incoming connections
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
Load Balancing
External Internal
Regional
Regional
Global
Network
TCP
HTTP/ SSL
Proxy
HTTPS Proxy
External Load Balancing
Google Cloud
Load Balancer
User
Internal Load Balancing
Project
VPC #1 Subnet 2
Subnet 1
Private IP addresses
- So that your own instances don’t need to use external IP addresses to
take advantage of load balancing
Internal Load - Private load balancing IP address that only your VPC instances can
Balancing access
Load Balancing - Hash based on 3-tuple (Client IP, Dest IP, Protocol)
Algorithm
- Hash based on 2-tuple (Client IP, Dest IP)
- HTTP, HTTPS health checks: If your traffic is HTTP(S), then HTTP(S)
health checks provide the highest fidelity check because they verify that the
web server is up and serving traffic, not just that the instance is healthy.
Health - TCP health checks: Configure the SSL health checks if your traffic is not
Checks HTTPS but is encrypted via SSL(TLS)
- SSL (TLS) health checks: For all TCP traffic that is not HTTP(S) or
SSL(TLS), you can configure a TCP health check
- Configure an internal IP on a load balancing device or instance(s) and your
client instance connects to this IP
A Stackdriver account holds monitoring and other configuration information for a group of
GCP projects and AWS accounts that are monitored together
Types of Monitored
Projects
- …
- Lots of options
- Email
- Phone
Alerts and - SMS
Notifications - Slack
- WebHooks
- …
- (depends on service tier)
- StackDriver error reporting works on
- AppEngine Standard Environment - log entries with a stack trace
and severity of ERROR or higher automatically show up
Trace - how long it takes to complete operations like RPC calls performed when
handling the requests
- round-trip RPC calls to App Engine services like Datastore, URL Fetch,
and Memcache.
Stackdriver Logging
- Stackdriver Logging includes storage for logs, a user interface (the Logs
Viewer), and an API to manage logs programmatically
Types of - Data access logs: API calls that create modify or read user-provided data
Logs - Admin activity logs are always on; data access logs need to be enabled
(can be big)
Using Logs - Exporting to sinks: Cloud Storage, BigQuery datasets, Pub/Sub topics
End-User Service
Accounts Accounts
Identity and Security
Authentication Who are Authorization What can
you? you do?
End-User Service
Accounts Accounts
- Most flexible and widely supported authentication method
Different GCP APIs support different credential types, but all GCP APIs
Ser vice -
- So, any project user gets access to all required resources at one go
Why use
them? - Btw, can also assign roles to service accounts
- Create from
- GCP Console
Application - Programmatically
End-User Service
Accounts Accounts
Identity and Security
Authentication Who are Authorization What can
you? you do?
End-User Service
Accounts Accounts
- Use service accounts wherever possible
End-user
Authentication - In certain specific cases however, end-user authentication its
unavoidable
- You need to access resources on behalf of an end user of
your application
- For example, your application needs to access Google
BigQuery datasets that belong to users of your
End-user application.
- You need to authenticate as yourself (not as your
Authentication
application)
- For example, because the Cloud Resource Manager API
can create and manage projects owned by a specific
user, you would need to authenticate as a user to create
projects on their behalf.
- User navigates to quora.com
“Sign in to Quora
using Google” - Quora presents Google sign-in screen to user; user signs in
“Access API via - Resource server: Project granting access to your account
GCP Project”
- Client: Project talking to API manager
End-User Service
Accounts Accounts
Identity and Security
Authentication Who are Authorization What can
you? you do?
End-User Service
Accounts Accounts
- Simple encrypted string
API Keys - Can be used when calling certain APIs that don't need to
access private user data
- Useful in clients such as browser and mobile applications that
don't have a backend server
API Keys
- The API key is used to track API requests associated with
your project for quota and billing.
- GCP Console => API Manager => Credentials => Create
Creation
- Select “API Key”
- Can be used by anyone - Man-in-the-Middle
Beware
- Do not identify user or application making request
- Used by a small number of GCP APIs
- Natural language processing
- Translation
ML APIs -
-
Speech
Vision
End-User Service
Accounts Accounts
Identity and Security
Authentication Who are Authorization What can
you? you do?
End-User Service
Accounts Accounts
Identity and Access Management (IAM)
Identity and Access Management (IAM)
Identities
- End-user (Google) account
- Service account
- Google group
- G-Suite domain
- Cloud Identity domain
- allUsers, allAuthenticatedUsers
Identity and Access Management (IAM)
Roles
- lots of granular roles
- per resource
Identity and Access Management (IAM)
Resources
- Projects
- Compute Engine instances
- Cloud Storage buckets
- …
Identity and Access Management (IAM)
Policy
- Associate identities with roles
Resource Hierarchy
- Organization >> project >> resource
End-User Service
Accounts Accounts
Identity and Security
Authentication Who are Authorization What can
you? you do?
- Identity-Aware Proxy (IAP) is an HTTPS-based, i.e. web-
based, way to combine all of this Identity and Access
Critical to API Keys
Standard flow
Management
get it right Not critical
(Cloud IAM)
to get it right
End-User Service
Accounts Accounts
- IAP acts as an additional safeguard on a particular resource
- Output
- Output
Redaction
- Input
- Output
- ML-based:
- Contextual Analysis
- Pattern Matching
Wow. How?
- Rule-based:
- Checksum
- Word and phrase list
Deployment Manager
https://cloud.google.com/dlp/docs/
- It describes all the resources you want for a single
deployment and this file written in YAML syntax.
- This lists each of the resources you want to create and it's
respective resource properties.
- A configuration must contain a resource. Resource must
Configuration
contain three components :-
- a)Name-user-defined string for identification.
b)Type-Type of resource being deployed
c)Properties-Parameters of the resource type
- Parts of the configuration and abstracted into individual
building blocks. This file is written in python or jinja2.
Access control for - The Google APIs service account is automatically granted
Deployment Manager editor permissions on the project.
CryptoKey and
- If Primary CryptoKeyVersion is enabled, Then only
CryptoKeyVersion
states CryptoKey to encrypt the data.
cloud KMS
- Each Crypto key version rotated to primary key, at the point
to encrypt the data .
- Regular rotation and Irregular rotation are the two rotations
of Encryption keys.
Frequency of
- Regular rotation take the time for data encrypted with single
key rotation
key.
rotation
- Rotation schedule is scheduled by rotation period and next
rotation time.
- Used for irregular key rotation
-
Separation of duties
- The user and owner can access and manage the project at
the time of run.
Setting up Cloud KMS a)Create the key project without an owner-recommended.
in separate project
b) Grant an owner role for your key project-Not
recommended.
- In smaller organisation-Owner,editor and viewer provide
sufficient granularity for key management.
Choosing a secret - Rotating secrets, Cache secrets locally and using a separate
management solution
solution or problem are some of the changing secrets.
- Configure firewall rules to allow SSH traffic to private instances from only the bastion host.