ãã®èšäºã§ã¯ãAnsibleãDocker SwarmãJenkinsãPortainerãªã©ã®ãã¯ãããžãŒã䜿çšããŠãçŸããWebã€ã³ã¿ãŒãã§ãŒã¹ã䜿çšããŠå¶åŸ¡ã§ããCI / CDãã€ãã©ã€ã³ãå®è£ ããæ¹æ³ã«ã€ããŠèª¬æããŠããŸãã
ãšã³ããªãŒ
éçºè ã¯éåžžäœãæãã§ããŸããïŒ åœŒã¯ãéãèããã«ããããŠèªåã®åµé æ§ã®çµæãã§ããã ãæ©ãèŠãããšèããŠããŸãã
äžæ¹ãããå€ãã®ãéãå¿ èŠãšããããžãã¹ãããããã補åãåžå Žã«åºããŸã§ã®æéãççž®ããããšãåžžã«èããŠããŸãã èšãæããã°ãããžãã¹ã¯ãMVPïŒå¥åãMinimum Viable ProductïŒã®è²·åãæ°è£œåãŸãã¯æ¢å補åã®æŽæ°æã«ã¹ããŒãã¢ããããããšã倢èŠãŠããŸãã
ããŠã管çè ã¯äœãæãã§ããŸããïŒ ãããŠã管çè ã¯åçŽãªäººã§ãã圌ã¯ãµãŒãã¹ãèœã¡ãã
人çã®çå®ã瀺ãããã«ã管çè ã®æ¬²æãå®çŸããããã«ãä»ã®ããŒããŒã®å€¢ã圌ã®åã«ãã£ãŠå®çŸãããªããã°ãªããªããããITããŒãã£ãŒã®ä»£è¡šè ã¯ããã«å€ãã®åªåãããŸããã å€ãã®å ŽåãDevOpsæ¹æ³è«ã«æºæ ããCI / CDïŒç¶ç¶çã€ã³ãã°ã¬ãŒã·ã§ã³ãšé ä¿¡ïŒã®ååãå®è£ ããŠãç®çãéæããããšãã§ããŸããã
ããã¯ãUrals IT Directorateã®å°ããªãããžã§ã¯ãã§çºçããŸããããã®ãããžã§ã¯ãã§ã¯ãéçºè ãããŒãžã§ã³ç®¡çã·ã¹ãã ã«ãœãŒã¹ã®å€æŽãå ¬éãããã¹ãç°å¢ã§ã¢ããªã±ãŒã·ã§ã³ã®æ°ããããŒãžã§ã³ãèªåçã«èµ·åãããŸã§ã®å®å šãªãã€ãã©ã€ã³ãçæéã§å®è£ ããããšãã§ããŸããã
ããŒã0ãã¿ã¹ã¯ã®èª¬æ
ã·ã¹ãã æ§æ
è°è«ã®åŸãããŒã ã¯æ¬¡ã®2å±€ã¢ãŒããã¯ãã£ãéžæããŸããã
- Spring Bootãã¬ãŒã ã¯ãŒã¯ã«å®è£ ãããJavaããã¯ãšã³ãã¯ãããŸããŸãªããŒã¿ããŒã¹ãä»ã®äŒæ¥ã·ã¹ãã ãšéä¿¡ããŸãïŒç°¡åãè¿ éãæ確ãªèšè¿°æ¹æ³ã®ããïŒã
- ããã³ããšã³ãã¯éåžžã«é«éã«åäœãããããNodeJSäžã«ãããŸãïŒReactJSã¯ãã©ãŠã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã§ãïŒã
次ã«ããããã®ã³ã³ããŒãã³ãã«NGINXãµãŒããŒãè¿œå ãããŸãããããã¯NodeJSã¢ããªã±ãŒã·ã§ã³ã®ããã³ããšã³ãã§ãã ãã®åœ¹å²ã¯ãã¢ããªã±ãŒã·ã§ã³èªäœãšã·ã¹ãã ã®ä»ã®ã€ã³ãã©ã¹ãã©ã¯ãã£ã³ã³ããŒãã³ãéã§èŠæ±ãåæ£ããããšã§ãããããã«ã€ããŠã¯ã以äžã§èª¬æããŸãã
ããŒã ã¯äœãæ±ããŠããŸããã
æ°ãããããžã§ã¯ãã«éä¿¡å·ãäžãããããšããã«ãæåã®æè¡çã¿ã¹ã¯ãããªãã¡ãæ°ãããããžã§ã¯ããç«ã¡äžããããã®ãæ©åšãã®æºåãçŸããŸããã ãã¹ãŠã®åå è ã«ãšã£ãŠãæ°ããããŒãžã§ã³ããµãŒããŒã«ããŒã«ã¢ãŠãããæ倧ã®å¹çããªããã°ããããžã§ã¯ãã®éçºã¯éåžžã«é£ããããšã¯æããã ã£ãã®ã§ãããã«å®å šãªCI / CDã®ãã¹ã«åŸãããšã«ãªããŸãã ç§ã¯æ¬¡ã®ãã€ãã©ã€ã³ãéæããããšæããŸããã
- éçºè ã¯ãå€æŽãããŒãžã§ã³ç®¡çã·ã¹ãã ïŒgitïŒã«å ¬éïŒã³ãããïŒããŸãã
- gitã¯ãå¿ èŠãªå±æ§ïŒããšãã°ãæ£ããã³ãããã¡ãã»ãŒãžãã©ãŒãããïŒã®ååšãéè¡ã®ãã¶ã€ã³ã¹ã¿ã€ã«ã®éµå®ãããã³ãã®ä»ã®å®åå¶åºŠã«ã€ããŠãã³ãããã®å 容ã®æå°éã®å¿ èŠãªãã¹ããå®æœããŸãã
- git-serverã¯web-hooksã®ã¡ã«ããºã ãä»ããŠJenkinsç¶ç¶ççµ±åãµãŒããŒãåŒãåºããŸãã
- Jenkinsã¯ãgitãããœãŒã¹ã®çŸåšã®ããŒãžã§ã³ãããŠã³ããŒãããCI / CDãã€ãã©ã€ã³ãå®è¡ããæäœãéå§ããŸãã
- ãœãŒã¹ã®ã³ã³ãã€ã«ãšåæãã¹ãã
- Dockerã€ã¡ãŒãžã®æ°ããããŒãžã§ã³ãçµã¿ç«ãŠãŸãïŒ2018幎ã«ãã¢ã¡ã¿ã«ãŸãã¯ä»®æ³ãã·ã³ã«äœããå±éããã®ã¯äžåã§ãã圌ãã¯ç解ããŸããïŒã
- ArtifactoryïŒãã€ããªã¢ãŒãã£ãã¡ã¯ãã®ã¹ãã¬ãŒãžããã³ç®¡çã·ã¹ãã ãæšå¥šïŒïŒã§ç»åãå ¬éããŸãã
- æŽæ°ãããŸãæåããªãã£ãå Žåã«ããµãŒããŒäžã®ã¢ããªã±ãŒã·ã§ã³ã®æ°ããããŒãžã§ã³ïŒãŸãã¯ã¢ããªã±ãŒã·ã§ã³ã®ãã¹ã¿ãã¯ãå šäœïŒãåã®ããŒãžã§ã³ã«ãããŒã«ããã¯ãããŠåèµ·åããã
ãã¬ãŒã ã¯ãŒã¯
ãã®ããŒãã®äººã ã¯ããããããã¯ãã«ããã¹ãã¡ãœã¹/ãã©ãœã³ã®ãããªãçç£æºåã®æŽã£ãããœãªã¥ãŒã·ã§ã³ã§ã¯ãªããæŸèæã䜿çšããŠããã®ã¯ãªããããšè³ªåããŠããã§ãããã åæ§ã®è³ªåã¯éåžžã«åççã§ããããã説æãããœãªã¥ãŒã·ã§ã³ã¯æ¬¡ã®ãããªããŸããŸãªçç±ã§äœ¿çšããããšããã«èšã£ãŠãã ããã
- ããã¯ããåçŽã§ãïŒãã£ãšç°¡åã§ãïŒã
- ããŒã å šäœã§ç解ãã管çè ãå±éããæ¹ãç°¡åã§ããã
ãã ãããœãªã¥ãŒã·ã§ã³ãæŸèæã®è±å¯ãªãã¡ããªã«å±ããŠããããšãå¿ããªãã§ãã ãããè¿ãå°æ¥ãããæšæºçãªOpenShift + Bambooã¹ã¿ãã¯ã«ç§»è¡ããããšãæãã§ããŸãã
ããã«ããã®èšäºã¯Webæåã®ã¢ããªã±ãŒã·ã§ã³ã®ã¿ã«é¢ä¿ããããŒã¿ãããããã©ããã«ããã®ã«ããŒã¿ãã©ããã«ãããä¿åããããšãèããŠããªãå Žåã®ã¹ããŒãã¬ã¹ã¢ãŒããã¯ãã£ã®çæ³çãªã±ãŒã¹ã«ã€ããŠã説æããŸãã
ããŒã1.ãã¹ãã·ã¹ãã ã§ã®ãœãããŠã§ã¢ã®ã€ã³ã¹ããŒã«ãšåºæ¬æ§æ
ãã§ãŒã³å šäœã®èªååãšé«ãåçŸæ§ãæ倧åããããã«ããã¹ãã·ã¹ãã ïŒVMWare / qemu KVM /ã¯ã©ãŠã/ãã®ä»ã«åºã¥ãä»®æ³ãã·ã³ïŒã¯ãAnsibleæ§æ管çã·ã¹ãã ã䜿çšããŠæ§æããããšã«ããŸããã
ç°¡åãªåçŸæ§ãšåçŸæ§ã«å ããŠããã®ãããªã·ã¹ãã ïŒAnsibleã®ä»ã«ãPuppetãšChefã·ã¹ãã ããããŸãïŒã®äœ¿çšã¯ãvariousçã®åœ¢åŒã§ã®ããŸããŸãªã·ã§ã«ãŸãã¯pythonã¹ã¯ãªããã®äœ¿çšããã倧ããªå©ç¹ãããããšãä»ãå ãã䟡å€ããããŸãã ç¹°ãè¿ãèµ·åããŠãã·ã¹ãã ã®æçµç¶æ ãå€ãããªãããããã£ã
ãã®å©ç¹ã¯ãæ§æ管çã·ã¹ãã ã䜿çšããå Žåãèšè¿°ãããã®ã¯æãŸããç¶æ ãéæããããã»ã¹ã§ã¯ãªãã宣èšçãªåœ¢ã§ã®æãŸããç¶æ èªäœã§ãããšããäºå®ã«ç±æ¥ããŸãã
1.1 ssh HostKeyChecking
ããã©ã«ãã§ã¯ãAnsibleã¯ã»ãã¥ãªãã£ãå°éãããªã¢ãŒãèšå®å¯èœãã¹ãã®sshãã£ã³ã¬ãŒããªã³ããæ€èšŒããŸãã ãªããªã ãã®ã¢ãŒãã§ã¯ããã¹ã¯ãŒãã§èªèšŒããæ©èœãç¡å¹ã«ãªããŸãããã®åŸããµãŒããŒã®åæã»ããã¢ããã§HostKeyCheckingãç¡å¹ã«ããããæåã«ããŒã«ã«ãã£ãã·ã¥ã«æçŽãè¿œå ããå¿ èŠããããŸãã åŸè ã¯2ã€ã®æ¹æ³ã§å®çŸã§ããŸãã
ãŸãã¯ïŒ
ç¹å¥ãªç°å¢å€æ°ãå®çŸ©ããŸãã
$ export ANSIBLE_HOST_KEY_CHECKING=False
ãŸãã¯å¥ã®æ¹æ³ã§ïŒ
host_key_checkingãã©ã¡ãŒã¿ãŒãããŒã«ã«ã®ansible.cfgæ§æãã¡ã€ã«ã«è¿œå ããŸãã
[defaults] host_key_checking = False
æåã®æ¹æ³ã§ã¯ããã®ãããªç°å¢å€æ°ãååšããéã®ã¿ãã§ãã¯ãç¡å¹ã«ãªãã2çªç®ã®æ¹æ³ã§ã¯ãã®ãã¹ãã«å¯ŸããŠå®å šã«ç¡å¹ã«ãªããŸãã
1.2ã€ã³ãã³ããª
ã€ã³ãã³ããªã¯ãèšå®ãå¶åŸ¡ããå¿ èŠããããã¹ããšãã®ã°ã«ãŒããèšè¿°ããAnsibleã·ã¹ãã ã®ãšã³ãã£ãã£ã§ãã
ã€ã³ãã³ããªã¯ãiniãŸãã¯yaml圢åŒã§èšè¿°ã§ããŸãã ãã®ãããžã§ã¯ãã§ã¯ãæåŸã®ãããžã§ã¯ããéžæãããŸããã
hosts.ymlãã¡ã€ã«ã®äŸïŒ
#_ all all: hosts: # , Ansible some-cool-vm-host vars: # , ansible_user: 'root' # , :-( ansible_password: '12345678' # corp_ca_crt: "-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----"
yaml圢åŒã«åããŠçŽé¢ãããšãããã®åœ¢åŒã®ãã¹ãŠã®ã€ã³ãã³ãã¯ã¹ããŒã¹ã§åããªããã°ãªããªãããšã«æ³šæããããšæããŸãã
1.3ãã¬ã€ããã¯
Playbookã¯Ansibleã®å¥ã®ãšã³ãã£ãã£ã§ãããInventoryãããã¹ããšã°ã«ãŒãã®æãŸããæçµç¶æ ã宣èšçã«çŽæ¥èšè¿°ããŸãã Ansibleã®ã»ãšãã©ãã¹ãŠã®ãã®ãšåæ§ã«ããã¬ã€ããã¯ã¯yaml圢åŒã®ãã¡ã€ã«ã§èšè¿°ãããŸãã
ãã¬ã€ããã¯ãã¡ã€ã«ãå®è¡ããã«ã¯ã次ã®åœ¢åŒã®ã³ãã³ããå®è¡ããå¿ èŠããããŸãã
ansible-playbook -i ./hosts.yml tasks.yml
ãã®ãã¬ã€ããã¯ã§ã¯ãå¿ èŠãªãŠãŒã¶ãŒã®äœæãšDockerã®ã€ã³ã¹ããŒã«ãå«ãåºæ¬ã·ã¹ãã ã®å®å šãªã»ããã¢ããã«ã€ããŠèª¬æããŸããã
#_ , () - hosts: all tasks: # - name: shell: rm /etc/zypp/repos.d/* || exit 0 - name: SLES- REPOs... zypper_repository: repo="{{ item.repo }}" name="{{ item.name }}" disable_gpg_check="{{ item.disable_gpg_check|default('no') }}" with_items: - { repo: "http://...", name: "SLE-DISTRO-X" } - name: zypper: name: '*' state: latest - name: CA copy: # Inventory content: '{{ corp_ca_crt }}' dest: /etc/pki/trust/anchors/orpCA.crt owner: root group: root mode: 0644 - name: ... shell: update-ca-certificates - name: group: name="{{ item.name }}" gid={{ item.gid }} state="present" with_items: - { name: "docker", gid: 1000 } - user: name: "{{ item.name }}" uid: "{{ item.uid }}" group: "{{ item.gid }}" state: "present" with_items: - { name: "dockeradm", uid: 1000, gid: "docker" } - name: user: name: "{{ item }}" password: "$6$..." generate_ssh_key: yes with_items: - root - dockeradm - name: ssh- authorized_key: user: "{{ item }}" key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" state: "present" with_items: - root - dockeradm - name: VG lvg: vg: 'vgAPP' pvs: '/dev/sdb' - name: ... LV lvol: vg: "{{ item.vg }}" lv: "{{ item.lv }}" size: "{{ item.size }}" with_items: - { vg: 'vgAPP', lv: "lvData", size: "10G" } - { vg: 'vgAPP', lv: "lvDockerData", size: "5G" } - name: LV- filesystem: dev="/dev/{{ item }}" fstype="btrfs" with_items: - 'vgAPP/lvData' - 'vgAPP/lvDockerData' - name: /etc/fstab mount: path="{{ item.dst }}" src="/dev/{{ item.src }}" state="mounted" fstype="btrfs" opts="noatime" with_items: - { src: "vgAPP/lvData", dst: "/APP" } - { src: "vgAPP/lvDockerData", dst: "/var/lib/docker" } - name: file: path: "{{ item.path }}" state: "directory" # mode: "0{{ item.perms|default('755') }}" owner: "{{ item.user|default('dockeradm') }}" group: "{{ item.group|default('docker') }}" with_items: - { path: '/etc/docker', user: 'root', group: 'root' } - { path: '/APP' } - { path: '/APP/configs' } - { path: '/APP/configs/filebeat' } - { path: '/APP/logs' } - { path: '/APP/logs/nginx' } - { path: '/APP/jenkins' } - { path: '/APP/jenkins/master' } - { path: '/APP/jenkins/node' } - { path: '/APP/portainer_data' } - name: zypper: name: '{{ item }}' with_items: - docker - mc # Java Jenkins- - java-1_8_0-openjdk-headless # - name: - " " template: src: daemon.json dest: /etc/docker/daemon.json owner: root group: root mode: 0644 - name: ... systemd: name: "{{ item }}" state: 'restarted' enabled: 'yes' with_items: - docker - sshd - name: docker-compose get_url: url: "https://github.com/docker/compose/releases/download/1.18.0/docker-compose-Linux-x86_64" dest: "/tmp/docker-compose" delegate_to: 127.0.0.1 - copy: src: "/tmp/docker-compose" dest: "/usr/local/bin/docker-compose" mode: "u=rwx,g=rx,o=rx" - name: - NGINX, template: src: nginx.conf dest: /APP/configs/nginx.conf owner: dockeradm group: docker mode: '0644' - name: docker-compose - , template: src: docker-compose.yml dest: /APP/docker-compose.yml owner: dockeradm group: docker mode: '0644' - name: docker-compose - Jenkins, Portainer NGINX shell: docker-compose -f /APP/docker-compose.yml up -d --force-recreate - name: Jenkins- wait_for: path: '/APP/jenkins/master/secrets/initialAdminPassword' - name: Jenkins fetch: src: '/APP/jenkins/master/secrets/initialAdminPassword' dest: initialJenkinsAdminPassword.txt flat: yes
ããŒã2.ãããžã§ã¯ããµãŒãã¹
2.1 CIãµãŒããŒãšããã»ã¹
æåãªJenkins CIãµãŒããŒã¯ããããžã§ã¯ãã®ãç¶ç¶çãªçµ±åãšå±éãã®ããã»ã¹ãæ åœããŸãã
äžèšã®Ansibleãã¬ã€ããã¯ã³ãŒãã¯ãå®è¡ã®æåŸã«ãæ°ããã€ã³ã¹ããŒã«ãããJenkinsããµãŒããŒïŒDockerã³ã³ãããŒå ïŒã§æ¢ã«å®è¡ããããã®äžæãã¹ã¯ãŒããinitialJenkinsAdminPassword.txtãã¡ã€ã«ã®LOCALãã·ã³ã«ä¿åãããããã«èšèšãããŠããŸãã
ããŒã å šäœãã³ãŒããšããŠã®ã€ã³ãã©ã¹ãã©ã¯ãã£ïŒIaCïŒã®çæ³çãªã±ãŒã¹ã«ã§ããã ãè¿ã¥ããããšãæãã§ããããããããžã§ã¯ãã®ã¿ã¹ã¯ã¯ãGroovyã¹ã¯ãªããèšèªã§ã¿ã¹ã¯ãèšè¿°ããããã®ã³ãŒãããããžã§ã¯ããœãŒã¹ã®é£ã«æ ŒçŽãããŠããå Žåã 宣èšããã³ã¹ã¯ãªããåããã Jenkinsãã€ãã©ã€ã³ã®åœ¢åŒã§å®è£ ãããŸããããŒãžã§ã³ç®¡çã·ã¹ãã ïŒgitïŒã
Spring Bootã§ã¢ããªã±ãŒã·ã§ã³ã®ããã¯ãšã³ãéšåãçµã¿ç«ãŠãããã®ãã€ãã©ã€ã³ã®äŸã以äžã«ç€ºããŸãã
pipeline { agent { # , # Docker- : docker { image 'java:8-jdk' } } stages { stage(' ') { steps { checkout scm } } stage('') { steps { sh 'chmod +x ./gradlew' sh './gradlew build -x test' } } stage('') { steps { script { sh './gradlew test' } } } } } #_ Docker- Artifactory: node { stage(' ') { docker.withRegistry("https://repo.artifactory.bank", "LoginToArtifactory") { def dkrImg = docker.build("repo.artifactory.bank/dev-backend:${env.BUILD_ID}") dkrImg.push() dkrImg.push('latest') } } stage(' Artifactory') { docker.withRegistry("https://repo.artifactory.bank", "LoginToArtifactory") { sh "docker service update --image repo.artifactory.bank/dev-backend:${env.BUILD_ID} SMB_dev-backend" } } }
ç»åãçµã¿ç«ãŠããšãã«ãåããŒãžã§ã³ãç¬èªã®ã¿ã°ïŒã©ãã«ïŒãååŸãããããã¢ããªã±ãŒã·ã§ã³ã®èªååèµ·åããã»ã¹ãå€§å¹ ã«å®¹æã«ãªãããšã«æ³šæããŠãã ããã
2.2ããŒãã€ããŒ
ãããžã§ã¯ãã®ãã¹ãŠã®ããŒã ã¡ã³ããŒãšDockerã®çžäºäœçšãä¿é²ããããã«ãåçŽãªWebã€ã³ã¿ãŒãã§ãŒã¹ã§ããPortainerã䜿çšããŸããã ãã®ã¢ããªã±ãŒã·ã§ã³ã¯ãDockerèªäœãšåæ§ã«Goã§èšè¿°ãããŠãããããéåžžã«ç°¡åã«å±éã§ããé«ãããã©ãŒãã³ã¹ãç¹åŸŽã§ãã
ããšãã°ãæãåçŽãªå Žåã次ã®ã³ãã³ãã¯ãã¹ãã·ã¹ãã ã®ããŒã9000ã§Porteinerãèµ·åããŸãã
docker run -d \ -p 9000:9000 \ -v /var/run/docker.sock:/var/run/docker.sock \ portainer/portainer
ãã ããçŸåšã®ãããžã§ã¯ãã§ã¯ã1ã€ã®ãã¹ãïŒ Docker ComposeïŒã«å¯ŸããŠããªãŒã±ã¹ãã¬ãŒã·ã§ã³ãããŒã«ã®æ©èœã䜿çšããããšã決å®ãããŸããã
2.3 Dockerã³ã³ãããŒãšãµãŒãã¹
ãã®ãããžã§ã¯ãã§å¿ èŠãªãã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ãšãµãŒãã¹ã¯ãåçŽãªdocker-compose.ymlãã¡ã€ã«ãä»ããŠèµ·åãããŸãã
ãã€ã³ãã©ã¹ãã©ã¯ãã£ããµãŒãã¹ã®åºæ¬ã»ããã¯ã次ã®èª¬æãéããŠéå§ãããŸãã
version: '3.4' services: # NGINX nginx: image: "nginx:1" container_name: fe-nginx restart: always volumes: - /APP/configs/nginx.conf:/etc/nginx/nginx.conf - /APP/logs/nginx:/var/log/nginx - /usr/share/zoneinfo/Europe/Moscow:/etc/localtime:ro networks: - int ports: - "80:80/tcp" - "8080:80/tcp" # Jenkins CI - , CI/CD- ci: image: "jenkins/jenkins:lts" container_name: ci-jenkins restart: always volumes: - /usr/share/zoneinfo/Europe/Moscow:/etc/localtime:ro - /APP/jenkins/master:/var/jenkins_home environment: JENKINS_OPTS: '--prefix=/jenkinsci' JAVA_OPTS: '-Xmx512m' networks: int: aliases: - srv-ci # - Docker- portainer: image: "portainer/portainer:latest" volumes: - type: bind source: /var/run/docker.sock target: /var/run/docker.sock - type: bind source: /APP/portainer_data target: /data networks: int: aliases: - srv-portainer command: -H 'unix:///var/run/docker.sock' networks: int: external: true
2.4ã¯ã©ã¹ã¿ãŒãªãã®Docker Swarmã¯ã©ã¹ã¿ãŒ
äžèšã®docker-compose.ymlãã¡ã€ã«ãèŠããšãããããã«ããŸããã¢ããªã±ãŒã·ã§ã³ã®ããã¯ãšã³ãéšåãšããã³ããšã³ãéšåãžã®åç §ããªããintãšããååã®ãå€éšãïŒå€éšïŒtrueïŒãããã¯ãŒã¯ãžã®ãªã³ã¯ããããŸãã å€éšãªãœãŒã¹ãšã¯ãåäžã®ãã¡ã€ã«ã§å®£èšãããŠããªããªãœãŒã¹ïŒãããã¯ãŒã¯ãããªã¥ãŒã ãããã³ãã®ä»ã®æ¢åã®ãšã³ãã£ãã£ïŒã§ãã
å®éã®ãšããããããžã§ã¯ãã§ã¯ãArtifactory Dockerãªããžããªå ã®ã€ã¡ãŒãžã®ããŒãžã§ã³ãæŽæ°ãããšãã«ããµãŒãã¹ããåèµ·åã§ããå¿ èŠããããåæ§ã®æ©èœãDocker SwarmãµãŒãã¹ïŒDockerã³ã³ããçšã®Dockerãã«ããã¹ã¿ãŒçµã¿èŸŒã¿ãªãŒã±ã¹ãã¬ãŒã·ã§ã³ã·ã¹ãã ïŒã«ååšããç®±ããåºããŠãã ãã®æ©èœã¯ãå®è¡äžã®ãµãŒãã¹ã®å¿ èŠãªã€ã¡ãŒãžãå€æŽããæ©èœãéããŠå®è£ ããããªããžããªã«ã€ã¡ãŒãžã®æ°ããããŒãžã§ã³ãããå Žåãåèµ·åã¯èªåçã«è¡ãããŸãã ããŒãžã§ã³ãå€æŽãããŠããªãå ŽåããµãŒãã¹ã³ã³ããã¯åŒãç¶ãæ£åžžã«å®è¡ãããŸãã
ãããã¯ãŒã¯ã«ã€ããŠã¯ãDocker SwarmãµãŒãã¹ã®åœ¢åŒã§ã¢ããªã±ãŒã·ã§ã³ãèµ·åãããšãã«ïŒyamlã®èª¬æã以äžã«ç€ºããŸãïŒãäžèšã§çºè¡šããã³ã³ããŒãã³ããšNGINXãµãŒããŒã®ãããã¯ãŒã¯æ¥ç¶ãç¶æããå¿ èŠããããŸããã ããã¯ãäžèšã®åºæ¬ãµãŒãã¹ãšã¢ããªã±ãŒã·ã§ã³ã³ã³ããŒãã³ãèªäœã®äž¡æ¹ãå«ããµãŒããŒã¯ã©ã¹ã¿ãŒäžã«ãªãŒããŒã¬ã€ãããã¯ãŒã¯ãäœæããããšã§å®çŸããŸããã
docker network create -d overlay --subnet 10.1.2.254/24 --attachable int
ïŒ-ããããªããã°ãåºæ¬ãµãŒãã¹ã¯ã¯ã©ã¹ã¿ãŒãããã¯ãŒã¯ã«ã¢ã¯ã»ã¹ã§ããªããããæ¥ç¶å¯èœãå¿ èŠã§ãïŒ
2ã€ã®ãµãŒãã¹ãåããã¢ããªã±ãŒã·ã§ã³ã³ã³ããŒãã³ãã®èª¬æïŒ
version: '3.2' services: pre-live-backend: image:repo.artifactory.bank/dev-backend:latest deploy: mode: replicated replicas: 1 networks: - int pre-live-front: image: repo.artifactory.bank/dev-front:latest deploy: mode: replicated replicas: 1 networks: - int networks: int: external: true
ãããã«
åé ã§è¿°ã¹ãããã«ããããžã§ã¯ãã®éå§æã«ãããŒã ã¯DevOpsã¢ãããŒãã®ãã¹ãŠã®å©ç¹ãååŸããããšèããŠããŸãããç¹ã«ãGitãªããžããªããå®è¡äžã®ã¢ããªã±ãŒã·ã§ã³ãšããŠãããã«ããµãŒããŒã«ã³ãŒããç¶ç¶çã«é ä¿¡ããããã»ã¹ãæŽçããããšèããŠããŸããã åæã«ãçŸåšã®æ®µéã§ã¯ã確ç«ãããæ £è¡ãå®å šã«æŸæ£ãã倧èŠæš¡ãªãªãŒã±ã¹ãã¬ãŒã¿ãŒã®äžçã§ã®ç掻ã®äžã§èªåèªèº«ãåæ§ç¯ããããããŸããã§ããã 説æãããã·ã¹ãã ã¢ãŒããã¯ãã£ã¯ã2é±éæªæºã§ïŒããŒã ã¡ã³ããŒãåãçµãã§ããä»ã®ãããžã§ã¯ããšäžŠè¡ããŠïŒèãåºãããŠå®è£ ãããæçµçã«ç§ãã¡ãæããã®ãéæããããšãã§ããŸããã ãã®è³æã¯ãDevOpsã¢ãããŒããå®è£ ããä»ã®ããŒã ã«ãšã£ãŠèå³æ·±ãæçšã§ãããšèããŠããŸãã