Preparing GKE resources for the GitLab chart

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.

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.

Prerequisites:

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.

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

The table below describes all variables.

VariableDescriptionDefault value
REGIONThe region where your cluster livesus-central1
ZONE_EXTENSIONThe extension (a, b, c) of the zone name where your cluster instances liveb
CLUSTER_NAMEThe name of the clustergitlab-cluster
CLUSTER_VERSIONThe version of your GKE clusterGKE default, check the GKE release notes
MACHINE_TYPEThe cluster instances’ typen2d-standard-4
NUM_NODESThe number of nodes required.2
AUTOSCALE_MIN_NODESThe minimum number of nodes the autoscaler should scale down to.0
AUTOSCALE_MAX_NODESThe maximum number of nodes the autoscaler should scale up to.NUM_NODES
PROJECTThe ID of your GCP projectNo defaults, required to be set.
ADMIN_USERThe user to assign cluster-admin access to during setupcurrent gcloud user
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
SUBNETWORKThe subnetwork 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 at least 2 nodes, each with 4vCPU and 15GB 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 after you have the cluster up and running, and the static IP and DNS entry ready.