DevOps

GitlabCI

gitlabci.neowinx.tech

Pero antes

Terraform + AKS

Hands-On Lab

Terraform + AKS Worflow

Using GitLab CI

Why GitLab CI?

Integration
Fully integrated with GitLab
Easy to start
A few lines in yml (YAML) inside of .gitlab-ci.yml and a bit clicks
Scalable
Concurrent jobs (in parallel), many runners, tagged runners
Isolated test environment
Using Docker containers

GitLab CI configuration

Is done via .gitlab-ci.yml file:

Example for NodeJS project:


nodejs_run:
  stage: test
  script:
    - npm install
    - npm test
					

How GitLab CI differs from other CI's?

Runners

This is an application that processes builds. It receives commands from GitLab CI.

It's possible to tag runners so jobs run on runners which can process them (e.g. different OS)

Executors

Shell
Localy
Docker
Inside of Docker container
Docker-SSH
In Docker container communicating over SSH
SSH
On remote server using SSH

Stages

Used to group your jobs in stages to create multiple pipelines

Builds of next stage are run after success

Repo cleaning

By default, GitLab CI cleans build dir between builds for the sake of concurrency

But we can preserve builds between builds (Hello, npm and node_modules !)

Job concurrency

Jobs of the same stage run in parallel

Start using GitLab CI

Get runner first

A simple Ubuntu Server VDS can play this role.

Provision it via script:

# Gitlab CI multi runner
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | bash
apt-get install -y gitlab-ci-multi-runner

echo 'run "gitlab-ci-multi-runner register"'
							

Run gitlab-ci-multi-runner register and answer questions. You can find your unique registration token under Settings ---> Runners section.

Agregar .gitlab-ci.yml al repo

Ejemplo para nodejs:


nodejs_run:
	stage: test
	script:
	- npm install
	- npm test
						

Esperaban algo más?

Eso es todo!

Pro tips for usage

Usar la opcion cache en el .gitlab-ci.yml para preservar directorios o archivos

Esta linea cachea todos los directorios y archivos en node_modules


cache:
	untracked: true
	paths:
	- node_modules/
						

Build skip

El build se ignora si en el mensaje de commit se encuentra el texto [ci skip]

Hands-On Lab

Gitlab CI

Questions?

DevOps Gitlab CI

By Pedro Flores

DevOps Gitlab CI

  • 58