SlideShare a Scribd company logo
GitlabCI and Kubernetes
#build #test and #deploy your projects like a #pro
Paolo Mainardi (@paolomainardi)
● CTO @sparkfabrik
● OSS developer, devops automation engineer
● Checkout my projects here: github.com/paolomainardi
Let’s start with
questions
● You know what Kubernetes is
● You ever used gitlab ci
● You already have a CI/CD pipeline workflow
Raise your hands if
Outlines
● What are Kubernetes and Gitlab
● How to create a cluster powered CI/CD pipeline
● Tips and tricks on real world usage.
Continuous integration is a tough job...
Credits: deis.com/blog/2016/kubernetes-illustrated-guide/
Containerize Everything
Cloud native applications
Cloud-native is an approach to building and running applications
that fully exploits the advantages of the cloud computing model.
https://12factor.net - https://pivotal.io/cloud-native
● Handle of application dependencies
● Dev/prod environments parity
● Orchestrate services
● Make easy to deploy to cloud clustered environments
Continuous integration is a tough job...
Continuous delivery is a software engineering approach to ensure
that the software can be reliably released at any time.
CD Continuous delivery
Continuous deployment is a software engineering approach to ensure
that the every change is automatically deployed to production.
CD Continuous deployment
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Cloud orchestrators
9%43% 7%
Source: https://sysdig.com/blog/sysdig-docker-usage-report-2017
Kubernetes
● A system for container management in a clustered environment, open sourced by
Google and inspired by the Borg project.
● Multiple container engines (Docker, rkt, OCI), mainly based on Docker.
● Provides grouping, load balancing, scaling, monitoring and scheduling features
with an unified and declarative API.
● 100% open source and written in GO - https://github.com/kubernetes/kubernetes
Kubernetes the hard way: Custom installers
Kubernetes installation is fairly complex, pick up the right solution:
https://kubernetes.io/docs/setup/pick-right-solution
https://github.com/kubernetes/kubeadm - https://github.com/kubernetes/kops
Kubernetes the easier way: Google GKE
One-click Kubernetes clusters, managed by Google:
https://cloud.google.com/container-engine
Kubernetes the easy way: Google GKE
● Fully managed HA Kubernetes cluster (free up to 5 nodes)
● Logging and monitoring included (Stackdriver)
● Private container registry - https://cloud.google.com/container-registry/
● Automatic and configurable cluster scaling
Kubernetes the easy way: Google GKE
gcloud container clusters list
NAME ZONE MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
My-testing-clust europe-west1-b 1.5.6 172.199.00.000 n1-standard-1 1.5.6 2 RUNNING
Gitlab
The platform for modern developers
GitLab unifies issues, code review, CI and CD into a single UI
https://about.gitlab.com
Gitlab Runner
The fully integrated solution to build test
and deploy your code.
https://about.gitlab.com/gitlab-ci/
Gitlab Runner
● It is the daemon that run the jobs and send the results back to Gitlab
● One single binary written in GO, very easy to deploy
● Allows to run multiple jobs concurrently
● Native supports for storing cache and artifacts
● It supports multiple build executors including Kubernetes
● Programmatic pipelines definition using a .gitlab-ci.yml file
Gitlab Kubernetes executor
The Kubernetes executor, connects to the Kubernetes API in the
cluster creating a Pod for each GitLab CI Job.
https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/executors/kubernetes.md
config.toml
concurrent = 4
[[runners]]
name = "Kubernetes Runner"
url = "https://gitlab.com/ci"
token = "......"
executor = "kubernetes"
[runners.kubernetes]
host = "https://45.67.34.123:4892"
cert_file = "/etc/ssl/kubernetes/api.crt"
namespace = "gitlab"
privileged = true
cpu_limit = "1"
memory_limit = "1Gi"
service_cpu_limit = "1"
service_memory_limit = "1Gi"
helper_cpu_limit = "500m"
helper_memory_limit = "100Mi"
[runners.kubernetes.node_selector]
"cloud.google.com/gke-nodepool" = "gitlab-ci"
Container limits and resources
Node selector
Kubernetes host
.gitlab-ci.yml
image: docker:latest
stages:
- build
- deploy
build:
stage: build
script:
- docker build -t containerday/my-cool-app:${GIT_COMMIT} .
- docker run containerday/my-cool-app:${GIT_COMMIT} go test -run ./
- docker push containerday/my-cool-app:${GIT_COMMIT} .
Pipelines dashboard
ArtifactsStages
History
Pipeline details
Jobs
Job details
Continuous deployment
With environments, you can control the Continuous Deployment of
your software all within GitLab.
https://about.gitlab.com/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/
image: docker:latest .gitlab-ci.yml
stages:
- build
- deploy
build:
stage: build
script:
- docker build -t containerday/my-cool-app:${GIT_COMMIT} .
- docker run containerday/my-cool-app:${GIT_COMMIT} go test -run ./
- docker push containerday/my-cool-app:${GIT_COMMIT} .
deploy:
stage: deploy
environment:
name: production
url: http://foobar.example.com
variables:
- IMAGE_DEPLOY: containerday/image:${CI_BUILD_REF_NAME}
scripts:
# auth
- kubectl config set-cluster my-cluster --server="$KUBE_URL" $KUBE_CLUSTER_OPTIONS
- kubectl config set-credentials my-cluster --token="$KUBE_TOKEN" $KUBE_CLUSTER_OPTIONS
# deploy
- envsubst < k8s/deployment.template.yml > "k8s/deployment.yml"
- kubectl apply -f k8s/deployment.yml
Gitlab continuous deployment
Web terminal
Gitlab continuous deployment
Monitoring with Prometheus
https://docs.gitlab.com/ce/user/project/integrations/prometheus.html
Continuous deployment with Kubernetes
Continuous deployment with Kubernetes
Running Gitlab on Kubernetes
Self hosting Gitlab on Kubernetes
https://gitlab.com/gitlab-org/kubernetes-gitlab-demo
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Running Gitlab on Kubernetes tips&tricks
● Segment your cluster by labelling the nodes and use the nodeSelector
● Make a correct use of namespacing for deploying
● Adjust correctly the limits/requests resources of Gitlab executor to help the pod
scheduling
● Keep the k8s templates on version control together with the codebase
● Make a smart use of caches, remember than each job is a clean build env
● Gitlab is an open source project, submit issues and share the fixes
Troubleshooting and debugging
Accessing to a pod internal port
> kubectl port-forward mysql-pod [-c container] 3306:3306
> mysql -hlocalhost -uroot -
Troubleshooting and debugging
Getting a shell to a running container
> kubectl exec -it mysql-pod [-c container] bash
Troubleshooting and debugging
Show gitlab executor pod metrics
> kubectl top pod runner-329d5212-project-255-concurrent-07rxsl -ngitlab --containers
POD NAME CPU(cores) MEMORY(bytes)
runner-329d5212-project-255-concurrent-07rxsl build 1m 35Mi
runner-329d5212-project-255-concurrent-07rxsl helper 0m 13Mi
runner-329d5212-project-255-concurrent-07rxsl svc-0 604m 248Mi
Troubleshooting and debugging
Get container logs
> kubectl logs -f mysql-pod [-c container] bash
Troubleshooting and debugging
https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/
That’s all folks, thanks!
Ad

Recommended

Introduction to GitHub Actions
Introduction to GitHub Actions
Bo-Yi Wu
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.sk
Juraj Hantak
 
Gitlab CI/CD
Gitlab CI/CD
JEMLI Fathi
 
Using GitLab CI
Using GitLab CI
ColCh
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
Anwarul Islam
 
Git training v10
Git training v10
Skander Hamza
 
Git and git flow
Git and git flow
Fran García
 
Intro to git and git hub
Intro to git and git hub
Venkat Malladi
 
FOSDEM 2017: GitLab CI
FOSDEM 2017: GitLab CI
OlinData
 
GitHub Actions in action
GitHub Actions in action
Oleksii Holub
 
Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building Tools
Akihiro Suda
 
Starting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Learning git
Learning git
Sid Anand
 
GitLab for CI/CD process
GitLab for CI/CD process
HYS Enterprise
 
CI with Gitlab & Docker
CI with Gitlab & Docker
Joerg Henning
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Gitlab flow solo
Gitlab flow solo
viniciusban
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
Knoldus Inc.
 
Git One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git for beginners
Git for beginners
Arulmurugan Rajaraman
 
Gitlab ci-cd
Gitlab ci-cd
Dan MAGIER
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
AddWeb Solution Pvt. Ltd.
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
Noa Harel
 
Git - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Introduction to Git
Introduction to Git
Yan Vugenfirer
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
Kumar Shìvam
 
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Indonesia
 
Git pour les (pas si) nuls
Git pour les (pas si) nuls
Malk Zameth
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
Oleg Shalygin
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
HungWei Chiu
 

More Related Content

What's hot (20)

FOSDEM 2017: GitLab CI
FOSDEM 2017: GitLab CI
OlinData
 
GitHub Actions in action
GitHub Actions in action
Oleksii Holub
 
Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building Tools
Akihiro Suda
 
Starting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Learning git
Learning git
Sid Anand
 
GitLab for CI/CD process
GitLab for CI/CD process
HYS Enterprise
 
CI with Gitlab & Docker
CI with Gitlab & Docker
Joerg Henning
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Gitlab flow solo
Gitlab flow solo
viniciusban
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
Knoldus Inc.
 
Git One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git for beginners
Git for beginners
Arulmurugan Rajaraman
 
Gitlab ci-cd
Gitlab ci-cd
Dan MAGIER
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
AddWeb Solution Pvt. Ltd.
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
Noa Harel
 
Git - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Introduction to Git
Introduction to Git
Yan Vugenfirer
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
Kumar Shìvam
 
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Indonesia
 
Git pour les (pas si) nuls
Git pour les (pas si) nuls
Malk Zameth
 
FOSDEM 2017: GitLab CI
FOSDEM 2017: GitLab CI
OlinData
 
GitHub Actions in action
GitHub Actions in action
Oleksii Holub
 
Comparing Next-Generation Container Image Building Tools
Comparing Next-Generation Container Image Building Tools
Akihiro Suda
 
Starting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Learning git
Learning git
Sid Anand
 
GitLab for CI/CD process
GitLab for CI/CD process
HYS Enterprise
 
CI with Gitlab & Docker
CI with Gitlab & Docker
Joerg Henning
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Gitlab flow solo
Gitlab flow solo
viniciusban
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
Knoldus Inc.
 
Git One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
Noa Harel
 
Git - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
Kumar Shìvam
 
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Indonesia
 
Git pour les (pas si) nuls
Git pour les (pas si) nuls
Malk Zameth
 

Similar to Gitlab ci e kubernetes, build test and deploy your projects like a pro (20)

GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
Oleg Shalygin
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
HungWei Chiu
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CI
alexanderkiel
 
Continuous Delivery With Containers
Continuous Delivery With Containers
All Things Open
 
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
devopsdaysaustin
 
Kubernetes and Hybrid Deployments
Kubernetes and Hybrid Deployments
Sandeep Parikh
 
Kubernetes Boulder - Kit Merker - Cloud Native Deployment
Kubernetes Boulder - Kit Merker - Cloud Native Deployment
Kit Merker
 
Automated Testing Environments With Kubernetes & GitLab
Automated Testing Environments With Kubernetes & GitLab
Vladislav Supalov
 
KubeCon EU 2016 Keynote: Kubernetes State of the Union
KubeCon EU 2016 Keynote: Kubernetes State of the Union
KubeAcademy
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google Cloud
Samuel Chow
 
Introduction to Kubernetes and GKE
Introduction to Kubernetes and GKE
Opsta
 
Deploying Kubernetes in the Enterprise (IBM #Think2019 #7678 Tech Talk)
Deploying Kubernetes in the Enterprise (IBM #Think2019 #7678 Tech Talk)
Michael Elder
 
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
Nico Meisenzahl
 
Free GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOps
Weaveworks
 
Achieving CI/CD with Kubernetes
Achieving CI/CD with Kubernetes
Ramit Surana
 
Going Serverless with Kubeless In Google Container Engine (GKE)
Going Serverless with Kubeless In Google Container Engine (GKE)
Bitnami
 
GitLab London Meetup: How Containerized Pipelines and Kubernetes Can Boost Yo...
GitLab London Meetup: How Containerized Pipelines and Kubernetes Can Boost Yo...
Nico Meisenzahl
 
An Introduction to Kubernetes and Continuous Delivery Fundamentals
An Introduction to Kubernetes and Continuous Delivery Fundamentals
All Things Open
 
Kubernetes Introduction
Kubernetes Introduction
Eric Gustafson
 
Whitepaper automating kuberneteswithgitops 1
Whitepaper automating kuberneteswithgitops 1
Kenneth Nnadikwe
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
Oleg Shalygin
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
HungWei Chiu
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CI
alexanderkiel
 
Continuous Delivery With Containers
Continuous Delivery With Containers
All Things Open
 
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
2016 - Continuously Delivering Microservices in Kubernetes using Jenkins
devopsdaysaustin
 
Kubernetes and Hybrid Deployments
Kubernetes and Hybrid Deployments
Sandeep Parikh
 
Kubernetes Boulder - Kit Merker - Cloud Native Deployment
Kubernetes Boulder - Kit Merker - Cloud Native Deployment
Kit Merker
 
Automated Testing Environments With Kubernetes & GitLab
Automated Testing Environments With Kubernetes & GitLab
Vladislav Supalov
 
KubeCon EU 2016 Keynote: Kubernetes State of the Union
KubeCon EU 2016 Keynote: Kubernetes State of the Union
KubeAcademy
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google Cloud
Samuel Chow
 
Introduction to Kubernetes and GKE
Introduction to Kubernetes and GKE
Opsta
 
Deploying Kubernetes in the Enterprise (IBM #Think2019 #7678 Tech Talk)
Deploying Kubernetes in the Enterprise (IBM #Think2019 #7678 Tech Talk)
Michael Elder
 
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
Nico Meisenzahl
 
Free GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOps
Weaveworks
 
Achieving CI/CD with Kubernetes
Achieving CI/CD with Kubernetes
Ramit Surana
 
Going Serverless with Kubeless In Google Container Engine (GKE)
Going Serverless with Kubeless In Google Container Engine (GKE)
Bitnami
 
GitLab London Meetup: How Containerized Pipelines and Kubernetes Can Boost Yo...
GitLab London Meetup: How Containerized Pipelines and Kubernetes Can Boost Yo...
Nico Meisenzahl
 
An Introduction to Kubernetes and Continuous Delivery Fundamentals
An Introduction to Kubernetes and Continuous Delivery Fundamentals
All Things Open
 
Kubernetes Introduction
Kubernetes Introduction
Eric Gustafson
 
Whitepaper automating kuberneteswithgitops 1
Whitepaper automating kuberneteswithgitops 1
Kenneth Nnadikwe
 
Ad

More from sparkfabrik (20)

Talks on my machine: Drupal, Storybook e SDC
Talks on my machine: Drupal, Storybook e SDC
sparkfabrik
 
Talks on my machine: Drupal CMS versus The Cool Kids
Talks on my machine: Drupal CMS versus The Cool Kids
sparkfabrik
 
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
sparkfabrik
 
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
sparkfabrik
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
sparkfabrik
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
sparkfabrik
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte
sparkfabrik
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
sparkfabrik
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
sparkfabrik
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdf
sparkfabrik
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
sparkfabrik
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloud
sparkfabrik
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplane
sparkfabrik
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagine
sparkfabrik
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
sparkfabrik
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
sparkfabrik
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
sparkfabrik
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWS
sparkfabrik
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Talks on my machine: Drupal, Storybook e SDC
Talks on my machine: Drupal, Storybook e SDC
sparkfabrik
 
Talks on my machine: Drupal CMS versus The Cool Kids
Talks on my machine: Drupal CMS versus The Cool Kids
sparkfabrik
 
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
sparkfabrik
 
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
sparkfabrik
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
sparkfabrik
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
sparkfabrik
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte
sparkfabrik
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
sparkfabrik
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
sparkfabrik
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdf
sparkfabrik
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
sparkfabrik
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloud
sparkfabrik
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplane
sparkfabrik
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagine
sparkfabrik
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
sparkfabrik
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
sparkfabrik
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
sparkfabrik
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWS
sparkfabrik
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Ad

Recently uploaded (20)

Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Azure AI Foundry: The AI app and agent factory
Azure AI Foundry: The AI app and agent factory
Maxim Salnikov
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
ElectraSuite_Prsentation(online voting system).pptx
ElectraSuite_Prsentation(online voting system).pptx
mrsinankhan01
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Azure AI Foundry: The AI app and agent factory
Azure AI Foundry: The AI app and agent factory
Maxim Salnikov
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
ElectraSuite_Prsentation(online voting system).pptx
ElectraSuite_Prsentation(online voting system).pptx
mrsinankhan01
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 

Gitlab ci e kubernetes, build test and deploy your projects like a pro

  • 1. GitlabCI and Kubernetes #build #test and #deploy your projects like a #pro
  • 2. Paolo Mainardi (@paolomainardi) ● CTO @sparkfabrik ● OSS developer, devops automation engineer ● Checkout my projects here: github.com/paolomainardi
  • 4. ● You know what Kubernetes is ● You ever used gitlab ci ● You already have a CI/CD pipeline workflow Raise your hands if
  • 5. Outlines ● What are Kubernetes and Gitlab ● How to create a cluster powered CI/CD pipeline ● Tips and tricks on real world usage.
  • 6. Continuous integration is a tough job... Credits: deis.com/blog/2016/kubernetes-illustrated-guide/
  • 9. Cloud-native is an approach to building and running applications that fully exploits the advantages of the cloud computing model. https://12factor.net - https://pivotal.io/cloud-native
  • 10. ● Handle of application dependencies ● Dev/prod environments parity ● Orchestrate services ● Make easy to deploy to cloud clustered environments Continuous integration is a tough job...
  • 11. Continuous delivery is a software engineering approach to ensure that the software can be reliably released at any time. CD Continuous delivery
  • 12. Continuous deployment is a software engineering approach to ensure that the every change is automatically deployed to production. CD Continuous deployment
  • 14. Cloud orchestrators 9%43% 7% Source: https://sysdig.com/blog/sysdig-docker-usage-report-2017
  • 15. Kubernetes ● A system for container management in a clustered environment, open sourced by Google and inspired by the Borg project. ● Multiple container engines (Docker, rkt, OCI), mainly based on Docker. ● Provides grouping, load balancing, scaling, monitoring and scheduling features with an unified and declarative API. ● 100% open source and written in GO - https://github.com/kubernetes/kubernetes
  • 16. Kubernetes the hard way: Custom installers Kubernetes installation is fairly complex, pick up the right solution: https://kubernetes.io/docs/setup/pick-right-solution https://github.com/kubernetes/kubeadm - https://github.com/kubernetes/kops
  • 17. Kubernetes the easier way: Google GKE One-click Kubernetes clusters, managed by Google: https://cloud.google.com/container-engine
  • 18. Kubernetes the easy way: Google GKE ● Fully managed HA Kubernetes cluster (free up to 5 nodes) ● Logging and monitoring included (Stackdriver) ● Private container registry - https://cloud.google.com/container-registry/ ● Automatic and configurable cluster scaling
  • 19. Kubernetes the easy way: Google GKE gcloud container clusters list NAME ZONE MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS My-testing-clust europe-west1-b 1.5.6 172.199.00.000 n1-standard-1 1.5.6 2 RUNNING
  • 20. Gitlab The platform for modern developers GitLab unifies issues, code review, CI and CD into a single UI https://about.gitlab.com
  • 21. Gitlab Runner The fully integrated solution to build test and deploy your code. https://about.gitlab.com/gitlab-ci/
  • 22. Gitlab Runner ● It is the daemon that run the jobs and send the results back to Gitlab ● One single binary written in GO, very easy to deploy ● Allows to run multiple jobs concurrently ● Native supports for storing cache and artifacts ● It supports multiple build executors including Kubernetes ● Programmatic pipelines definition using a .gitlab-ci.yml file
  • 23. Gitlab Kubernetes executor The Kubernetes executor, connects to the Kubernetes API in the cluster creating a Pod for each GitLab CI Job. https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/executors/kubernetes.md
  • 24. config.toml concurrent = 4 [[runners]] name = "Kubernetes Runner" url = "https://gitlab.com/ci" token = "......" executor = "kubernetes" [runners.kubernetes] host = "https://45.67.34.123:4892" cert_file = "/etc/ssl/kubernetes/api.crt" namespace = "gitlab" privileged = true cpu_limit = "1" memory_limit = "1Gi" service_cpu_limit = "1" service_memory_limit = "1Gi" helper_cpu_limit = "500m" helper_memory_limit = "100Mi" [runners.kubernetes.node_selector] "cloud.google.com/gke-nodepool" = "gitlab-ci" Container limits and resources Node selector Kubernetes host
  • 25. .gitlab-ci.yml image: docker:latest stages: - build - deploy build: stage: build script: - docker build -t containerday/my-cool-app:${GIT_COMMIT} . - docker run containerday/my-cool-app:${GIT_COMMIT} go test -run ./ - docker push containerday/my-cool-app:${GIT_COMMIT} .
  • 29. Continuous deployment With environments, you can control the Continuous Deployment of your software all within GitLab. https://about.gitlab.com/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/
  • 30. image: docker:latest .gitlab-ci.yml stages: - build - deploy build: stage: build script: - docker build -t containerday/my-cool-app:${GIT_COMMIT} . - docker run containerday/my-cool-app:${GIT_COMMIT} go test -run ./ - docker push containerday/my-cool-app:${GIT_COMMIT} . deploy: stage: deploy environment: name: production url: http://foobar.example.com variables: - IMAGE_DEPLOY: containerday/image:${CI_BUILD_REF_NAME} scripts: # auth - kubectl config set-cluster my-cluster --server="$KUBE_URL" $KUBE_CLUSTER_OPTIONS - kubectl config set-credentials my-cluster --token="$KUBE_TOKEN" $KUBE_CLUSTER_OPTIONS # deploy - envsubst < k8s/deployment.template.yml > "k8s/deployment.yml" - kubectl apply -f k8s/deployment.yml
  • 32. Gitlab continuous deployment Monitoring with Prometheus https://docs.gitlab.com/ce/user/project/integrations/prometheus.html
  • 35. Running Gitlab on Kubernetes Self hosting Gitlab on Kubernetes https://gitlab.com/gitlab-org/kubernetes-gitlab-demo
  • 40. Running Gitlab on Kubernetes tips&tricks ● Segment your cluster by labelling the nodes and use the nodeSelector ● Make a correct use of namespacing for deploying ● Adjust correctly the limits/requests resources of Gitlab executor to help the pod scheduling ● Keep the k8s templates on version control together with the codebase ● Make a smart use of caches, remember than each job is a clean build env ● Gitlab is an open source project, submit issues and share the fixes
  • 41. Troubleshooting and debugging Accessing to a pod internal port > kubectl port-forward mysql-pod [-c container] 3306:3306 > mysql -hlocalhost -uroot -
  • 42. Troubleshooting and debugging Getting a shell to a running container > kubectl exec -it mysql-pod [-c container] bash
  • 43. Troubleshooting and debugging Show gitlab executor pod metrics > kubectl top pod runner-329d5212-project-255-concurrent-07rxsl -ngitlab --containers POD NAME CPU(cores) MEMORY(bytes) runner-329d5212-project-255-concurrent-07rxsl build 1m 35Mi runner-329d5212-project-255-concurrent-07rxsl helper 0m 13Mi runner-329d5212-project-255-concurrent-07rxsl svc-0 604m 248Mi
  • 44. Troubleshooting and debugging Get container logs > kubectl logs -f mysql-pod [-c container] bash