Modernising With GCP: Create A Custom Cloud Shell Image

19 July 2019
Rachel Wood

Our GCP team have got together to help provide insight into how the latest Cloud Shell features within Google Cloud Platform (GCP) can help modernise your business.

 

In today’s economic climate, many businesses are often faced with a harsh choice – either move with the times or be overtaken by those embracing new technologies, to grow their business. Companies need to be agile and modernise their business to gain a competitive advantage and maximise their future success in the marketplace.

Technology changes at a rapid pace and businesses should fully understand their digital assets, whether they’re fit for purpose and subsequently update their IT infrastructure, applications and processes to realise the benefits new innovations can offer. 

Why choose Google Cloud Platform?

Many businesses opt for Google Cloud Platform (GCP) due to the ability to build, deploy and scale applications, websites and services to suit their business needs. Indeed, the key to business success is the ability to quickly adapt to changing market conditions or customer trends, and GCP provides this flexibility. 

GCP offers a range of benefits for organisations looking to modernise their business: 

  • Scalability – ideal for growing businesses or those with changing demands.
  • Reliability – provides best-in-class infrastructure supported by Google’s own network.
  • Flexibility – works with a managed application platform, leverages container technologies and provides the ability to build your own cloud-based infrastructure.
  • Security – provides complete control and full visibility of resources.
  • Cost effectiveness – offers a variety of cost options with no long term commitments, upfront payments or capital expenditure.

New Cloud Shell features

Our team regularly use Cloud Shell to efficiently and securely manage our environment directly from the browser. Two new features recently discovered are the ability to use Terraform for infrastructure provisioning and Helm, the Kubernetes package manager, enabling to easily package, configure and deploy applications and services onto Kubernetes clusters.

Here are the few simple steps on how to create a customer Docker image for Cloud Shell that includes the Helm client and Terraform.

 

1. Create and publish a custom Cloud Shell Docker image

The first step is to create a new Docker image that’s based on the default Cloud Shell image and then publish the image you created to the Container Registry.

  • Create a new repo and set the project ID where the Docker image should be published:

  mkdir gcp-cloud-shell-custom-image

cd gcp-cloud-shell-custom-image

GCP_PROJECT_ID=your-project-ID

 

  • With your file editor of choice, create a file named Dockerfile with the following content:

  FROM gcr.io/cloudshell-images/cloudshell:latest

ENV TERRAFORM_VERSION=”0.11.10″ \

    HELM_VERSION=”v2.14.0″

WORKDIR /tmp

RUN curl https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip > terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \

    unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /bin && \

    wget -q https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz -O – | tar -xzO linux-amd64/helm > /usr/local/bin/helm && \

    chmod +x /usr/local/bin/helm && \

    rm -f terraform_${TERRAFORM_VERSION}_linux_amd64.zip

 

  • Build the Docker image:

  docker build -t gcr.io/$GCP_PROJECT_ID/cloud-shell-image .

 

  • Push the Docker image to the Container Registry:

  docker push gcr.io/$GCP_PROJECT_ID/cloud-shell-image:latest

Note: You will need to configure Docker to authenticate with gcr by following these steps.

 

2. Configure the Cloud Shell image to use the published image

Once you’ve created and published your image, you need to configure the Cloud Shell Environment to use the image that was published to the Container Registry. To do this, go into the Cloud Console and complete the following steps:

  • Go to Cloud Shell Environment settings.  
  • Click Edit.
  • Click “Select image from project”.
  • In the Image URL field enter: gcr.io/$GCP_PROJECT_ID/cloud-shell-image:latest
  • Click “Save” then open a new Cloud Shell session and you should see that the new custom image is used.

 

Speak to our team of cloud experts for all the latest information on Cloud Shell and GCP DevOps hints and tips to help modernise your business today on 0161 871 0330.

Related Posts

Copyright © 2019 Cloud Technology Solutions. All Rights Reserved.