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
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 = "[email protected]"
}
Then perform the following commands on the root folder:
terraform init
to get the pluginsterraform plan
to see the infrastructure planterraform apply
to apply the infrastructure buildterraform destroy
to destroy the built infrastructure
Name | Description | Type | Default | Required |
---|---|---|---|---|
certmanager_email | Email used to retrieve SSL certificates from Let's Encrypt | string | n/a | yes |
gitlab_db_password | Password for the GitLab Postgres user | string | "" |
no |
project_id | GCP Project to deploy resources | string | n/a | yes |
region | GCP region to deploy resources to | string | "us-central1" |
no |
Name | Description |
---|---|
gitlab_url | URL where you can access your GitLab instance |
root_password_instructions | Instructions for getting the root user's password for initial setup |
Before this module can be used on a project, you must ensure that the following pre-requisites are fulfilled:
- Terraform is installed on the machine where Terraform is executed.
- 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.
- Terraform 0.10.x
- terraform-provider-google plugin v1.8.0
In order to execute this module you must have a Service Account with the following project roles:
- roles/owner
Be sure you have the correct Terraform version (0.10.x), you can choose the binary here:
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
- bundler
- gcloud
- terraform-docs 0.3.0
Run
make generate_docs
Integration tests are run though test-kitchen, kitchen-terraform, and InSpec.
test-kitchen
instances are defined in .kitchen.yml
. The test-kitchen instances in test/fixtures/
wrap identically-named examples in the examples/
directory.
- Configure the test fixtures
- Download a Service Account key with the necessary permissions and put it in the module's root directory with the name
credentials.json
. - Build the Docker container for testing:
make docker_build_kitchen_terraform
- Run the testing container in interactive mode:
make docker_run
The module root directory will be loaded into the Docker container at /cft/workdir/
.
5. Run kitchen-terraform to test the infrastructure:
kitchen create
creates Terraform state and downloads modules, if applicable.kitchen converge
creates the underlying resources. Runkitchen converge <INSTANCE_NAME>
to create resources for a specific test case.kitchen verify
tests the created infrastructure. Runkitchen verify <INSTANCE_NAME>
to run a specific test case.kitchen destroy
tears down the underlying resources created bykitchen converge
. Runkitchen destroy <INSTANCE_NAME>
to tear down resources for a specific test case.
Alternatively, you can simply run make test_integration_docker
to run all the test steps non-interactively.
Each test-kitchen instance is configured with a variables.tfvars
file in the test fixture directory. For convenience, since all of the variables are project-specific, these files have been symlinked to test/fixtures/shared/terraform.tfvars
.
Similarly, each test fixture has a variables.tf
to define these variables, and an outputs.tf
to facilitate providing necessary information for inspec
to locate and query against created resources.
Each test-kitchen instance creates necessary fixtures to house resources.
Run
make generate_docs
The makefile in this project will lint or sometimes just format any shell, Python, golang, Terraform, or Dockerfiles. The linters will only be run if the makefile finds files with the appropriate file extension.
All of the linter checks are in the default make target, so you just have to run
make -s
The -s is for 'silent'. Successful output looks like this
Running shellcheck
Running flake8
Running go fmt and go vet
Running terraform validate
Running hadolint on Dockerfiles
Checking for required files
Testing the validity of the header check
..
----------------------------------------------------------------------
Ran 2 tests in 0.026s
OK
Checking file headers
The following lines have trailing whitespace
The linters are as follows:
- Shell - shellcheck. Can be found in homebrew
- Python - flake8. Can be installed with 'pip install flake8'
- Golang - gofmt. gofmt comes with the standard golang installation. golang is a compiled language so there is no standard linter.
- Terraform - terraform has a built-in linter in the 'terraform validate' command.
- Dockerfiles - hadolint. Can be found in homebrew