top of page

One-Click GCP Deployment with Cloud Build and GKE Autopilot

This guide explains how to set up and execute a one-click deployment of an Nginx service on Google Cloud Platform (GCP) using Google Kubernetes Engine (GKE) Autopilot and Cloud Build. The setup includes creating a GKE Autopilot cluster, getting credentials for the cluster, and deploying an Nginx application.


Prerequisites

  • A GCP project set up and configured.

  • GCP's Cloud Build and GKE APIs enabled.

  • Necessary permissions to manage Cloud Build, GKE, and Deployment Manager resources.


Overview of Configuration

The deployment process involves the following steps:

  1. Setting the GCP project.

  2. create a Deployment Manager deployment for the GKE Autopilot cluster using cloud build .

  3. Retrieving the credentials of the newly created cluster.

  4. Deploying an Nginx service using kubectl.


Step-by-Step Setup and Execution

Flow diagram

1. Cloud Build Configuration

The Cloud Build configuration is defined in the cloudbuild.yaml file. This file orchestrates the entire deployment process using the following steps:


2. Deployment Manager Configuration

The Deployment Manager configuration is specified in gke_autopilot.yaml. It describes the properties of the GKE Autopilot cluster to be created.


3. Nginx Deployment Configuration

The Nginx deployment is described in the nginx-deployment.yaml file, which defines the deployment of an Nginx container and a load-balanced service to expose it.


Deployment Instructions

  1. Create or Edit cloudbuild.yaml: Define the steps for deploying your resources using Cloud Build as shown above.

  2. Create or Edit gke_autopilot.yaml: Specify the GKE Autopilot cluster properties.

  3. Create or Edit nginx-deployment.yaml: Define the Nginx deployment and service.

  4. Trigger the Cloud Build:

Use the Google Cloud Console or the following command to start the Cloud Build:

Cloud Build will execute each step sequentially, creating the GKE Autopilot cluster, fetching credentials, and deploying Nginx.


Conclusion

This automated deployment setup using Google Cloud Build and GKE Autopilot simplifies the process of deploying applications on Google Cloud Platform. By defining clear steps in the cloudbuild.yaml file, you can handle project configuration, cluster setup, and application deployment in a seamless, efficient manner.

Comments


bottom of page