Fetch all Pod (labled backend
) logs with severity error from StackDriver (parsing with jq
)
gcloud logging read "resource.labels.pod_id:backend AND severity:ERROR" --order asc --format json | jq '.[].textPayload'
gcloud compute instances stop $(gcloud compute instances list | grep -v "NAME" | awk '{ print $1}')
gcloud compute instances start --async $(gcloud compute instances list | grep -v NAME | awk '{ print $1 }')
Manually create a network (--subnet-mode custom
)
gcloud compute networks create k8s --subnet-mode custom
Create a subnet within a network
gcloud compute networks subnets create k8s-nodes --network k8s --range 10.0.0.0/24
Change configuration settings, set project for gcloud
gcloud config set core/project cka-exam-prep
Add firewall allowing internal traffic between components and pod networks
gcloud compute firewall-rules create k8s-cluster-fw --network k8s --allow tcp,udp,icmp --source-ranges 10.0.0.0/24,10.100.0.0/16
Add firewall allowing external traffic to the network (port 6443 are used by API server TLS)
gcloud compute firewall-rules create k8s-allow-external \
--allow tcp:22,tcp:6443,icmp \
--network k8s \
--source-ranges 0.0.0.0/0
List all firewall rules filtering on a specific network
gcloud compute firewall-rules list --filter="network:k8s"
Allocate a external IP address
gcloud compute addresses create k8s-external --region $(gcloud config get-value compute/region)
List allocated external IP addresses
gcloud compute addresses list
NAME REGION ADDRESS STATUS
k8s-external europe-west1 1.2.3.4 RESERVED
Query the metadata server from within a compute instance and fetch it's IP address
curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip