Giter VIP home page Giter VIP logo

cicd-training-1's Introduction

Virtualbox kurulumu

https://www.virtualbox.org/wiki/Downloads adresinden uygun kurulum paketi indirilerek kurulum gerçekleştirilir.

Sanal sunucu oluşturulması

  • debian-live-11.6.0-amd64-standard.iso dosyası indirilerek Virtualbox üzerinde yeni bir sanal sunucu oluşturulur (Name: Jenkins, Memory: 2048 MB, cpu: 1, Disk: 20GB).
  • Açılış menüsünde VBoxUnatendedInstall seçilerek kurulum başlatılır.
  • Kurulum sonrası makine kapatılarak Machine -> Settings ekranında network ayarlarında "Bridged Adaptor" seçilerek makine start edilir.
  • VM'e ssh ile bağlanabilmek için aşağıdaki komutlar çalıştırılır:
su - root
apt update && apt install openssh-server -y
usermod -aG sudo vboxuser
ip a
  • IP adresinin sabit kalması için /etc/network/interfaces dosyası içinde ilgili network interface ayarları aşağıdaki şekilde düzenlenerek sunucu reboot edilir. Not: Parametreler bulunduğunuz networkün ayarlarına uygun olmalı.
...
# The primary network interface
#allow-hotplug enp0s3
#iface enp0s3 inet dhcp

auto enp0s3
iface enp0s3 inet static
 address 192.168.1.28
 netmask 255.255.255.0
 gateway 192.168.1.1
 dns-domain home
 dns-nameservers 192.168.1.1
  • Yukarıdaki adımlar tekrar uygulanarak aynı ayarlarla app-server adıyla bir sanal sunucu daha oluşturulur.
echo <jenkins_ip_adresi> jenkins >> C:\Windows\System32\drivers\etc\hosts
echo <app-server_ip_adresi> app-server >> C:\Windows\System32\drivers\etc\hosts
  • Windows ayarlarında Apps & Features / Optional Fetures ekranında OpenSSH Client uygulamasının kurulu olduğu teyit edilir.
  • Windows terminal ekranıonda ssh vboxuser@jenkins komutuyla VM'e bağlanılır.
  • Tercihen sunuculara public key authentication ile girebilmek için Windows terminalde "ssh-keygen -t rsa -b 4096" komutuyla key oluşturularak .ssh/id_rsa.pub dosyasının içeriği hedef sunucuda .ssh/authorized_keys dosyası içerisine eklenir.

Jenkins kurulumu

  • Paket depolarına erişim için gerekli key dosyası sisteme eklenir:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \
    /usr/share/keyrings/jenkins-keyring.asc > /dev/null
  • Repository listesi sisteme eklenir:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
    https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
    /etc/apt/sources.list.d/jenkins.list > /dev/null
  • Paket indexi güncellenir ve kurulum gerçekleştirilir:
sudo apt-get update
sudo apt-get install fontconfig openjdk-17-jdk git maven vim acl
sudo apt-get install jenkins
sudo echo <app-server_ip_adresi> app-server >> /etc/hosts
sudo -u jenkins ssh-keygen -t rsa -b 4096

Uygulama sunucusunun hazırlanması

  • Uygulama dizinlerini ve çalıştıracak kullanıcıyı oluşturuyoruz.
sudo useradd -d /opt/spring-petclinic spring-petclinic
sudo passwd spring-petclinic
  • Deployment kullanıcısını oluşturuyoruz.
sudo useradd jenkins
sudo passwd jenkins
  • jenkins user için uygulama dizinine yazma yetkisi veriyoruz.
sudo setfacl -m u:jenkins:wx /opt/spring-petclinic
  • Jenkins sunucusundan jenkins user ssh key'ini app-server sunucusuna kopyalıyoruz.
sudo su - jenkins
ssh-copy-id jenkins@app-server
  • Systemd servisini oluşturup uygulamayı başlatıyoruz.
sudo vim /lib/systemd/system/spring-petclinic.service
cd /etc/systemd/system/multi-user.target.wants
sudo ln -s /lib/systemd/system/spring-petclinic.service spring-petclinic.service
sudo systemctl enable spring-petclinic.service
sudo systemctl start spring-petclinic.service
sudo systemctl status spring-petclinic.service
  • jenkins user ile servisi restart edebilmek için aşağıdaki 2 satırı içeren sudoer dosyası oluşturuyoruz
sudo visudo -f /etc/sudoers.d/spring-petclinic 
Cmnd_Alias COMMANDS = /usr/bin/systemctl restart spring-petclinic.service
jenkins ALL = (root) NOPASSWD: COMMANDS

cicd-training-1's People

Contributors

osmanizbat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.