Developing with a GKE cluster
This guide creates a Google Kubernetes Engine (GKE) cluster for chart development, deploys GitLab from your branch, and removes everything again when you are done.
Use a GKE cluster when your change depends on behavior that a local cluster does not provide, like cloud load balancers or persistent disks. For more information, see provider-specific testing.
Prerequisites
Install the required developer tools.
Install the Google Cloud CLI and the
gke-gcloud-auth-plugincomponent thatkubectluses to authenticate:gcloud components install gke-gcloud-auth-pluginGet access to a Google Cloud project where you can create GKE clusters and compute addresses. GitLab team members can create a personal project in the Sandbox Cloud.
Sign in with the Google Cloud CLI:
gcloud auth login
Create the cluster
Set the variables used by the following commands:
export PROJECT="<your-project-id>" export REGION="us-central1" export ZONE="${REGION}-b" export CLUSTER_NAME="gitlab-dev-<your-name>"The cluster name must contain only lowercase letters, numbers, and hyphens.
List the Kubernetes versions available in the zone:
gcloud container get-server-config --project "${PROJECT}" --zone "${ZONE}" \ --flatten="channels" \ --filter="channels.channel=REGULAR" \ --format="yaml(channels.channel,channels.defaultVersion,channels.validVersions)"Pick a version from a supported Kubernetes release.
Create the cluster:
gcloud container clusters create "${CLUSTER_NAME}" \ --project "${PROJECT}" \ --zone "${ZONE}" \ --release-channel regular \ --cluster-version "<version>" \ --machine-type n2d-standard-4 \ --num-nodes 2 \ --enable-autoscaling --min-nodes 1 --max-nodes 4Two
n2d-standard-4nodes provide 8 vCPU and 32 GB of RAM, which meets the cluster requirements. To reduce costs, add--spotto use Spot VMs. GKE can reclaim Spot VMs at any time, so pods restart more often.Connect
kubectlto the cluster. Thecreatecommand already configures the current context, so you only need this step on another machine or after you switch contexts:gcloud container clusters get-credentials "${CLUSTER_NAME}" --project "${PROJECT}" --zone "${ZONE}" kubectl get nodes
Reserve an external IP
Reserve a static IP for the GitLab Gateway. The IP must be regional and in the same region as the cluster:
gcloud compute addresses create "${CLUSTER_NAME}-external-ip" --project "${PROJECT}" --region "${REGION}"
export EXTERNAL_IP=$(gcloud compute addresses describe "${CLUSTER_NAME}-external-ip" \
--project "${PROJECT}" --region "${REGION}" --format='value(address)')This guide uses nip.io to resolve gitlab.${EXTERNAL_IP}.nip.io to the IP,
so you don’t need to create DNS records.
Deploy GitLab
From the root of the chart repository, set up the external dependencies:
bash scripts/dev_dependencies.sh setupDeploy the chart from your branch:
helm dependency update helm upgrade --install gitlab . \ --namespace gitlab \ --timeout 600s \ -f .values/dev-external.values.yaml \ --set global.hosts.domain="${EXTERNAL_IP}.nip.io" \ --set global.hosts.externalIP="${EXTERNAL_IP}" \ --set certmanager-issuer.email="<your-email>"If Let’s Encrypt cannot issue certificates for the domain, for example because of rate limits, you can attempt
--set global.hosts.domain="${EXTERNAL_IP}.sslip.io", or use the auto-generated self-signed wildcard certificate instead.Open
https://gitlab.${EXTERNAL_IP}.nip.io, orhttps://gitlab.${EXTERNAL_IP}.sslip.ioif you switched to sslip.io, and sign in.
For more information about deploying a development branch, see Deploy development branch.
Clean up
Delete the cluster when you are done. Uninstall GitLab and delete the namespace first, so that GKE also deletes the load balancer and the persistent disks that the chart created:
helm uninstall gitlab --namespace gitlab
bash scripts/dev_dependencies.sh teardown
kubectl delete namespace gitlab
gcloud container clusters delete "${CLUSTER_NAME}" --project "${PROJECT}" --zone "${ZONE}" --quiet
gcloud compute addresses delete "${CLUSTER_NAME}-external-ip" --project "${PROJECT}" --region "${REGION}" --quietTo find leftover persistent disks, run:
gcloud compute disks list --project "${PROJECT}" --filter="name~^pvc-"