This solution is suitable only for Yandex Cloud
Check resource quotas
Resource requirements are based on initial default quotas in an empty, newly created cloud
You will need
Quota | Value |
---|---|
Number of cloud networks | 2 |
Number of security groups | 7 |
Number of all public IP addresses | 2 |
Number of static public IP addresses | 1 |
Number of subnets | 8 |
Number of disks | 9 |
Number of vCPUs for instances | 25 |
Total RAM for instances | 50 GB |
Number of instances | 8 |
Total SSD capacity | 170 GB |
Total size of non-replicated SSDs | 465 GB |
Number of instance groups | 3 |
- Delegate a DNS domain to Yandex Cloud. It could be either a 2nd level domain or a 3rd level domain.
2nd level domain should be delegated through a domain registrar.
3rd level domain can be delegated via your DNS hosting.
You need to create in your DNS zone (e.g. example.com) two NS records like these:
playground.example.com. 3600 IN NS ns1.yandexcloud.net. playground.example.com. 3600 IN NS ns2.yandexcloud.net.
- Install Yandex Cloud CLI and setup access to the cloud via
yc init
- Create an empty cloud folder for experiments and get its
folder_id
. - Create new or use an exiting GitLab instance.
- In GitLab create a new empty project and get the project id. It could be found in the "Project overview" section of the Project page.
- Create the project access token with
Maintainer
role andapi
scope (it grants complete read and write access to the scoped project API). - Install terraform and setup access to your cloud
- Clone this repo.
- Get into
boostrap
subdirectory. - Prepare terraform variables e.g. create in
boostrap
subdirectory terraform.tfvars file with the following contentfolder_id = "b1gxxxxxxxxxxx" # your folder_id here dns_domain = "playground.example.com" # your domain here dns_hostnames = ["test1"] # subdomain name here gitlab_runner_enabled = true gitlab_url = "https://xxxxxxx.gitlab.yandexcloud.net" # your GitLab instance URL gitlab_project_id = "0000" # your GitLab project id gitlab_username = "your-username" # your GitLab username gitlab_access_token = "glpat-xxxxxxxxxx" # your GitLab project access token
- Prepare environment:
export YC_TOKEN=$(yc iam create-token)
- Run
check the plan and confirm the creation. This step will prepare the initial infrastructure - DNS, Container Registry, gitlab-runner. It will also prepare the repo by adding necessary CI/CD variables and registering gitlab-runner.
terraform init terraform apply
- Follow to root directory of the new repo.
- Set the remote tracked repository by executing (don't forget to set URL of your repo)
git remote set-url origin [email protected]:new/repo/location.git
- Put the code to GitLab
git add . git commit -m "Initial commit" git push --set-upstream origin master
- Go to
build
section on the GitLab project page and watch the pipeline. - Check the result in the job log and on the ALB monitoring page.
- Ensure that the clean job compete successfully. If it doesn't try to run it again
- Be sure that the clean step of the pipeline was done completely
- Open the Yandex Cloud web console, go to the Container Registry in testing folder and remove all images from the container registry.
- Go to bootstrap directory and run
terraform destroy
, check the plan and confirm the deletion