SlideShare a Scribd company logo
Ondrej Sika
ondrej@sika.io
@ondrejsika
Gitlab CI
Introduction
Agenda
- DevOps
- What is CI/CD
- Setup Gitlab CI
- Configure CI Pipeline
- Live Demo
DevOps
DevOps is a set of software
development practices that combine
software development (Dev) and
information-technology operations
(Ops) to shorten the
systems-development life cycle
while delivering features, fixes, and
updates frequently in close
alignment with business objectives.
DevOps Lifecycle
CI
Continuous Integration
Continuous Integration works to
integrate code from your team in a
shared repository. Developers share
their new code in a Merge (Pull)
Request, which triggers a pipeline to
build, test, and validate the new code
before merging the changes in your
repository.
CD
Continuous Deployment
Continuous Delivery delivers CI
validated code to your application.
Together, CI and CD accelerate how
quickly your team can deliver results
for your customers and
stakeholders. CI helps you catch and
reduce bugs early in the
development cycle, and CD moves
verified to your applications faster.
CI/CD Pipeline
Gitlab CI
Why Gitlab CI
- Integrated: GitLab CI/CD is part of GitLab
- Open source: CI/CD is a part of both the open source GitLab
- Seamless: Part of the single GitLab application
- Scalable: Tests run distributed on separate machines
- Faster results: Each build can be split in multiple jobs that run in parallel on
multiple machines
- Optimized for delivery: multiple stages, manual deploy gates, environments,
and variables
- Easy to learn
Gitlab CI Architecture
Gitlab Runner
- To perform the actual build, you need to install GitLab Runner which is
written in Go.
- It can run on any platform for which you can build Go binaries, including
Linux, OSX, Windows, FreeBSD and Docker.
- It can test any programming language including .Net, Java, Python, C, PHP
and others.
- GitLab Runner has many features, including autoscaling, great Docker
support, and the ability to run multiple jobs concurrently.
Setup Gitlab CI
Setup Gitlab Runners
See my setup scripts https://github.com/ondrejsika/gitlab-ci-runner
# create runner
docker run -d 
--name gitlab-runner 
--restart always 
-v /var/run/docker.sock:/var/run/docker.sock 
-v /builds:/builds 
gitlab/gitlab-runner:latest
Get Runner Registration Token
Go to Admin -> Runners
Setup Gitlab Runners
# register runner to Gitlab
docker exec gitlab-runner gitlab-runner register 
--non-interactive 
--url $GITLABCI_URL 
--registration-token $GITLABCI_TOKEN 
--name $RUNNER_NAME 
--executor docker 
--docker-image docker:git 
--docker-volumes '/var/run/docker.sock:/var/run/docker.sock' 
--docker-volumes '/builds:/builds'
We are ready to use CI
How to use Gitlab CI
- Gitlab CI configuration is stored inside of the repository in file .gitlab-ci.yml
- If repository contains .gitlab-ci.yml, CI run automatically
- You can work on code & CI together and merge them together
- Smallest unit you can run is job, you can group jobs to stages (jobs run in
parallel in stage, stages run in defined order) and stages create pipeline
- You can build binaries, Docker images, deploy to Kubernetes, track
environments and much more.
First Gitlab CI Job
# .gitlab-ci.yml
job:
script: echo Hello World from Gitlab CI!
Stages
# .gitlab-ci.yml
stages:
- build
- deploy
build:
stage: build
script: docker-compose build && docker-compose push
deploy:
stage: deploy
script: helm template --set TAG=$CI_COMMIT_SHA helm/hello-world | kubectl apply -f
Variables
- Secret variables are defined in
Gitlab
- Some variables set CI runtime
- Public variables are defined in
.gitlab-ci.yml
Variables
CI
CI_PROJECT_NAME, CI_PROJECT_PATH_SLUG
CI_COMMIT_REF_NAME, CI_COMMIT_REF_SLUG
CI_COMMIT_SHA, CI_COMMIT_TAG
CI_PIPELINE_ID, CI_JOB_ID
CI_REGISTRY, CI_REGISTRY_USER, CI_REGISTRY_PASSWORD
...
https://docs.gitlab.com/ce/ci/variables/README.html
Artifacts
Artifacts is a list of files and
directories which are attached to a job
after it completes successfully.
Artifacts
job:
script: make build
artifacts:
name: "$CI_JOB_NAME"
paths:
- binaries/
when: on_failure
https://docs.gitlab.com/ce/ci/yaml/README.html#artifacts
Docker
- Fully supported
- Easiest way how to create build
environment
- Easiest way how to run and
distribute your software
Docker Environment
image: ondrejsika/ci
job:
image: ondrejsika/ci-go
script: go build server.go
Docker
job:
script:
- 'docker login $CI_REGISTRY 
-u $CI_REGISTRY_USER 
-p $CI_REGISTRY_PASSWORD'
- docker build -t $CI_REGISTRY_IMAGE .
- docker push $CI_REGISTRY_IMAGE
Environments
Environment is used to define that a
job deploys to a specific environment.
If environment is specified and no
environment under that name exists, a
new one will be created automatically.
Environment
deploy:
script: echo 'Deploy!'
environment:
name: $CI_COMMIT_REF_SLUG
url: https://$CI_COMMIT_REF_SLUG.example.com
Deployments - Automatic
- Manual
Auto vs Manual Deployments
auto_deploy_job:
script: echo Auto Deploy!
environment:
name: deployment-$CI_PIPELINE_ID
manual_deploy_job:
when: manual
script: echo Manual Deploy!
environment:
name: deployment-$CI_PIPELINE_ID
Stop Deployment
deploy_job:
stage: deploy
script: echo Deploy!
environment:
name: deployment-$CI_PIPELINE_ID
on_stop: stop_deploy_job
stop_deploy_job:
stage: deploy
script: echo Stop!
when: manual
environment:
name: deployment-$CI_PIPELINE_ID
action: stop
Demo Time!
https://github.com/ondrejsika/go-server-example
Resources
- Moje Ukazky Gitlab CI
https://ondrej-sika.cz/repozitare/#gitlab-ci
- Moje skoleni Gitlab CI
https://ondrej-sika.cz/skoleni/gitlab-ci/
- https://docs.gitlab.com/ce/ci/
- https://docs.gitlab.com/ce/ci/yaml/
- https://docs.gitlab.com/ce/ci/quick_start/
Thank you & Questions
Ondrej Sika
email: ondrej@sika.io
web: https://ondrej-sika.cz
twitter: @ondrejsika
linkedin: /in/ondrejsika/
Slides: https://sika.link/cncf-sk-ci

More Related Content

PDF
Continuous Integration/Deployment with Gitlab CI
PDF
Using GitLab CI
PDF
Devops Porto - CI/CD at Gitlab
PDF
Introducing GitLab (June 2018)
PPTX
Gitlab CI/CD
PDF
Gitlab ci-cd
PPTX
GitLab.pptx
PPTX
Transforming Organizations with CI/CD
Continuous Integration/Deployment with Gitlab CI
Using GitLab CI
Devops Porto - CI/CD at Gitlab
Introducing GitLab (June 2018)
Gitlab CI/CD
Gitlab ci-cd
GitLab.pptx
Transforming Organizations with CI/CD

What's hot (20)

PDF
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
PDF
CI with Gitlab & Docker
PDF
What's New for GitLab CI/CD February 2020
PPTX
Git & GitLab
PDF
Introducing GitLab (September 2018)
PDF
Intro to Github Actions @likecoin
PPTX
CICD Pipeline Using Github Actions
PPTX
Git Lab Introduction
PDF
GitOps with ArgoCD
PDF
Introduction to GitHub Actions
PDF
Git flow Introduction
PDF
Introduction to GitHub Actions
PDF
Git flow
PDF
Introducing GitLab
PPTX
CI/CD Overview
PPTX
Introduction to Gitlab | Gitlab 101 | Training Session
PDF
Gitlab, GitOps & ArgoCD
PPTX
Jenkins CI
PDF
FOSDEM 2017: GitLab CI
PDF
CI/CD with Github Actions
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
CI with Gitlab & Docker
What's New for GitLab CI/CD February 2020
Git & GitLab
Introducing GitLab (September 2018)
Intro to Github Actions @likecoin
CICD Pipeline Using Github Actions
Git Lab Introduction
GitOps with ArgoCD
Introduction to GitHub Actions
Git flow Introduction
Introduction to GitHub Actions
Git flow
Introducing GitLab
CI/CD Overview
Introduction to Gitlab | Gitlab 101 | Training Session
Gitlab, GitOps & ArgoCD
Jenkins CI
FOSDEM 2017: GitLab CI
CI/CD with Github Actions
Ad

Similar to Gitlab ci, cncf.sk (20)

PDF
Gitlab ci e kubernetes, build test and deploy your projects like a pro
PDF
Webinar - Unbox GitLab CI/CD
PPTX
Gocd – Kubernetes/Nomad Continuous Deployment
PDF
Portable CI wGitLab and Github led by Gavin Pickin.pdf
PDF
Optimizing Your CI Pipelines
PPTX
Introduction to git and Github
PDF
CICD_1670665418.pdf
PDF
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
PPT
Life of a Chromium Developer
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
PDF
Continuous Deployment with Kubernetes, Docker and GitLab CI
PDF
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
PPTX
Introduction to git & github
PDF
Attacking Pipelines--Security meets Continuous Delivery
PPT
Open up your platform with Open Source and GitHub
PPTX
Docker e git lab
PPTX
2015-ghci-presentation-git_gerritJenkins_final
PDF
HOW TO DRONE.IO IN CI/CD WORLD
PDF
Gitops: the kubernetes way
PDF
gitopsthekubernetesway-201026090439.pdf
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Webinar - Unbox GitLab CI/CD
Gocd – Kubernetes/Nomad Continuous Deployment
Portable CI wGitLab and Github led by Gavin Pickin.pdf
Optimizing Your CI Pipelines
Introduction to git and Github
CICD_1670665418.pdf
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Life of a Chromium Developer
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Continuous Deployment with Kubernetes, Docker and GitLab CI
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
Introduction to git & github
Attacking Pipelines--Security meets Continuous Delivery
Open up your platform with Open Source and GitHub
Docker e git lab
2015-ghci-presentation-git_gerritJenkins_final
HOW TO DRONE.IO IN CI/CD WORLD
Gitops: the kubernetes way
gitopsthekubernetesway-201026090439.pdf
Ad

More from Juraj Hantak (20)

PDF
Kubernetes day 2_jozef_halgas_pf
PDF
Kubernetes day 2 @ zse energia
PDF
Dev ops culture_final
PDF
Promise of DevOps
PDF
23 meetup rancher
PDF
Integracia security do ci cd pipelines
PDF
CNCF opa
PDF
Secrets management vault cncf meetup
PDF
Introductiontohelmcharts2021
PDF
Intro to creating kubernetes operators
PDF
19. stretnutie komunity kubernetes
PDF
16. Cncf meetup-docker
PDF
16. meetup sietovy model v kubernetes
PDF
16.meetup uvod
PDF
14. meetup
PDF
Terraform a gitlab ci
PDF
Monitoring with prometheus at scale
PDF
Kubernetes monitoring using prometheus stack
PDF
12.cncfsk meetup observability and analysis
PDF
Grafana 7.0
Kubernetes day 2_jozef_halgas_pf
Kubernetes day 2 @ zse energia
Dev ops culture_final
Promise of DevOps
23 meetup rancher
Integracia security do ci cd pipelines
CNCF opa
Secrets management vault cncf meetup
Introductiontohelmcharts2021
Intro to creating kubernetes operators
19. stretnutie komunity kubernetes
16. Cncf meetup-docker
16. meetup sietovy model v kubernetes
16.meetup uvod
14. meetup
Terraform a gitlab ci
Monitoring with prometheus at scale
Kubernetes monitoring using prometheus stack
12.cncfsk meetup observability and analysis
Grafana 7.0

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
Teaching material agriculture food technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Machine learning based COVID-19 study performance prediction
PDF
cuic standard and advanced reporting.pdf
PDF
KodekX | Application Modernization Development
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Cloud computing and distributed systems.
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Empathic Computing: Creating Shared Understanding
DOCX
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Review of recent advances in non-invasive hemoglobin estimation
CIFDAQ's Market Insight: SEC Turns Pro Crypto
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Teaching material agriculture food technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Machine learning based COVID-19 study performance prediction
cuic standard and advanced reporting.pdf
KodekX | Application Modernization Development
MYSQL Presentation for SQL database connectivity
Cloud computing and distributed systems.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Empathic Computing: Creating Shared Understanding
The AUB Centre for AI in Media Proposal.docx

Gitlab ci, cncf.sk

  • 2. Agenda - DevOps - What is CI/CD - Setup Gitlab CI - Configure CI Pipeline - Live Demo
  • 3. DevOps DevOps is a set of software development practices that combine software development (Dev) and information-technology operations (Ops) to shorten the systems-development life cycle while delivering features, fixes, and updates frequently in close alignment with business objectives.
  • 5. CI Continuous Integration Continuous Integration works to integrate code from your team in a shared repository. Developers share their new code in a Merge (Pull) Request, which triggers a pipeline to build, test, and validate the new code before merging the changes in your repository.
  • 6. CD Continuous Deployment Continuous Delivery delivers CI validated code to your application. Together, CI and CD accelerate how quickly your team can deliver results for your customers and stakeholders. CI helps you catch and reduce bugs early in the development cycle, and CD moves verified to your applications faster.
  • 9. Why Gitlab CI - Integrated: GitLab CI/CD is part of GitLab - Open source: CI/CD is a part of both the open source GitLab - Seamless: Part of the single GitLab application - Scalable: Tests run distributed on separate machines - Faster results: Each build can be split in multiple jobs that run in parallel on multiple machines - Optimized for delivery: multiple stages, manual deploy gates, environments, and variables - Easy to learn
  • 11. Gitlab Runner - To perform the actual build, you need to install GitLab Runner which is written in Go. - It can run on any platform for which you can build Go binaries, including Linux, OSX, Windows, FreeBSD and Docker. - It can test any programming language including .Net, Java, Python, C, PHP and others. - GitLab Runner has many features, including autoscaling, great Docker support, and the ability to run multiple jobs concurrently.
  • 13. Setup Gitlab Runners See my setup scripts https://github.com/ondrejsika/gitlab-ci-runner # create runner docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /builds:/builds gitlab/gitlab-runner:latest
  • 14. Get Runner Registration Token Go to Admin -> Runners
  • 15. Setup Gitlab Runners # register runner to Gitlab docker exec gitlab-runner gitlab-runner register --non-interactive --url $GITLABCI_URL --registration-token $GITLABCI_TOKEN --name $RUNNER_NAME --executor docker --docker-image docker:git --docker-volumes '/var/run/docker.sock:/var/run/docker.sock' --docker-volumes '/builds:/builds'
  • 16. We are ready to use CI
  • 17. How to use Gitlab CI - Gitlab CI configuration is stored inside of the repository in file .gitlab-ci.yml - If repository contains .gitlab-ci.yml, CI run automatically - You can work on code & CI together and merge them together - Smallest unit you can run is job, you can group jobs to stages (jobs run in parallel in stage, stages run in defined order) and stages create pipeline - You can build binaries, Docker images, deploy to Kubernetes, track environments and much more.
  • 18. First Gitlab CI Job # .gitlab-ci.yml job: script: echo Hello World from Gitlab CI!
  • 19. Stages # .gitlab-ci.yml stages: - build - deploy build: stage: build script: docker-compose build && docker-compose push deploy: stage: deploy script: helm template --set TAG=$CI_COMMIT_SHA helm/hello-world | kubectl apply -f
  • 20. Variables - Secret variables are defined in Gitlab - Some variables set CI runtime - Public variables are defined in .gitlab-ci.yml
  • 21. Variables CI CI_PROJECT_NAME, CI_PROJECT_PATH_SLUG CI_COMMIT_REF_NAME, CI_COMMIT_REF_SLUG CI_COMMIT_SHA, CI_COMMIT_TAG CI_PIPELINE_ID, CI_JOB_ID CI_REGISTRY, CI_REGISTRY_USER, CI_REGISTRY_PASSWORD ... https://docs.gitlab.com/ce/ci/variables/README.html
  • 22. Artifacts Artifacts is a list of files and directories which are attached to a job after it completes successfully.
  • 23. Artifacts job: script: make build artifacts: name: "$CI_JOB_NAME" paths: - binaries/ when: on_failure https://docs.gitlab.com/ce/ci/yaml/README.html#artifacts
  • 24. Docker - Fully supported - Easiest way how to create build environment - Easiest way how to run and distribute your software
  • 25. Docker Environment image: ondrejsika/ci job: image: ondrejsika/ci-go script: go build server.go
  • 26. Docker job: script: - 'docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD' - docker build -t $CI_REGISTRY_IMAGE . - docker push $CI_REGISTRY_IMAGE
  • 27. Environments Environment is used to define that a job deploys to a specific environment. If environment is specified and no environment under that name exists, a new one will be created automatically.
  • 28. Environment deploy: script: echo 'Deploy!' environment: name: $CI_COMMIT_REF_SLUG url: https://$CI_COMMIT_REF_SLUG.example.com
  • 30. Auto vs Manual Deployments auto_deploy_job: script: echo Auto Deploy! environment: name: deployment-$CI_PIPELINE_ID manual_deploy_job: when: manual script: echo Manual Deploy! environment: name: deployment-$CI_PIPELINE_ID
  • 31. Stop Deployment deploy_job: stage: deploy script: echo Deploy! environment: name: deployment-$CI_PIPELINE_ID on_stop: stop_deploy_job stop_deploy_job: stage: deploy script: echo Stop! when: manual environment: name: deployment-$CI_PIPELINE_ID action: stop
  • 34. Resources - Moje Ukazky Gitlab CI https://ondrej-sika.cz/repozitare/#gitlab-ci - Moje skoleni Gitlab CI https://ondrej-sika.cz/skoleni/gitlab-ci/ - https://docs.gitlab.com/ce/ci/ - https://docs.gitlab.com/ce/ci/yaml/ - https://docs.gitlab.com/ce/ci/quick_start/
  • 35. Thank you & Questions Ondrej Sika email: ondrej@sika.io web: https://ondrej-sika.cz twitter: @ondrejsika linkedin: /in/ondrejsika/ Slides: https://sika.link/cncf-sk-ci