The example we will be following is here. Checking this out reveals the following structure:
From a Habitat perspective, the key lines of the
plan.sh are as follows:
This means we depend on the
core/nginx maintained package and don't require any special build or installation setup. This package will export a port which is important for us to see the
index.html page when deployed at a later stage. The configuration directory also includes a simple
Build the Habitat package and create the container image
With Habitat installed locally, let's first trigger a build:
This will create a
hart file in the
results folder according to the origin and package name e.g.
From the Studio or otherwise, now execute the following to create a container image. This is what we will upload to Google Container Registry.
This creates a Docker image with tags e.g.
Push the container image to GCR
The following command ensures we are authorized to push/pull images to Container Registry:
Now we run the following two commands to tag and push our image, note that the repository URI conforms to
[HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG], more details here:
Deploy your application to GKE
With our image in the Container Registry we can deploy the application to Google Kubernetes Engine using the provided manifest:
This also creates a Kubernetes LoadBalancer to expose port
8080 from the container running nginx to a public IP address on port
80. This manifest can now be deployed to GKE:
Navigating to the page we see the expected
In this walkthrough you saw how to push a Habitat managed application to GCR and how to deploy it to GKE. Watch this space, Habitat Builder integration for Google Container Registry is coming soon. Thanks for reading!
- Ask and answer questions on the Habitat forums
- Chat with the Habitat Community on Slack
- Learn more about Habitat