Deploy GitLab Runners on Oracle Container Engine for Kubernetes with autoscaling functionality to scale worker nodes automatically based on load for smooth running jobs in the CI/CD pipeline. This Terraform code will create an OKE cluster with all dependent resources (networking, worker node-pool), deploy cluster autoscalling and Gitlab runners.
For details of the architecture, see Deploy GitLab Runners on Oracle Container Engine for Kubernetes with autoscaling
OKE cluster autoscaling is based on deployments resource booking. When booked resources exceed available resources (CPU, memory) on worker nodes, new worker nodes are added automatically to the cluster up to max_number_of_nodes:10
. When cluster resources are not utilized, number of worker nodes will be decresed down to min_number_of_nodes:3
.
Gitlab runners will handle pending CI/CD jobs and will book, by default, 0.2 CPU and 512M RAM. These values can be overriden using KUBERNETES_CPU_REQUEST
and KUBERNETES_MEMORY_REQUEST
variables. Default values can be modified in locals.tf
.
-
OCI account with rights to:
- manage dynamic groups
- manage policies
- manage network resources
- manage OKE clusters
- manage compute resources
- manage resource manager service
Note:
-
Gitlab account.
- required for Gitlab Runner registration token
If you don't have the required permissions and quota, contact your tenancy administrator. See Policy Reference, Service Limits, Compartment Quotas.
-
If you aren't already signed in, when prompted, enter the tenancy and user credentials.
-
Review and accept the terms and conditions.
-
Select the region where you want to deploy the stack.
-
Follow the on-screen prompts and instructions to create the stack.
-
After creating the stack, click Terraform Actions, and select Plan.
-
Wait for the job to be completed, and review the plan.
To make any changes, return to the Stack Details page, click Edit Stack, and make the required changes. Then, run the Plan action again.
-
If no further changes are necessary, return to the Stack Details page, click Terraform Actions, and select Apply.
Now, you'll want a local copy of this repo. You can make that with the commands:
git clone https://github.com/oracle-devrel/terraform-oci-arch-oke-autoscale-gitlab-runners.git
cd terraform-oci-arch-oke-autoscale-gitlab-runners
ls
Required for gitlab runners deployment to OKE using helm charts.
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh
First off, you'll need to do some pre-deploy setup. That's all detailed here.
Create a terraform.tfvars
file, and specify the following variables:
# Authentication
tenancy_ocid = "<tenancy_ocid>"
user_ocid = "<user_ocid>"
fingerprint = "<finger_print>"
private_key_path = "<pem_private_key_path>"
# Region
region = "<oci_region>"
# Compartment
compartment_ocid = "<compartment_ocid>"
Run the following commands:
terraform init
terraform plan
terraform apply
Connect to OCI cloud shell and execute below commands:
$ oci ce cluster create-kubeconfig --cluster-id <oke_cluster_id>
$ kubectl get deployments --all-namespaces
Confirm deployed gitlab runners are available in runners section of Gitlab Project CI/CD Settings.
Validate the deployment using gitlab-ci.yml
file in samples
directory.
When you no longer need the deployment, you can run this command to destroy the resources:
terraform destroy
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.
Copyright (c) 2024 Oracle and/or its affiliates.
Licensed under the Universal Permissive License (UPL), Version 1.0.
See LICENSE for more details.
ORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK.