This is a simple probe for measuring sources of HTTP connection latency, including DNS lookup, TLS handshake, connection establishment, and data transfer.
Enable the Stackdriver and Kubernetes Engine APIs in the Cloud Console. You will need to enable Stackdriver premium for use of custom metrics.
Export the name of your project and zone to the shell environment
export PROJECT_ID=[YOUR PROJECT ID]
gcloud config set project $PROJECT_ID
ZONE=us-west1-a
gcloud config set compute/zone $ZONE
Create a service account in the console and download the key json file into the directory that you run these commands from. Assign the service account role Project > Owner when you create it.
export GOOGLE_APPLICATION_CREDENTIALS=???.json
Export a shell variable set to the target URL you want your probe to send requests to:
export TARGET_URL=http://[YOUR URL]
Define the Stackdriver custom metric:
docker build -f Dockerfile-setup -t setup_sd .
docker run -it --env PROJECT_ID=$PROJECT_ID \
--env GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
setup_sd
Build and deploy the probe in a Docker container:
docker build -f Dockerfile-httpprobe -t httpprobe .
docker run -it --env PROJECT_ID=$PROJECT_ID \
--env GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
--env TARGET_URL=$TARGET_URL \
httpprobe
Uploading to the Google Container Rep
gcloud auth configure-docker
TAG=v1
docker tag httpprobe gcr.io/$PROJECT_ID/httpprobe:$TAG
docker push gcr.io/$PROJECT_ID/httpprobe:$TAG
Start up a GKE cluster:
gcloud components install kubectl
gcloud config set project $PROJECT_ID
#ZONE=europe-west4-a
ZONE=us-west1-a
gcloud config set compute/zone $ZONE
CLUSTER_NAME=httpprobe-$ZONE
gcloud container clusters create $CLUSTER_NAME --zone $ZONE --num-nodes 1
gcloud container clusters get-credentials $CLUSTER_NAME
Deploy the probe to the cluster
kubectl run httpprobe --image gcr.io/$PROJECT_ID/httpprobe:$TAG \
--env="PROJECT_ID=$PROJECT_ID" \
--env "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" \
--env TARGET_URL=$TARGET_URL
Apache 2.0. Copyright 2018 Google. All rights reserved.