Skip to content

terraform-google-modules/terraform-google-gke-gitlab

Repository files navigation

terraform-google-gke-gitlab

This module creates a reslient and fault tolerant GitLab installation using Google Kubernetes Engine (GKE) as the computing environment and the following services for storing data:

  • CloudSQL for PostgreSQL
  • Memorystore for Redis
  • Cloud Storage

GitLab on GKE architecture diagram

Compatibility

This module is meant for use with Terraform 0.13+ and tested using Terraform 0.14.

Usage

There are examples included in the examples folder but simple usage is as follows:

module "gke-gitlab" {
  source                     = "terraform-google-modules/gke-gitlab/google"
  project_id                 = "<PROJECT ID>"
  certmanager_email          = "test@example.com"
}

Then perform the following commands on the root folder:

  • terraform init to get the plugins
  • terraform plan to see the infrastructure plan
  • terraform apply to apply the infrastructure build
  • terraform destroy to destroy the built infrastructure

Inputs

Name Description Type Default Required
allow_force_destroy Allows full cleanup of resources by disabling any deletion safe guards bool false no
certmanager_email Email used to retrieve SSL certificates from Let's Encrypt string n/a yes
domain Domain for hosting gitlab functionality (ie mydomain.com would access gitlab at gitlab.mydomain.com) string "" no
gitlab_address_name Name of the address to use for GitLab ingress string "" no
gitlab_db_name Instance name for the GitLab Postgres database. string "gitlab-db" no
gitlab_db_password Password for the GitLab Postgres user string "" no
gitlab_db_random_prefix Sets random suffix at the end of the Cloud SQL instance name. bool false no
gitlab_deletion_protection Must be false to allow Terraform to destroy the Cloud SQL instance. bool true no
gitlab_nodes_subnet_cidr Cidr range to use for gitlab GKE nodes subnet string "10.0.0.0/16" no
gitlab_pods_subnet_cidr Cidr range to use for gitlab GKE pods subnet string "10.3.0.0/16" no
gitlab_runner_install Choose whether to install the gitlab runner in the cluster bool true no
gitlab_services_subnet_cidr Cidr range to use for gitlab GKE services subnet string "10.2.0.0/16" no
gke_machine_type Machine type used for the node-pool string "n1-standard-4" no
gke_version Version of GKE to use for the GitLab cluster string "1.21" no
helm_chart_version Helm chart version to install during deployment string "4.2.4" no
project_id GCP Project to deploy resources string n/a yes
region GCP region to deploy resources to string "us-central1" no

Outputs

Name Description
cluster_ca_certificate CA Certificate for the GKE cluster that GitLab is deployed in.
cluster_location Location of the GKE cluster that GitLab is deployed in.
cluster_name Name of the GKE cluster that GitLab is deployed in.
gitlab_address IP address where you can connect to your GitLab instance
gitlab_url URL where you can access your GitLab instance
host Host for the GKE cluster that GitLab is deployed in.
root_password_instructions Instructions for getting the root user's password for initial setup
token Token for the GKE cluster that GitLab is deployed in.

Requirements

Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:

  1. Terraform is installed on the machine where Terraform is executed.
  2. The Service Account you execute the module with has the right permissions.

The project factory can be used to provision projects with the correct APIs active.

Software Dependencies

Terraform

Configure a Service Account

In order to execute this module you must have a Service Account with the following project roles:

  • roles/owner

Install

Terraform

Be sure you have the correct Terraform version, you can choose the binary here:

File structure

The project has the following folders and files:

  • /: root folder
  • /examples: examples for using this module
  • /helpers: Helper scripts
  • /test: Folders with files for testing the module (see Testing section on this file)
  • /main.tf: main file for this module, contains all the resources to create
  • /variables.tf: all the variables for the module
  • /output.tf: the outputs of the module
  • /README.md: this file