Google Container Driver Documentation

Google Container Platform is a Kubernetes hosting service, provided by Google. Docker-native tools and elastic hosts make deploying on Google Cloud as easy as running Docker on your laptop. There is no special software to install or configure. Mix Kubernetes containers with container-native Linux to extend the benefits of containerization to legacy applications and stateful services.


Additional example code can be found in the “demos” directory of Libcloud here:

1. Getting Driver with Service Account authentication

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

ComputeEngine = get_driver(Provider.GCE)
# Note that the 'PEM file' argument can either be the JSON format or
# the P12 format.
driver = ComputeEngine('your_service_account_email', 'path_to_pem_file',

API Docs

class libcloud.container.drivers.gke.GKEContainerDriver(user_id, key=None, datacenter=None, project=None, auth_type=None, scopes=None, credential_file=None, host=None, port=443, **kwargs)[source]

GKE Container Driver class.

This is the primary driver for interacting with Google Container Engine. It contains all of the standard libcloud methods, plus additional ex_* methods for more features.

Note that many methods allow either objects or strings (or lists of objects/strings). In most cases, passing strings instead of objects will result in additional GKE API calls.

  • user_id (str) – The email address (for service accounts) or Client ID (for installed apps) to be used for authentication.
  • key (str) – The RSA Key (for service accounts) or file path containing key or Client Secret (for installed apps) to be used for authentication.
  • datacenter (str) – The name of the datacenter (zone) used for operations.
  • project (str) – Your GKE project name. (required)
  • auth_type (str) – Accepted values are “SA” or “IA” or “GKE” (“Service Account” or “Installed Application” or “GKE” if libcloud is being used on a GKE instance with service account enabled). If not supplied, auth_type will be guessed based on value of user_id or if the code is being executed in a GKE instance.
  • scopes (list) – List of authorization URLs. Default is empty and grants read/write to Compute, Storage, DNS.
  • credential_file (str) – Path to file for caching authentication information used by GKEConnection.

alias of GKEConnection

create_cluster(name, location=None)

Create a container cluster (a namespace)

  • name (str) – The name of the cluster
  • location (ClusterLocation) – The location to create the cluster in
Return type:


deploy_container(name, image, cluster=None, parameters=None, start=True)

Deploy an installed container image. In kubernetes this deploys a single container Pod.

  • name (str) – The name of the new container
  • image (ContainerImage) – The container image to deploy
  • cluster (ContainerCluster) – The cluster to deploy to, None is default
  • parameters (str) – Container Image parameters
  • start (bool) – Start the container on deployment
Return type:



Delete a cluster (namespace)

Returns:True if the destroy was successful, otherwise False.
Return type:bool

Destroy a deployed container. Because the containers are single container pods, this will delete the pod.

Parameters:container (Container) – The container to destroy
Return type:bool
ex_destroy_pod(namespace, pod_name)

Delete a pod and the containers within it.


List available Pods

Return type:list of KubernetesPod

Get a cluster by ID

Parameters:id (str) – The ID of the cluster to get
Return type:libcloud.container.base.ContainerCluster

Get a container by ID

Parameters:id (str) – The ID of the container to get
Return type:libcloud.container.base.Container

Return configuration info about the Container Engine service.

Parameters:ex_zone (str or GCEZone or NodeLocation or None) – Optional zone name or None

Install a container image from a remote path.

Parameters:path (str) – Path to the container image
Return type:ContainerImage

Return a list of cluster information in the current zone or all zones.

Parameters:ex_zone (str or GCEZone or NodeLocation or None) – Optional zone name or None
list_containers(image=None, all=True)

List the deployed container images

Return type:

list of libcloud.container.base.Container


List the installed container images

Return type:list of ContainerImage

Get a list of potential locations to deploy clusters into

Return type:list of ClusterLocation

Restart a deployed container

Parameters:container (Container) – The container to restart
Return type:Container

Start a deployed container

Parameters:container (Container) – The container to start
Return type:Container

Stop a deployed container

Parameters:container (Container) – The container to stop
Return type:Container