Creating a CI/CD Pipeline with GitLab and GKE (Part 1)

Pradnya
2 min readApr 5, 2020

--

CI/CD Pipeline with GitLab and GKE

In this article we are going to take a look at how to create a CI/CD Pipeline for deploying and updating workloads in Google Kubernetes Engine. A step-by-step explanation of the code is provided in order to have a better understanding of the pipeline. In Part 1 of this article we will learn how to setup the GCP and Gitlab account for creating a pipeline.

Before starting, you need to configure your GitLab and GCP account as given below:

GCP Platform

  1. Setup a GCP Account here (If first time user you will get $300 free credits)
  2. Navigate to the Kubernetes Engine Page and create a cluster (Regional or Zonal as per your choice)
  3. Navigate to the Service Account page in GCP console and create a new Service Account named “gitlab-user”
  4. Create a Service Account key and save its json file.
  5. Attach the following Roles to the Service Account:
  • Cloud Build Service Account: Building the docker images and pushing to GCR using gcloud.
  • Kubernetes Engine Developer: Accessing the Kubernetes Cluster for deployments
  • Storage Object Admin: Accessing the buckets and GCR repository
  • Project Viewer: Accessing the cloud build logs for successful execution of the pipeline

GitLab

  1. Setup a GitLab Account and create a private repository
  2. Create a ssh key pair and add the public key in the GitLab account, this will allow you to clone your repository using ssh key as shown in Fig. 1.1
  3. Once the ssh keys are configured, use the ssh clone option and clone the repository to your local system.
Fig. 1.1 Adding SSH key to GitLab

These are few of the initial configurations which are needed to use CI/CD pipelines. The next part of this article will explain you how to create the pipeline and successfully execute it.

--

--