Architecture & DesignUsing the Google Container Engine on the Google Cloud Platform

Using the Google Container Engine on the Google Cloud Platform

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

The Google Container Engine is based on Kubernetes and is also a cluster manager for Docker containers. Unlike Kubernetes, Google Container Engine is not open source, but provides the same features as Kubernetes, such as scheduling Docker containers in a cluster and subsequently managing them automatically based on resources (CPU and memory) requirements. In this article, you will see how to set up the Google Container Engine so that you can use it to run Jenkins. This article has the following sections:

In a follow-up article, I’ll show you how to then use Jenkins within the Google Container Engine on the Google Cloud Platform.

Getting Started with the Google Container Engine

To start using Google Container Engine, you first need to create a Google Cloud Platform account. You can set up a free trial account.

To use the Google Cloud Platform APIs you will need to set up a billing account. You can do this by selecting “Billing” from the navigation within the Google Cloud Platform Console, as shown in Figure 1.

Selecting Billing in Google Cloud Platform Console
Figure 1: Selecting Billing in Google Cloud Platform Console

You should verify that the status of your account, new or old, is Active, as shown in Figure 2.

Google Cloud Platform Billing Account should be Active
Figure 2: Google Cloud Platform Billing Account should be Active

Creating a Google Cloud Platform Project

Once you have an account, you can create a project. Start a new project by navigating to a http://console.cloud.google.com/start. A new project is created with the New Project wizard or dialog. Two options are available to start the New Project wizard:

  • Click Create an Empty Projectin the Getting Started page, as shown in Figure 3.

    Create an empty project
    Figure 3: Create an empty project

  • Click Select a project in the Getting Started page, as shown in Figure 4.

    Select a project
    Figure 4: Select a project

The Select dialog gets displayed (see Figure 5).

Select
Figure 5: Select

Click the Create Project button (+), as shown in Figure 6.

Create Project

Figure 6: Create Project

Using either of the options (Create an empty project or Select a project) should launch the New Project wizard. Specify a Project name (Jenkins-GKE) and click Create, as shown in Figure 7.

New Project>Create
Figure 7: New Project>Create

A new project gets created and the project info gets displayed in the Dashboard, as shown in Figure 8. Click Go to project settings, as shown in Figure 8, to display the project settings.

Project Info for Jenkins-GKE
Figure 8: Project Info for Jenkins-GKE

The project settings get displayed, as shown in Figure 9.

Project Settings for Jenkins-GKE
Figure 9: Project Settings for Jenkins-GKE

Once a project has been created, the Select a project dialog lists the project (see Figure 10). Select the project and click Open to display the project info shown in Figure 10.

Selecting a Project
Figure 10: Selecting a Project

To display the project permissions, click IAM & Admin, as shown in Figure 11.

IAM & Admin
Figure 11: IAM & Admin

The Permissions for the project get displayed, as shown in Figure 12. The default settings should suffice for most projects.

Project Permissions
Figure 12: Project Permissions

Enabling APIs

To use Google Container Engine, two APIs need to be enabled: Google Compute Engine and Google Container Engine. By default, these APIs are not enabled. To enable the APIs, select API Manager>Dashboard, as shown in Figure 13.

API Manager>Dashboard
Figure 13: API Manager>Dashboard

The APIs listed in the Dashboard may be enabled with Enable API, as shown in Figure 14. The APIs we need to enable, Google Compute Engine and Google Container Engine, are not listed by default when a new project is created.

Enable API
Figure 14: Enable API

Navigate to the URL https://console.cloud.google.com/apis/ for APIs, which shall redirect to the Project URL for the APIs https://console.cloud.google.com/apis/library?project=jenkins-gke or similar. From the Google Cloud APIs, select the Compute Engine API link (see Figure 15).

Selecting Compute Engine API
Figure 15: Selecting Compute Engine API

Click ENABLE, as shown in Figure 16.

Google Compute Engine API>Enable
Figure 16: Google Compute Engine API>Enable

The “ENABLING” message should get displayed, as shown in Figure 17.

Enabling Google Compute Engine API
Figure 17: Enabling Google Compute Engine API

When the API has been enabled, the DISABLE link should get displayed, as shown in Figure 18.

Disable option for Google Compute Engine API
Figure 18: Disable option for Google Compute Engine API

Navigate back to the Library of APIs page and select the Container Engine API link, as shown in Figure 19.

Selecting Container Engine API
Figure 19: Selecting Container Engine API

Click ENABLE (see Figure 20).

Google Container Engine API>Enable
Figure 20: Google Container Engine API>Enable

The “ENABLING” message should get displayed, as shown in Figure 21.

Enabling Google Container Engine API
Figure 21: Enabling Google Container Engine API

Once the API has been enabled, the DISABLE link should get displayed. The Google Container Engine API should get listed as enabled as indicated by the “Disable” link shown in Figure 22. The Google Compute Engine API also should get listed as enabled, as indicated by the “Disable” link.

Google Container Engine API & Google Compute Engine API Enabled
Figure 22: Google Container Engine API & Google Compute Engine API Enabled

Downloading the Sample Applications

First, we need to activate the Google Cloud Shell. Click the Activate Google Cloud Shell button in the Google Cloud Platform Dashboard, as shown in Figure 23.

Activate Google Cloud Shell
Figure 23: Activate Google Cloud Shell

The Google Cloud Shell gets started, as shown in Figure 24.

Google Cloud Shell
Figure 24: Google Cloud Shell

Set the default compute zone to us-east1-d:

gcloud config set compute/zone us-east1-d

The compute zone gets set (see Figure 25).

Setting Compute Zone
Figure 25: Setting Compute Zone

Next, clone the sample application code for the Continuous Deployment on Kubernetes application from the Git.

git clone https://github.com/GoogleCloudPlatform/continuous-deployment-on-kubernetes.git

The code gets cloned, as shown in Figure 26.

Cloning Sample application code
Figure 26: Cloning Sample application code

Change directory (cd) to the application root directory.

cd continuous-deployment-on-kubernetes

The sample application root directory becomes the current directory, as shown in Figure 27.

Setting the current directory
Figure 27: Setting the current directory

Conclusion

In this article, we got started with creating a Google Cloud Platform project and enabling the requisite APIs: Compute engine and Container Engine APIs. Subsequently, we downloaded a sample application which contains the Kubernetes manifests for Jenkins. In the next article of the tutorial, we shall create a Kubernetes cluster and subsequently deploy a Jenkins deployment and create a Jenkins service.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories