Running Hubot on GKE + Kubernetes Within the Free Tier — Running from the CLI
Overview
- We’ll build a Slack-integrated Hubot on GKE using the free tier.
- As a bonus, we’ll also add JIRA integration.
Installing and Initializing the Google Cloud SDK
Download the SDK by referring to the Quickstart for macOS.
- Check whether you’re on Mac OS X (x86_64) or (x86) with the following command:
1 | macOS%$ uname -m |
Installing kubectl
1 | macOS%$ gcloud components update kubectl |
gcloud Default Configuration
Below, we configure the project, region, and zone we created.
This means you won’t have to specify the region and so on each time you run a gcloud command from now on.
- Created project ID:
hubot-167007 - We set the region to a US region so we can use the free tier with us-west.
1 | macOS%$ gcloud auth login |
Please refer to the Google Cloud Platform Free Tier.
Creating the Cluster
- To use the free tier, we set f1-micro with 30GB.
- However, 3 nodes are required at creation time.
- After creation completes, we resize down to 1 node.
1 | macOS%$ gcloud container clusters create hubot-cluster-free \ |
- Looking at the console, you can confirm that it’s being created.

- You can verify it with the following command:
1 | macOS% $ kubectl get nodes |
- Resize down to 1 node
1 | macOS%$ gcloud container clusters resize hubot-cluster-free --size=1 |

If we can resize it, I wish they’d just let us create it with 1 node from the start (>_<)
Doing it from the console still doesn’t work, after all (T_T)

Obtaining Credentials
- Obtain the container cluster’s credentials so you can use kubectl to create containers on the container cluster.
1 | macOS%$ gcloud container clusters get-credentials hubot-cluster-free |
- Display container cluster information
1 | macOS%$ gcloud container clusters describe hubot-cluster-free |
Starting Docker Locally
[https://github.com/kenzo0107/hubot-slack-on-docker:embed:cite]
1 | macOS%$ git clone https://github.com/kenzo0107/hubot-slack-on-docker |
1 | macOS%$ docker ps |
Verifying Hubot Works
If Hubot shows up in Slack and replies with Hi when you say hello to it, you’ve succeeded.
Committing an Image from the CONTAINER ID
1 | macOS%$ docker commit 12f77feb09b4 gcr.io/hubot-167007/hubot:latest |
Pushing to the GKE Registry
Reference: Pushing to Container Registry
1 | macOS%$ gcloud docker -- push gcr.io/hubot-167007/hubot:latest |
- If the
latesttag collides, the tag of the previous image gets taken away. It’s a waste of storage, so delete it.

Creating the Deployment
1 | macOS%$ kubectl run pod-hubot \ |
- Check the deployments status
1 | macOS%$ kubectl get deployments |
- Check the Pod status
1 | macOS%$ kubectl get pods |
- Log in to the Pod
1 | $ kubectl exec -it pod-hubot-1713414922-b2dkq /bin/bash |
- Check the service status
1 | macOS%$ kubectl get service |
EXTERNAL-IP: <none> … this means there’s no IP open to the outside.
A Private IP has been assigned, but there’s no Public IP, so it can’t be accessed from external networks.
Exposing the Container
- Attach a load balancer to the Service to expose it.
- Note: adding a load balancer makes the billing jump by an order of magnitude.
(Around 2,000 yen/month. Just to be safe, I found out via the budget alert I had set up.)
1 | macOS%$ kubectl expose deployment pod-hubot --type="LoadBalancer" |
- Check the Service
It shows EXTERNAL-IP: <pending>, which tells us it’s still being created.
1 | macOS%$ kubectl get service |
- Check the Service again
We can see it has been successfully assigned.
1 | macOS%$ kubectl get service |
Testing
1 | macOS%$ curl \ |

Cleanup
Run the following if you want to clean things up.
- Delete the service
1 | macOS%$ kubectl delete service pod-hubot |
- Delete the pod
1 | macOS%$ kubectl delete pod pod-hubot-729436916-htw3r |
- Delete the deployments
1 | macOS%$ kubectl delete deployments pod-hubot |
- Delete the container clusters
If you delete the container cluster, the deployments, service, and pod associated with it are also deleted.
1 | macOS%$ gcloud container clusters delete hubot-cluster-free |
That’s all.
Overall Impressions
GKE has a lot of concepts, and there’s plenty to learn all at once — deployment, pod, service, kubernetes, and so on — but it’s fun to learn while actually running things.
I was able to set up almost everything on my Mac at hand!
Since it can all be done locally, macOS%$ wasn’t really necessary…
The service we created this time leaves port 8080 wide open to the outside.
Next time, I’ll cover restricting the source of access for port access and updating containers.
[http://kenzo0107.hatenablog.com/entry/2017/05/16/222815:embed:cite]
Running Hubot on GKE + Kubernetes Within the Free Tier — Running from the CLI
https://kenzo0107.github.io/en/2017/05/10/gke-kubernetes-hubot-cli/
