Man holding a gift on cloudy sky background

$300 free trial. How to use it wisely ?

$300 free trial gift from Google

Google-man hands you a wrapped gift $300 free trial

Google has done something awesome. They’ve presented us with a gift that will surely win them some developer love.


You get $300 free credit over 12 months period to get started with any Google Cloud Platform product


That was a smart move on their part. If you get a developer excited about something then often it spreads to his whole team like a virus. $300 bucks for free in cloud services is pretty exciting to all the coders out there who wanted to “touch” the cloud but never had the chance. I have to say that Google Cloud Platform is a great place to start your adventure with cloud development.

Additionally there are some services that are always free. For example they’ve allowed for free usage of a small (f1-micro) instance in Compute Engine (if you create them in us-east1, us-west1 and us-central1 regions). You can check what else is free. You can also take a look at what is always-free if you don’t exceed some quotas.

Why cloud platform providers give us free stuff ?

I don’t usually like to look a gifted horse in the mouth but there is always a catch when companies like Amazon or Google give you something for “free”. You get so many free services that it is easy to get yourself attached to one cloud platform provider. You need to decide what to use and what not to use in your applications. From time to time ask yourself following questions:

If I decide to switch cloud providers will I be able to ?

Can I transfer all my services and data without a hassle and loss/degradation of functionality ?

Cloud platform agnostic approach using Kubernetes

You probably don’t want to get too tightly coupled with a specific platform early on. A wise thing to do is plan cloud platform agnostic approach to your apps’ deployment. My advice is to use this opportunity to learn something interesting about containerized applications creation and deployment in the cloud. At the first glance the subject seems a bit complicated but this is where Kubernetes comes in.

Kubernetes logoKubernetes just makes everything simple. This solution also eliminates the need to care about some of the convoluted and time consuming things. Things that are not always easy to set up properly eg. networking . If you are a developer then you will probably love it. When you use Kubernetes everything just auto-magically works (most of the time 🙂 ).

Strictly speaking in IT jargon, Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications. You can learn more about Kubernetes here.

Kubernetes also runs on Amazon Web Services, Microsoft Azure, IBM Bluemix and many more.

Start your adventure with Google Cloud and Kubernetes now !

Register for the free trial

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

Click here and go to GCP free tier Registration page

I believe that you are capable of registering for a service on your own and you don't need a bunch of stupid screenshots to guide you. You will need a credit card number to finish the registration. Nothing is charged to your credit card until you enable billing and you never actually have to do that if you don't want to. If you run out of free tier gift money with no billing enabled then your resources will be stopped. You can learn more about the end of free trial here.

Install gcloud and kubectl tools

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

Install Google Cloud SDK -

Install and set up kubectl -

Remember to add following line to the end of ~/.bashrc for kubectl autocompletion

source <(kubectl completion bash)

Both of those tools have an extremely handy autocomplete feature. Double-tap TAB key to autocomplete not only commands but also names of the resources and objects.

Create a one node cluster

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

I will use names example and everywhere. Just replace them with the name of your choice.

You can manage your Google Cloud using a Console available at:
Go there and create a project first. Choose a general name for your project. Keep in mind that you can manage multiple applications using one project.

Next use gcloud tool to create a new cluster in a compute zone that is the best fit for you.

To list all available zones use

gcloud compute zones list

Project name: example
Compute zone: europe-west1-d (choose your own compute zone)
Cluster name: my-cluster
Instance type: g1-small

gcloud config set project example
gcloud config set compute/zone europe-west1-d
gcloud container clusters create my-cluster --num-nodes 1 --machine-type g1-small
gcloud container clusters get-credentials my-cluster --zone europe-west1-d --project example

Add Service Account for your application

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

You need to create Service Account first.

Go to Google Cloud Platform ConsoleAPI ManagerCredentials

Click Create credentials button and choose Service account key

Choose Compute Engine default service account and JSON

Save the JSON file in your home directory

Add following line to your ~/.bashrc. Modify USERNAME and FILENAME accordingly


Open new terminal or run following command to apply the changes you've made to ~/.bashrc

source ~/.bashrc

Run following commands. First one will log you in so that you can finally manage your cluster. Second one will print some information about your cluster

gcloud auth application-default login
kubectl cluster-info

Command below makes your cluster's Kubernetes UI available under http://localhost:8001/ui

kubectl proxy &

Create Google Cloud Engine Persistent Disk

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

You will need a persistent storage for your application. Kubernetes gives you the ability to hook up a lot of different storage options but for this tutorial you will use Google Cloud Engine's Persistent Disk.

First of all you need to create a Persistent Disk. You can either do it using Google Cloud Platform Console or command line. If you wish to create disk that has size lower than 10GB then you need to use command line.

Create persistent disk using Google Cloud Platform Console

Go to Google Cloud Platform ConsoleCompute EngineDisks

At the top of the page click Create disk

Now under Source type you have to click None (blank disk) tab and set the size you want your disk to have

Disk Type: Standard persistent disk (cheaper option)

Enter zone, name and other parameters according to your needs

Create persistent disk using the command line

If you do not wish to continue with the Kubernetes tutorial then substitute PROJECT_NAME-wordpress with the name you want for your disk. Otherwise you should create two disks. One for WordPress with name matching the pattern PROJECT_NAME-wordpress and one for MySQL named: wordpress-mysql

gcloud compute --project "PROJECT_NAME" disks create "PROJECT_NAME-wordpress" --zone "ZONE_NAME" --size=5GB

Add persistent disk to your instance and format it

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

Don't get scared. Adding Persistent Disk to your instance is a piece of cake. Just a few clicks in Google Cloud Platform Console and a few commands to run. If you wish to continue with Kubernetes tutorial then keep in mind that both drives you've created need to be formatted.
Follow this tutorial but do not mount the disk to the instance and do not add anything to /etc/fstab. Last step you should do is formatting the drive.

Adding a persistent disk to your instance -

Formatting a persistent disk -

In addition now you also know how to connect to the VM instance inside your cluster should you ever need it.

Detach persistent disk from VM instance

Reliability: MediumUpdated: 28 September 2017CopiedBookmarkedBookmark removed

gcloud compute instances detach-disk VM_INSTANCE_NAME --disk DISK_NAME

Detaching disks is especially important if you wish to continue with Kubernetes tutorial.

Let's restart the VM instance. This is done just to make sure that the problem described in the notes to this step does not occur.

gcloud compute instances start VM_INSTANCE_NAME

Step notes

I do not like the fact that detaching disks can cause the problem described below. I've decreased the reliability of this step to Medium as a result. Last checked on Kubernetes ver. 1.6.4

VM instance attached disk and Kubernetes problem description

You will not be able to use your disk with Kubernetes if you do not detach your disks. Your Persistent Volumes will not be able to bind to disk that is already attached to a VM instance.
If you still get errors similar to the ones below then you probably need to restart the VM instance.

When you describe your Pod

Output: mount: cannot remount /var/lib/kubelet/plugins/ read-write, is write-protected

When you look at your VM instance's logs

Orphaned pod "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX" found, but volume paths are still present on disk.

Two times that I have been formatting disks using Google's own tutorial I had that situation so I guess you might encounter it as well.

Restarting the VM instance seems to be the most simple solution to fix the problem. Instead of restarting the instance you can kill two birds with one stone and update your cluster's Kubernetes if you have an update available. You can also format the drives on some other instance and avoid the problem altogether.

Enable Google Cloud Logging - Basic Tier(Optional)

Reliability: HighUpdated: 28 September 2017CopiedBookmarkedBookmark removed

Basic Tier of logging service is free if your monthly logs never exceed 5GB OR you do not agree to pay overage charges ever.

Run command below and go to your cluster's Kubernetes UI at http://localhost:8001/ui

kubectl proxy &

Select All namespaces. Take a look at the logs of the Pod named fluentd-cloud-logging-gke-XXXXXXXXXX
You might see a warning like that:

[warn]: Dropping 2 log message(s) error_class="Google::Apis::ClientError" error="forbidden: 
Stackdriver Logging API has not been used in project PROJECT_NAME before or it is disabled. 
Enable it by visiting
then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our 
systems and retry.

Stackdriver's Basic Tier no cost usage details

Before you enable it, check current information on what is billable and what is free in Stackdriver's Basic Tier. You do not want to find something out at the very moment the invoice arrives. Especially take notice of overage charges.
Overage charges apply when you exceed the limit. On the day that I published this for Premium Tier accounts, overage charges are billed automatically but in Basic Tier you must sign up to pay overage charges. As always there is a catch. If you want to use logs-based or custom metrics in the Basic Tier, you must agree to pay overage charges. If you never agree to it then after exceeding 5GB logs are no longer gathered until you get another 5GB of quota.

Stackdriver pricing in details -

Since Basic Tier of Stackdriver is free plus you get 30 day trial of Premium Tier let's turn it on and check it out.
If you don't like it I guess you can always disable it in Google Cloud Platform ConsoleAPI ManagerDashboard.
According to Stackdriver pricing page, start of billing occurs only after free trial expires. You can choose to use Basic Tier at that moment.

Enable Stackdriver Logging

First you need to enable the Stackdriver API.

You can use the link from the warning message. Alternatively you can go to Google Cloud Platform ConsoleAPI ManagerLibrary and search for stackdriver.

Enable Stackdriver Logging API.
As it says in the warning message, you might need to wait a few minutes before the changes propagate.

Go to Google Cloud Platform ConsoleLogging

All the logs are in one place now. You can use filters to go through them. For example using the first selectbox choose GKE containermy-clusterkube-system to see logs from resources in one namespace only.

Basic Tier allows 50GB to use monthly per project without additional charges. You can check you usage and estimated monthly usage under Google Cloud Platform ConsoleLoggingResource usage

Go to Google Cloud Platform ConsoleAPI ManagerDashboard. You should see that Stackdriver Logging API is in use.

You can do much more with your logs using Stackdriver. For more information on it check out

Stackdriver Monitoring Documentation -

Good job. You deserve a bottle of Grog. Arrrr !
Success ! Let's open a case of Rum. Arrrr !
New skills gained. Beers all around! Arrrr !
Thanks for reading ! Please
  • 1

Leave a comment

Your email address will not be published. Required fields are marked *