Preparing GKE resources

For a fully functional GitLab instance, you will need a few resources before deploying the gitlab chart. The following is how these charts are deployed and tested within GitLab.

Note: Google provides a whitepaper for deploying production-ready GitLab on Google Kubernetes Engine, including all steps and external resource configuration. These are alternative to this document, and the deployed chart will behave slightly differently. For example, the default domain is configured with nip.io, which may experience issues due to rate limiting with Let’s Encrypt.

Creating the GKE cluster

To get started easier, a script is provided to automate the cluster creation. Alternatively, a cluster can be created manually as well.

Scripted cluster creation

A bootstrap script has been created to automate much of the setup process for users on GCP/GKE.

The script will:

  1. Create a new GKE cluster.
  2. Allow the cluster to modify DNS records.
  3. Setup kubectl, and connect it to the cluster.
  4. Initialize Helm and install Tiller.

Google Cloud SDK is a dependency of this script, so make sure it’s set up correctly in order for the script to work.

The script reads various parameters from environment variables and an argument up or down for bootstrap and clean up respectively.

The table below describes all variables.

VariableDescriptionDefault value
REGIONThe region where your cluster livesus-central1
ZONEThe zone where your cluster instances livesus-central1-a
CLUSTER_NAMEThe name of the clustergitlab-cluster
CLUSTER_VERSIONThe version of your GKE clusterGKE default, check the GKE release notes
MACHINE_TYPEThe cluster instances’ typen1-standard-4
NUM_NODESThe number of nodes required.2
PROJECTthe id of your GCP projectNo defaults, required to be set.
RBAC_ENABLEDIf you know whether your cluster has RBAC enabled set this variable.true
PREEMPTIBLECheaper, clusters live at most 24 hrs. No SLA on nodes/disksfalse
USE_STATIC_IPCreate a static IP for Gitlab instead of an ephemeral IP with managed DNSfalse
INT_NETWORKThe IP space to use within this clusterdefault

Run the script, by passing in your desired parameters. It can work with the default parameters except for PROJECT which is required:

PROJECT=<gcloud project id> ./scripts/gke_bootstrap_script.sh up

The script can also be used to clean up the created GKE resources:

PROJECT=<gcloud project id> ./scripts/gke_bootstrap_script.sh down

With the cluster created, continue to creating the DNS entry.

Manual cluster creation

Two resources need to be created in GCP, a Kubernetes cluster and an external IP.

Creating the Kubernetes cluster

To provision the Kubernetes cluster manually, follow the GKE instructions.

  • We recommend a cluster with 8vCPU and 30GB of RAM.
  • Make a note of the cluster’s region, it will be needed in the following step.

Creating the external IP

An external IP is required so that your cluster can be reachable. The external IP needs to be regional and in the same region as the cluster itself. A global IP or an IP outside the cluster’s region will not work.

To create a static IP run:

gcloud compute addresses create ${CLUSTER_NAME}-external-ip --region $REGION --project $PROJECT

To get the address of the newly created IP:

gcloud compute addresses describe ${CLUSTER_NAME}-external-ip --region $REGION --project $PROJECT --format='value(address)'

We will use this IP to bind with a DNS name in the next section.

DNS Entry

If you created your cluster manually or used the USE_STATIC_IP option with the scripted creation, you’ll need a public domain with an A record wild card DNS entry pointing to the IP we just created.

Follow the Google DNS quickstart guide to create the DNS entry.

Next Steps

Continue with the installation of the chart once you have the cluster up and running, and the static IP and DNS entry ready.