A new Gitpod template for Google Cloud
Tags: gitpod, googlecloud, programming, beginners
Published: 2023-04-12 14:52:06

## 📚 My projects on Google Cloud Platform

Some of my projects are deployed on Google Cloud Platform. Mainly in Java, I deployed a lot of functions on [Cloud function](https://cloud.google.com/functions). This service is so useful for quickly deploying a short function in the cloud. Sometimes I also deploy applications with [App engine](https://cloud.google.com/appengine), it scans your application, detects the language and deploys it without any configuration. Handy for deploying a component without creating and configuring any Docker file. 
Since 2019, another service has been created, its Cloud Run. This serverless platform allows you to deploy containers easily. Before 2022, I only used it for one test.

## 🚀 The discovery of Cloud Seed

In 2022, I discovered [Cloud Seed](https://about.gitlab.com/handbook/engineering/incubation/cloud-seed/), a new GitLab project whose objective is to deploy faster on GCP.  If you don’t know Cloud Seed, I suggest you read my [Cheatsheet](https://dev.to/zenika/gitlab-cheatsheet-14-cloud-seed-3oh7) I created last year.


![Gitpod Cheatsheet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ipnyr346cqu05qaqgu91.png)


I explain this project in the [programmez.com magazine](http://www.programmez.com/magazine/article/cloud-seed-deployer-plus-rapidement-avec-gitlab) (in French) and in a blog post that will be published at the end of April on [Zenika’s blog](https://blog.zenika.com/).

With the Cloud Seed project, I migrated some of my applications to Cloud Run. 

## 🧩 Cloud code, a VsCode extension for GCP

Last year, during an event organized by Zenika and Google, [Julien Landuré](https://twitter.com/jlandure) presented [Cloud Code](https://cloud.google.com/code), a project available as an extension on VsCode and Intellij.

With this one, you can easily see your Cloud Run services, check their configuration and open logs without leaving your IDE. Great!


![Cloud code in VsCode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pkcd6k6pcdx8yiegr357.png)


## 🍑 My daily use with Gitpod

And as you may already know, I often use Gitpod to develop. It's a Cloud Development Environment. I will not explain in this blog post what Gitpod is, I will let you read [this cheatsheet](https://dev.to/zenika/gitpod-cheatsheet-2ek6) and [this video](https://www.youtube.com/watch?v=tLx3D7BRTLI) I made for the Gitpod event in Paris in January.


![Gitpod Cheatsheet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2ufpdbm6amdlhg37c5b.png)
 

## ⚙️ A Google Cloud template for Gitpod


Every time I open a project in Gitpod, I have to install the gcloud CLI, configure it with the secret of my GCP project. Do these steps once in a while, why not, but several times a day, it’s so boring.

With Gitpod, we can use the .gitpod.yml file to configure our workspaces. 

How do this ? 

First step, the gcloud installation. As we can see on the [Google documentation](https://cloud.google.com/sdk/docs/install), gcloud can be installed with a curl command and the execution of a sh script : 

```
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-394.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-cli-394.0.0-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
```

To get a “gcloud” command available, I created an alias : `alias gcloud=/workspace/google-cloud-sdk/bin/gcloud`

The last step is the authentication of your project. To avoid setting your service key on the project and visible to all, a good way is to define and set variables on your [Gitpod profile](https://gitpod.io/user/variables). 


![Gitpod Variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1eay1z7ysnyae0pbug0c.png)


After doing that, you can use it to initialize a json file with this command : `echo $GCP_SERVICE_KEY | base64 -d > .gcloud-conf.json`.
This file should not be published on GitLab, it’s added on the .gitignore file.

With this file, you can authenticate and configure the project saved also in your Gitpod variable : 

```
gcloud auth activate-service-account --key-file .gcloud-conf.json
gcloud config set project $GCP_PROJECT
``` 

If you are interested in this configuration, you can find it on [this repository](https://github.com/jeanphibaconnais/template-gcp). It’s an open source project, so feel free to comment or add any suggestion.