
Google Cloud Platform offers a robust Git source code management system that lets you store, manage, and track changes to your code. This system is built on top of Google's scalable infrastructure.
You can use Google Cloud Source Repositories to store your code, which provides a scalable and secure way to manage your codebase. Google Cloud Source Repositories can be accessed from any device with an internet connection.
With Google Cloud Source Repositories, you can manage your code in a team environment, including features like branching, merging, and permissions management. This makes it easy to collaborate with your team on code changes.
Google Cloud Source Repositories integrates seamlessly with other Google Cloud services, such as Cloud Build and Cloud Source Repositories.
You might enjoy: Azure Ticketing System
Prerequisites
To get started with Google Cloud Platform and Git, you'll need to meet some basic requirements.
Administrator access to a Google Workspace or Cloud Identity domain is a must, with Cloud Search for Third Party Data Indexing enabled. This allows you to view settings in the Admin control panel.
You'll also need a GitHub user account, which is a crucial part of the process. Don't worry if you're not familiar with GitHub yet - it's easy to sign up!
To write code for Google Cloud Platform, you should have familiarity with Java and JavaScript. This will help you understand how to use the platform's API.
In terms of specific software, you'll need Java 8 or newer, and Maven. These will be your go-to tools for coding and building projects.
If you're working on a Node.js project, make sure you have Node.js 8.11 or newer installed. This will ensure that your project runs smoothly on the Google Cloud Platform.
Expand your knowledge: How to Run Next Js App
Setup and Installation
To set up Google Cloud Platform for Git, you'll need to start by installing Git and the Google Cloud CLI.
First, install Git, which is a version control system that helps you manage changes to your code. You can download and install it from the official Git website.
For more insights, see: How to Config Git Credential Helper Azure
Next, install the gcloud CLI, which is a command-line tool for interacting with Google Cloud services. You'll need version 395.0.0 or later to use Git with HTTPS.
To check your gcloud CLI version, run the command `gcloud --version`. If your version is outdated, update it by running `gcloud components update`. After updating, run `gcloud init` to initialize the gcloud CLI.
Here's a quick rundown of the steps:
- Install Git.
- Install the gcloud CLI.
- Check your gcloud CLI version with `gcloud --version`.
- Update the gcloud CLI with `gcloud components update` if necessary.
- Initialize the gcloud CLI with `gcloud init`.
Once you have the gcloud CLI set up, you can move on to installing GitLab, which is a web-based Git repository manager. After a few seconds, the instance is created and available to sign in.
Git on Google Cloud
Git on Google Cloud is a powerful combination that simplifies version control and collaboration.
You can use the Google Cloud Source Repositories to store and manage your Git repositories.
This service integrates seamlessly with other Google Cloud products, making it easy to deploy and manage your code.
With Google Cloud Source Repositories, you can also use features like Git Large File Storage and Git LFS to store large files.
Worth a look: How to Use Google Drive Cloud Sync
Required Roles
To use Git with a Secure Source Manager repository on Google Cloud, you'll need the right permissions.
To get these permissions, ask your administrator to grant you the Secure Source Manager Instance Accessor role on the Secure Source Manager instance.
You'll also need the Secure Source Manager Repo Reader role on the repository to clone it. This role gives you the necessary permissions to read the repository.
To push changes to a repository, you'll need the Secure Source Manager Repo Writer role on the repository. This role allows you to write changes to the repository.
Here's a summary of the required roles:
- Secure Source Manager Instance Accessor (roles/securesourcemanager.instanceAccessor) on the Secure Source Manager instance
- Secure Source Manager Repo Reader (roles/securesourcemanager.repoReader) on the repository to clone it
- Secure Source Manager Repo Writer (roles/securesourcemanager.repoWriter) on the repository to push changes
You might also be able to get the required permissions through custom roles or other predefined roles, but for that, you'll need to check the documentation on granting Secure Source Manager roles.
Runners on GCE
You can create self-hosted runners on Compute Engine that suit your specific workflows. These runners can be custom machine sizes or GPU-accelerated VMs, and you can control them from a single pane of glass using Managed Instance Groups.
For your interest: Connections - Oracle Fusion Cloud Applications
Managed Instance Groups offer features like autoscaling based on usage, which can be a huge time-saver. You can also use Application Default Credentials to automatically authenticate with Google Cloud APIs using the service account attached to the GCE VM.
This approach is great for automating tasks, as you don't have to manage service account keys. You can find an example of a Managed Instance Groups runner on GitHub at https://github.com/bharathkkb/gh-runners/tree/master/gce.
Here's an interesting read: Google Drive Service Account
Hybrid Runners with Anthos
You can use Anthos to build, deploy, and manage applications anywhere in a secure, consistent manner.
Anthos is a subset of the Google Cloud software stack that runs on infrastructure you control, including on-premises. This allows you to compose a containerized build pipeline that runs on your infrastructure using GitHub Actions and Anthos GKE.
The repository linked above includes the set of commands to run to provision an Anthos GKE cluster. It creates the Google Cloud project, enables all required services, and provisions a GKE cluster managed by Anthos.
Check this out: Azure Cluster
To configure Kubernetes secrets, you'll need to provide a TOKEN for the runner pod to (de)register itself and a GITHUB_REPO variable for which the runner(s) will be made available.
A Dockerfile based on a general-purpose Ubuntu image downloads and installs dependencies, including the runner itself. This allows you to use self-hosted runners to run container builds.
Using a Docker-in-Docker sidecar pod requires a privileged security context, which extends the trust boundary to the whole cluster. This approach offers build flexibility but requires extra caution.
After completing test and deploy jobs, you can navigate to GITHUB_REPO's settings page to see the newly provisioned runners.
It's not advised to scale down replicas as builds are happening, since it's not yet feasible to select only the idle runners.
On a similar theme: Google Cloud Platform Docker
Sources
- https://cloud.google.com/secure-source-manager/docs/use-git
- https://docs.gitlab.com/ee/install/google_cloud_platform/
- https://github.blog/news-insights/product-news/github-actions-self-hosted-runners-on-google-cloud/
- https://stackoverflow.com/questions/37230002/how-do-i-git-push-from-a-local-machine-to-a-google-cloud-platform-instance
- https://developers.google.com/cloud-search/docs/tutorials/end-to-end
Featured Images: pexels.com