ΠΡΠΈΠ²Π΅Ρ!
μ μ΄λ¦μ Sergeyμ΄κ³ Tinkoff.ru νλ«νΌμ API νμμ μΈνλΌ μμ§λμ΄λ‘ μΌνκ³ μμ΅λλ€.
μ΄ κΈ°μ¬μμλ μ°λ¦¬ νμ΄ λ°Έλ°μλ₯Ό μ€λΉν λ μ§λ©΄νλ λ¬Έμ μ λν΄ μ΄μΌκΈ°νκ² μ΅λλ€. λ€μν νλ‘μ νΈλ₯Ό μν΄. λν λλΆλΆμ λ¬Έμ λ₯Ό 극볡ν μ μκ² ν΄μ€ λꡬμ λν΄μλ λ§μλλ¦¬κ² μ΅λλ€.
Nginxλ λ€κΈ°λ₯μ΄λ©° νλ°ν κ°λ°λκ³ μλ νλ‘μ μλ²μ λλ€. λ§μ μμ λͺ¨λμ κ°μΆκ³ μμΌλ©°, . κ° νλ‘μ νΈλ λ°Έλ°μμ κΈ°λ₯κ³Ό Nginx λ²μ (μ: http/2 λ° grpc νλ‘μ μ‘΄μ¬) λ° λͺ¨λ ꡬμ±μ λν νΉμ μꡬ μ¬νμ λΆκ³Όν©λλ€.
μ ν¬λ νΉμ λ°°ν¬νμμ μ€νλλ, νμν λͺ¨λ μΈνΈκ° ν¬ν¨λ μ΅μ λ²μ μ λ³΄κ³ μΆμ΅λλ€. Linuxλ³Έ κΈμμλ deb λ° rpm κΈ°λ° μμ€ν μ λ€λ£Ήλλ€. 컨ν μ΄λ κΈ°λ° μμ€ν μ κ³ λ €νμ§ μμ΅λλ€.
μ°λ¦¬λ λ°Έλ°μμ κΈ°λ₯μ μ μνκ² λ³κ²½νκ³ μΆμ΅λλ€. κ·Έλ¦¬κ³ μ¬κΈ°μ μ¦μ μ§λ¬Έμ΄ μκΉλλ€. κ°λ₯ν ν μ μ μμμ μλΉνλ©΄μ μ΄λ₯Ό λ¬μ±νλ λ°©λ²μ 무μμ λκΉ? μ νν μμ μ λ ₯ λ§€κ°λ³μλ₯Ό μ§μ ν μ μκ³ μΆλ ₯μμ ββμνλ OSμ λν deb/rpm ν¨ν€μ§ νμμ μν°ν©νΈλ₯Ό μμ ν μ μλλ‘ νλ‘μΈμ€λ₯Ό μ€μ νλ κ²μ΄ ν¨μ¬ λ μ’μ΅λλ€.
κ²°κ³Όμ μΌλ‘ λ€μκ³Ό κ°μ μ¬λ¬ κ°μ§ λ¬Έμ κ° κ³΅μνλ μ μμ΅λλ€.
- νμ μ΅μ λ²μ μ Nginxκ° ν¬ν¨λ ν¨ν€μ§κ° μλ κ²μ μλλλ€.
- νμ λͺ¨λμ΄ ν¬ν¨λ ν¨ν€μ§κ° μμ΅λλ€.
- ν¨ν€μ§λ₯Ό μλμΌλ‘ μ»΄νμΌνκ³ λΉλνλ κ²μ μκ°μ΄ λ§μ΄ κ±Έλ¦¬κ³ λ§€μ° μ§λ£¨ν©λλ€.
- μ΄ Nginx μΈμ€ν΄μ€κ° μ΄λ»κ² 쑰립λλμ§μ λν μ€λͺ μ μμ΅λλ€.
μ΄λ¬ν λ¬Έμ λ₯Ό ν΄κ²°νλ €λ©΄ μ¬λμ΄ μ½μ μ μλ νμμ μ¬μμ μ λ ₯μΌλ‘ μ¬μ©νκ³ μ΄λ₯Ό κΈ°λ°μΌλ‘ νμν κΈ°λ₯μ κ°μΆ Nginx ν¨ν€μ§λ₯Ό μ‘°ν©νλ λκ΅¬κ° νμν©λλ€.
λ°©λν Githubμμ μ ν©ν μ΅μ μ μ°Ύμ§ λͺ»ν΄ μ°λ¦¬λ μ체 λꡬλ₯Ό λ§λ€κΈ°λ‘ κ²°μ νμ΅λλ€. .
λͺ μΈμ
μ°λ¦¬ λꡬμμλ μ½λ νμμΌλ‘ μ¬μμ λν μ€λͺ μ μμ±νμ¬ Git μ μ₯μμ λ£μ μ μκΈ°λ₯Ό μνμ΅λλ€. μ΄λ₯Ό μν΄ μ°λ¦¬λ μ΄λ¬ν μμ μ μ΅μν νμμΈ yamlμ μ ννμ΅λλ€. μ¬μ μ:
nginx_version: 1.14.1
output_package: deb
modules:
- module:
name: nginx-auth-ldap
git_url: https://github.com/kvspb/nginx-auth-ldap.git
git_branch: master
dependencies:
- libldap2-dev
- module:
name: ngx_http_substitutions_filter_module
git_url: https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
- module:
name: headers-more-nginx-module
web_url: https://github.com/openresty/headers-more-nginx-module/archive/v0.261.zip
- module:
name: nginx-module-vts
git_url: https://github.com/vozlt/nginx-module-vts.git
git_tag: v0.1.18
- module:
name: ngx_devel_kit
git_url: https://github.com/simplresty/ngx_devel_kit.git
git_tag: v0.3.0
- module:
name: ngx_cache_purge
git_url: https://github.com/FRiCKLE/ngx_cache_purge.git
- module:
name: ngx_http_dyups_module
git_url: https://github.com/yzprofile/ngx_http_dyups_module.git
- module:
name: nginx-brotli
git_url: https://github.com/eustas/ngx_brotli.git
git_tag: v0.1.2
- module:
name: nginx_upstream_check_module
git_url: https://github.com/yaoweibin/nginx_upstream_check_module.git
- module:
name: njs
git_url: https://github.com/nginx/njs.git
git_tag: 0.2.5
config_folder_path: nginx
μ¬κΈ°μλ νμ λͺ¨λ μΈνΈκ° ν¬ν¨λ Nginx λ²μ 1.14.2μ deb ν¨ν€μ§λ₯Ό λ³΄κ³ μΆλ€λ κ²μ λνλ λλ€. λͺ¨λμ΄ μλ μΉμ μ μ ν μ¬νμ λλ€. κ°κ°μ λν΄ λ€μμ μ€μ ν μ μμ΅λλ€.
- μ΄λ¦μ λλ€.
- λ°μ μ μλ μ£Όμ:
- Git μ μ₯μ. λΆκΈ°λ νκ·Έλ₯Ό μ§μ ν μλ μμ΅λλ€.
- μμΉ΄μ΄λΈ μΉ λ§ν¬.
- μμΉ΄μ΄λΈμ λν λ‘컬 λ§ν¬.
μΌλΆ λͺ¨λμλ μΆκ° μ’ μμ±μ μ€μΉν΄μΌ ν©λλ€. μλ₯Ό λ€μ΄ nginx-auth-ldapμλ libldap2-devκ° μ€μΉλμ΄ μμ΄μΌ ν©λλ€. λͺ¨λμ μ€λͺ ν λ νμν μ’ μμ±μ μ§μ ν μλ μμ΅λλ€.
νκ²½
μ ν¬ λꡬλ₯Ό μ¬μ©νλ©΄ μ»΄νμΌ, ν¨ν€μ§ λΉλ λ° κΈ°ν 보쑰 μννΈμ¨μ΄μ νμν μ νΈλ¦¬ν°κ° μ€μΉλ νκ²½μ μ μνκ² μμ±ν μ μμ΅λλ€. νμν λͺ¨λ κ²μ΄ ν¬ν¨λ Docker 컨ν μ΄λκ° μ΄λ¬ν λͺ©μ μ μ΄μμ μ λλ€(μ μ₯μμλ μ΄λ―Έ λͺ κ°μ§ μν Docker νμΌμ΄ ν¬ν¨λμ΄ μμ΅λλ€). ubuntu ΠΈ centos).
μ¬μμ΄ μμ±λκ³ νκ²½μ΄ μ€λΉλ ν μ΄μ μ μ’ μμ±μ μ€μΉν λΉλλ₯Ό μμν©λλ€.
pip3 install -r requirements.txt
./main.py build -f [ΠΊΠΎΠ½ΡΠΈΠ³_ΡΠ°ΠΉΠ»].yaml -r [Π½ΠΎΠΌΠ΅Ρ_ΡΠ΅Π²ΠΈΠ·ΠΈΠΈ]
μ¬κΈ°μ κ°μ λ²νΈλ μ ν μ¬νμ΄λ©° μ΄μ
λΈλ¦¬ λ²μ κ΄λ¦¬μ μ¬μ©λ©λλ€. μ΄λ ν¨ν€μ§μ λ©ν μ 보μ κΈ°λ‘λλ―λ‘ μλ²μμ μ½κ² μ
λ°μ΄νΈν μ μμ΅λλ€.
λ‘κ·Έλ₯Ό ν΅ν΄ λ¬΄μ¨ μΌμ΄ μΌμ΄λκ³ μλμ§ λͺ¨λν°λ§ν μ μμ΅λλ€. μ£Όμ μ¬νμ μλ λ€μκ³Ό κ°μ΅λλ€.
builder - INFO - Parse yaml file: example.config.yaml
builder - INFO - Download scripts for build deb package
builder - INFO - Downloading nginx src...
builder - INFO - --> http://nginx.org/download/nginx-1.14.1.tar.gz
builder - INFO - Downloading 3d-party modules...
builder - INFO - Module nginx-auth-ldap will download by branch
builder - INFO - -- Done: nginx-auth-ldap
builder - INFO - -- Done: ngx_http_substitutions_filter_module
builder - INFO - Module headers-more-nginx-module will downloading
builder - INFO - Module nginx-module-vts will download by tag
builder - INFO - -- Done: nginx-module-vts
builder - INFO - Module ngx_devel_kit will download by tag
builder - INFO - -- Done: ngx_devel_kit
builder - INFO - -- Done: ngx_cache_purge
builder - INFO - -- Done: ngx_http_dyups_module
builder - INFO - Downloading dependencies
builder - INFO - Building .deb package
builder - INFO - Running 'dh_make'...
builder - INFO - Running 'dpkg-buildpackage'...
dpkg-deb: building package 'nginx' in '../nginx_1.14.1-1_amd64.deb'.
λ°λΌμ λͺ κ°μ§ λͺ λ Ήλ§μΌλ‘ νκ²½κ³Ό νμν Nginx μ΄μ λΈλ¦¬λ₯Ό μμ±νλ©΄ μ€ν¬λ¦½νΈκ° μ€νλλ λλ ν°λ¦¬μ ν¨ν€μ§κ° λνλ©λλ€.
μλ² λ©
λν λꡬλ₯Ό CI/CD νλ‘μΈμ€μ ν΅ν©ν μλ μμ΅λλ€. μλ₯Ό λ€μ΄ μ€λλ μ‘΄μ¬νλ λ§μ CI μμ€ν μ€ νλκ° μ΄μ λμμ΄ λ μ μμ΅λλ€. λλ .
κ²°κ³Όμ μΌλ‘ Git μ μ₯μμ μ¬μμ΄ λ³κ²½λ λλ§λ€ μν°ν©νΈ λΉλκ° μλμΌλ‘ μμλ©λλ€. κ°μ λ²νΈλ λΉλ μ€ν μΉ΄μ΄ν°μ μ°κ²°λμ΄ μμ΅λλ€.
μκ°μ΄ μ’ λ μμΌλ©΄ λ‘컬 ν¨ν€μ§ μ μ₯μ, Nexus, Artifactory λ±μΌλ‘ μ μ‘λλλ‘ μν°ν©νΈλ₯Ό ꡬμ±ν μ μμ΅λλ€.
μΆκ°μ μΈ μ΄μ μ yaml κ΅¬μ± νμΌμ Ansible λλ λ€λ₯Έ μλ κ΅¬μ± μμ€ν μ μ°κ²°ν μ μκ³ κ±°κΈ°μμ λ°°ν¬νλ €λ λ²μ λ²νΈμ ν¨ν€μ§ μ νμ κ°μ Έμ¬ μ μλ€λ κ²μ λλ€.
λ€μ λ¨κ³
νλ‘μ νΈκ° μμ§ μλ£λμ§ μμμ΅λλ€. νμ¬ μ°λ¦¬κ° μμ νκ³ μλ μμ μ λ€μκ³Ό κ°μ΅λλ€.
- μ°λ¦¬λ κ΅¬μ± κ°λ₯μ±μ νμ₯νλ λμμ κ°λ₯ν ν λ¨μνκ² μ μ§ν©λλ€. λ κ°λ§ νμνκ³ λλ¨Έμ§λ κΈ°λ³Έμ μΌλ‘ μ ν©νλ€λ©΄ μ² κ°μ λ§€κ°λ³μλ₯Ό μ μνκ³ μΆμ§ μμ κ²μ λλ€. μ¬κΈ°μλ μ»΄νμΌ νλκ·Έ(μ΄μ λ΄λΆ κ΅¬μ± νμΌ src/config.pyμμ λ³κ²½ν μ μμ), μ€μΉ κ²½λ‘ λ° μμ μ¬μ©μκ° ν¬ν¨λ©λλ€.
- λ€μν μν°ν©νΈ μ μ₯μμ ν¨ν€μ§λ₯Ό μλμΌλ‘ 보λ΄λ μ΅μ μ μΆκ°νκ³ μμ΅λλ€.
- λͺ¨λμ λ‘λν λ μ¬μ©μ μ μ λͺ λ Ήμ μ€νν©λλ€(μ: λ¨Όμ νΉμ λ²μ μ ν¨μΉλ₯Ό μ μ©ν΄μΌ ν©λλ€)
- ν
μ€νΈ μΆκ°:
- ν¨ν€μ§κ° μ¬λ°λ₯΄κ² μ€μΉλμμ΅λλ€.
- Nginxμλ νμ λ²μ μ΄ μμΌλ©° νμ νλκ·Έ λ° λͺ¨λλ‘ λΉλλμμ΅λλ€.
- νμν κ²½λ‘, κ³μ λ±μ΄ μμ±λ©λλ€.
νμ§λ§ μ΄μ μ΄ λꡬλ₯Ό μ¬μ©νκ³ κ°μ μ¬νμ μ μν μλ μμ΅λλ€. μ΄μ μ€μΈμ!
μΆμ² : habr.com
