Skip to content

Instantly share code, notes, and snippets.

@mebaysan
Last active December 6, 2022 17:07
Show Gist options
  • Save mebaysan/e7c6b24905727578b51c62fd56867c4c to your computer and use it in GitHub Desktop.
Save mebaysan/e7c6b24905727578b51c62fd56867c4c to your computer and use it in GitHub Desktop.
DevOps-101 | Gerçek Bir CI & CD Pipeline: Docker - Jenkins - GitHub Actions - Nginx

DevOps - 101

Buradan Youtube video linkine ulaşabilirsiniz.

Kullandığımız teknolojiler:

  • Python
  • Docker
  • Jenkins
  • Nginx
  • GitHub
    • GitHub Actions
  • Git
  • Fedora 36

Bu videoda değinmeye çalıştığımız konular aşağıdaki gibidir;

  • DevOps Nedir?
  • DevOps Mindset and Culture, UC Davis kursunu takip ederken aldığım notlar ve önemli noktalar
  • Python projemizi tanıyalım
  • Docker nedir ve basit bir Streamlit (Python) uygulamasının dockerize edilmesi
  • GitHub actions nedir?
    • 2 adet GitHub workflow oluşturalım (CI)
      1. Docker image oluşturma ve Docker Hub'a göndermek için bir workflow
      2. Docker Hub image readme güncelleme workflow
  • Jenkins nedir?
    • Arayüzü tanıyalım ve kullanıcı oluşturalım
  • Web projemizi deploy etmek için jenkins pipeline ve Jenkinsfile oluşturalım (CD)
    • GitHub Actions ile Jenkins trigger edelim
  • Nginx nedir?
  • Container'a domain bağlamak için Nginx konfigürasyonu yapalım

Videoyu İzle

Faydalı Kaynaklar

  • Kullandığımız codebase
  • "DevOps Culture and Mindset" Notlarım
  • Nginx script için "Easily-Dockerize-Django-Prod-Dev" Projesi
    • server {
          # `listen` can be changed for your nginx service in docker-compose.yml
          listen 80;
          listen [::]:80;
          server_name YOUR_URL(S);
          server_name_in_redirect off;
      
          access_log /var/log/nginx/reverse-access.log;
          error_log /var/log/nginx/reverse-error.log;
      
          location / {
              proxy_set_header Client-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $host;
              proxy_pass http://127.0.0.1:81; # because baysan_nginx service is listening 81 port on host
          }
      }
  • cd.yml
    • name: CD (Trigger Jenkins Job)
      
      on:
      workflow_run:
          workflows: ["CI"]
          branches: [main]
          types:
          - completed
      
      jobs:
          deploy:
              name: Build
              runs-on: ubuntu-latest
              steps:
              - name: Trigger Jenkins Deployment Job
              uses: appleboy/jenkins-action@master
              with:
                  url: "${{ secrets.JENKINS_SERVER_URL }}"
                  user: "${{ secrets.JENKINS_SERVER_USERNAME }}"
                  token: "${{ secrets.JENKINS_SERVER_TOKEN }}"
                  job: "${{ secrets.JENKINS_JOB_NAME }}"
  • Jenkinsfile
    • pipeline{
          agent any
          stages{
              stage("Pull & Deploy Docker Image"){
                  steps{
                      sh '''
                          docker pull mebaysan/turkey-earthquake-crisis-app:latest
                          docker container rm -f eq-app 
                          docker run -d -p 81:8080 --name eq-app mebaysan/turkey-earthquake-crisis-app                    
                      '''
                  }
                }
              }
            }
  • Streamlit "unsupported error" çözümü
    • Açıkçası Streamlit ile pek uğraşım olmamıştı. Kolay olması için tercih etmiştim. Uygulamayı CI & CD pipeline ile deploy edebildik. Fakat sonda beklenmeyen bir proxy hatası çıktı :& Bunu da ben dahil çoğumuz biraz araştırma ile çözerdi diye düşünüyorum. Çözüm linki yukarıdadır ^^

Önemli Bulduğum Noktalar

Roots of DevOps lie in lean management

DevOps is about humans. DevOps is a set of practices and patterns that turn human capital into high-performance organizational capital. - John Willis

Organization’s #1 Number Assets is People

High-performing organizations deploy on demand and multiple deploys per day

It’s important to track and manage workloads at the team level

Best way to solve a problem: make it visible

WIP ⇒ Work In Process

  • Only work on a set number of things at once
  • Start next thing only after finishing something

Prioritizing is Important

Focus on deploying smaller changes more frequently

We can and do deploy or release our application independently of other applications and services it depends on. - High-performing organizations agree

Coupling = Refers to dependencies between various mechanisms in a system. Can be tight or loose. We should chase for loose coupled architecture.

Shifting From Outputs to Outcomes

  • Output = what we deliver
  • Outcome = what we gain from output

"It’s about people and creating a culture of focusing on delivering value for the customer.”

@mebaysan
Copy link
Author

mebaysan commented Dec 6, 2022

The Complete NGINX Cookbook kitabında belirtildiği gibi videoda kullandığım yöntem deprecate olmuş...

/etc/nginx/conf.d/
The /etc/nginx/conf.d/ directory contains the default HTTP server configura‐
tion file. Files in this directory ending in .conf are included in the top-level
http block from within the /etc/nginx/nginx.conf file. It’s best practice to uti‐
lize include statements and organize your configuration in this way to keep
your configuration files concise. In some package repositories, this folder is
named sites-enabled, and configuration files are linked from a folder named
site-available; this convention is deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment