[쿠버네티스/도커] 1 - 컨테이너 인프라 환경이란, 테스트 환경 구성
TIL

[쿠버네티스/도커] 1 - 컨테이너 인프라 환경이란, 테스트 환경 구성

 
회사에서 쿠버네티스를 사용한다는 것은 알고 있었지만 직접적으로 개발하진 않기 때문에 단순 반복해서 사용만 해왔다. 하지만 전체적인 구조와 사용하는 툴에 대한 기본적인 정보를 파악하고 싶어 컨테이너 인프라 환경 구축을 위한 쿠버네티스/도커 도서를 읽고 서칭한 내용을 간단하게 정리해본다.


1장 - 컨테이너 인프라 환경이란

이 책의 큰 주제 중 하나인 컨테이너 인프라 환경의 정의는 다음과 같다.

컨테이너 인프라 환경: 컨테이너를 중심으로 구성된 인프라 환경
컨테이너: 하나의 운영 체제 커널에서 다른 프로세스에 영향을 받지 않고 독립적으로 실행되는 프로세스 상태

 
과거에 모놀리식 아키텍쳐를 사용하다가 서비스가 커지고 다양해짐에 따라 마이크로소프트 서비스 아키텍쳐(MSA)가 많이 채용이 되고 있고, MSA를 구현하는데 적합한 환경이 컨테이너 인프라 환경이다. 컨테이너를 서비스 단위로 손쉽게 배포할 수 있기 때문이다.
 
컨테이너 인프라 환경을 지원하는 도구는 다음과 같이 리스트업할 수 있다.

  • 도커: 컨테이너 환경에서 독립적으로 애플리케이션을 실행할 수 있도록 컨테이너를 만들고 관리하는 것을 도와주는 컨테이너 도구. 어플리케이션이 운영 체케 환경에 관계없이 독립적인 환경에서 일관된 결과를 보장. 비슷한 툴로는 컨테이너디(Containerd), 크라이오(CRI-O), 파드맨(Podman) 등이 있음.
  • 쿠버네티스: 다수의 컨테이너를 관리하는 데 사용. 컨테이너의 자동 배포와 배포된 컨테이너에 대한 동작 보증, 부하에 따른 종적 확장 등의 기능을 제공. 비슷한 툴로는 도커스웜(Docker Swarm), 메소스(Mesos), 노마드(Nomad) 등이 있음.
  • 젠킨스: 지속적 통합(CI)과 지속적 배포(CD)를 지원. 개발한 프로그램의 빌드, 테스트, 패키지화, 배포 단계를 모두 자동화해 개발 단계를 표준화. 비슷한 툴로는 뱀부(Bamboo), 깃허브 액션(Github Action), 팀시티(Teamcity) 등이 있음.
  • 프로메테우스와 그라파나: 모니터링을 위한 도구. 프로메테우스는 상태 데이터를 수집. 그라파나는 프로메테우스로 수집한 데이터를 시각화. 중앙 모니터링을 위해 많이 사용하는 조합. 모니터링 데이터 수집 도구에는 프로메테우스 외에도 데이터독(DataDog), 인플럭스DB(InfluxDB), 뉴 렐릭(New Relic) 등이 있음. 데이터를 시각화하는 도구는 그라파나 외에도 키바나(Kibana), 크로노그래프(Chronograf) 등이 있음.

2장 - 테스트 환경 구성

이 챕터에서는 가상 환경을 구축하고 그 안에 인프라 환경을 구성한다. 이때 일관된 결과를 얻기 위해 코드형 인프라(IaC, Infrastructure as Code)로 인프라 환경을 일정하게 유지하고 구성한다.

코드형 인프라: 코드로 하드웨어를 설정하고, 운영체제를 설치하고, 네트워크를 구성하고, 개발 환경을 구축하는 것

 

버추얼박스(Virtual Box) 설치

이노테크에서 개발한 가상화 소프트웨어로 오라클에서 배포. 버추얼박스를 사용하면 가상의 '컴퓨터'를 만들 수 있다. 이렇게 만든 가상의 컴퓨터를 가상머신(VM, Virtual Machine)이라고 한다. 가상머신 위에도 운영체제를 설치하고 프로그램을 실행할 수 있다.

 
여기서 Oracle VirtualBox를 다운받아 설치한다. (책과 동일한 환경을 맞추기 위해 6.1.12 버전을 설치해줬다.)

 

Downloads     – Oracle VM VirtualBox

Download VirtualBox Here you will find links to VirtualBox binaries and its source code. VirtualBox binaries By downloading, you agree to the terms and conditions of the respective license. VirtualBox 7.0.14 platform packages The binaries are released unde

www.virtualbox.org

설치 후 VirtualBox 첫 화면

 

베이그런트(Vagrant) 설치

베이그런트란 단일 워크플로우에서 가상 시스템 환경을 구축하고 관리하기 위한 도구이다. 위에서 언급한 코드형 인프라를 구현하기 위한 소프트웨어 중 하나다. 베이그런트는 유사한 소프트웨어들 중 교육용과 소규모 시스템에 적합하다.

 
베이그런트는 왜 쓰는 도구일까? 찾아보니 바로 이해할 수 있는 그림이 있었다.
이전에 대학교 수업을 들으면서 가상머신을 설치했을 때 과정이 꽤 번거롭게 느껴졌었다. 아래 이미지처럼 설정해줘야하는게 많았었다.

cafe-jun12님 블로그 그림1

 
만약 가상머신을 50대를 설치해야하면 번거로운 설치 과정을 50번이나 반복해야한다. 그런 끔찍한 일을 방지하기 위해 사용하는 것이 바로 베이그런트다. 베이그런트는 YAML 설정 파일을 만들어서 자동으로 가상머신을 설치할 수 있게 해준다.
 

cafe-jun12님 블로그 그림2

 
베이그런트는 사용자의 요구에 맞게 시스템 자원을 할당, 배치, 배포해 두었다가 필요할 때 시스템을 사용할 수 있는 상태로 만들어 준다(= 프로비저닝 provisioning).
 
베이그런트는 여기서 다운로드 받을 수 있다.

 

Install | Vagrant | HashiCorp Developer

Explore Vagrant product documentation, tutorials, and examples.

developer.hashicorp.com

 
다음과 같이 vagrant -v 를 쳤을 때 버전정보가 나온다면 설치 성공.

 
이제 프로비저닝을 위한 코드를 작성해서 베이그런트에 불러온 후 버추얼박스에 운영체제를 설치해보자. vagrant init 명령어를 쓰면 프로비저닝을 위한 기초 파일을 생성해준다.

기초 파일 생성

 
이때 생성된 Vagrantfile을 열어보면 다음과 같이 config.vm.box = "base"라고 작성된 부분을 확인할 수 있다. "base"를 다른 값으로 바꿔주면 vagrant cloud에 올라가있는 이미지를 편리하게 받아서 사용할 수 있다.

이미지명을 작성해줬다면 vagrant up 명령어를 통해 vagrantfile을 읽어 들여 프로비저닝을 진행한다.

 
이제 virtual box를 실행해서 가상머신이 제대로 생성됐는지 확인한다.

 

 
이제 필요한 설정으로 Vagrantfile을 재구성해보자. (vagrantfile은 루비로 작성된다.)

# -*- mode: ruby -*-
# vi: set ft=ruby :

# 2: 베이그런트에서 루비로 코드를 읽어 들여 실행할 때 작동하는 API 버전
# do |config|: 베이그런트 설정의 시작
Vagrant.configure("2") do |config|
  # 버추얼 박스에서 보이는 가상 머신을 "m-k8s"로 정의
  # do |cfg|: 가상머신에서 필요한 설정으로 변경. end에서 종료
  config.vm.define "m-k8s" do |cfg|
    cfg.vm.box = "sysnet4admin/CentOS-k8s"
    # 베이그런트의 프로바이더(실제 배포되게 하는 소프트웨어)가 버추얼박스라느 것을 정의
    # do |vb|: 버추얼박스에서 필요한 설정을 정의
    cfg.vm.provider "virtualbox" do |vb|
      vb.name = "m-k9s(github_SysNet4admin)"
      vb.cpus = 2
      vb.memory = 2048
      vb.customize ["modifyvm", :id, "--groups", "/k8s-SM(github_SysNet4Admin)"]
    end
    cfg.vm.host_name = "m-k8s"
    # 호스트 전용 네트워크 설정
    cfg.vm.network "private_network", ip: "192.168.1.10"
    # ssh 통신은 호스트 60010번을 게스트 22번으로 전달되도록 구성
    # disabled: 포트 중복 대비해 true로 설정해 포트 중복시 자동 변경되도록 설정
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    # disabled: 호스트와 게스트 사이 디렉터리 동기화 막도록 true로 설정
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end
end

 
설정 후 가상머신을 생성해본다.

 
이제 추가 패키지 설치를 위해 Vagrantfile에 아래줄을 추가 작성해주고 install_pkg.sh 파일을 생성해준다.

    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
    # path에 있는 install_pkg.sh를 게스트 내부에서 호출해 실행되도록 한다. (추가 패키지 설치 위함)
    cfg.vm.provision "shell", path: "install_pkg.sh"
# install_pkg.sh 파일

#!/usr/bin/env bash
# install packages
yum install epel-release -y # EPEL 저장소
yum install vim-enhanced -y # 코드 하이라이트를 위한 Vim의 추가 기능

 
이어서 vagrant provision 명령어로 가상버신에 변경된 설정을 적용해준다. vagrant ssh 로 가상머신에 접속해 yum repolist로 패키지가 잘 설치되어있는지 확인하고 vagrant destroy -f 로 가상머신을 삭제한다.
 
이제 가상머신 3대를 추가로 설치해 보자.
기존의 Vagrantfile에 아래와 같이 가상머신 3대를 추가하는 코드를 작성해준다.

# -*- mode: ruby -*-
# vi: set ft=ruby :

# 2: 베이그런트에서 루비로 코드를 읽어 들여 실행할 때 작동하는 API 버전
# do |config|: 베이그런트 설정의 시작
Vagrant.configure("2") do |config|
  ...
    # path에 있는 install_pkg.sh를 게스트 내부에서 호출해 실행되도록 한다. (추가 패키지 설치 위함)
    cfg.vm.provision "shell", path: "install_pkg.sh"
    # 호스트에 있는 ping_2_nds.sh 파일을 게스트의 홈 디렉터리(/home/vagrant)로 전달
    cfg.vm.provision "file", source: "ping_2_nds.sh", destination: "ping_2_nds.sh"
    # config.sh를 게스트에서 실행
    cfg.vm.provision "shell", path: "config.sh"
  end

  # 추가한 3대의 CentOS에 대한 구성. 기존의 CentOS와 동일하나 반복문으로 효율적으로 구성
  # 1부터 3까지 반복해서 i에 입력
  (1..3).each do |i|
    config.vm.define "w#{i}-k8s" do |cfg|
      cfg.vm.box = "sysnet4admin/CentOS-k8s"
      cfg.vm.provider "virtualbox" do |vb|
        vb.name = "w#{i}-k8s(github_SysNet4Admin)"
        vb.cpus = 1
        vb.memory = 1024
        vb.customize ["modifyvm", :id, "--groups", "/k8s-SM(github_SysNet4Admin)"]
      end
      cfg.vm.host_name = "w#{i}-k8s"
      cfg.vm.network "private_network", ip: "192.168.1.10#{i}"
      cfg.vm.network "forwarded_port", guest: 22, host: "6010#{i}", auto_correct: true, id: "ssh"
      cfg.vm.synced_folder "../data", "/vagrant", disabled: true
      cfg.vm.provision "shell", path: "install_pkg.sh"
    end
  end
end

 
기존 가상머신에서 새로 추가한 3개의 가상 머신간에 네트워크 통신이 원할하게 작동하는지 확인하기 위해 아래 파일을 추가해준다.

# ping_2_nds.sh

# 추가한 CentOS 3대로 ping을 보내 네트워크가 제대로 작동하는지 확인하는 명령 
# -c는 몇 번의 ping을 보낼지 지정
ping 192.168.1.101 -c 3
ping 192.168.1.102 -c 3
ping 192.168.1.103 -c 3

 

# config.sh

#!/usr/bin/env bash
# ping 테스트 파일의 권한 설정을 변경
chmod 744 ./ping_2_nds.sh

 
vagrant up으로 4대의 CentOS를 설치하고 구성한다.

더보기

C:\Users\admin\vagrantTest>vagrant up
Bringing machine 'm-k8s' up with 'virtualbox' provider...
Bringing machine 'w1-k8s' up with 'virtualbox' provider...
Bringing machine 'w2-k8s' up with 'virtualbox' provider...
Bringing machine 'w3-k8s' up with 'virtualbox' provider...
==> m-k8s: Importing base box 'sysnet4admin/CentOS-k8s'...
==> m-k8s: Matching MAC address for NAT networking...
==> m-k8s: Checking if box 'sysnet4admin/CentOS-k8s' version '0.8.0' is up to date...
==> m-k8s: Setting the name of the VM: m-k9s(github_SysNet4admin)
==> m-k8s: Clearing any previously set network interfaces...
==> m-k8s: Preparing network interfaces based on configuration...
    m-k8s: Adapter 1: nat
    m-k8s: Adapter 2: hostonly
==> m-k8s: Forwarding ports...
    m-k8s: 22 (guest) => 60010 (host) (adapter 1)
==> m-k8s: Running 'pre-boot' VM customizations...
==> m-k8s: Booting VM...
==> m-k8s: Waiting for machine to boot. This may take a few minutes...
    m-k8s: SSH address: 127.0.0.1:60010
    m-k8s: SSH username: vagrant
    m-k8s: SSH auth method: private key
    m-k8s: Warning: Connection reset. Retrying...
    m-k8s: Warning: Connection aborted. Retrying...
    m-k8s: Warning: Remote connection disconnect. Retrying...
    m-k8s: Warning: Connection aborted. Retrying...
    m-k8s: Warning: Connection reset. Retrying...
    m-k8s: Warning: Remote connection disconnect. Retrying...
    m-k8s: Warning: Connection aborted. Retrying...
    m-k8s: Warning: Connection reset. Retrying...
    m-k8s:
    m-k8s: Vagrant insecure key detected. Vagrant will automatically replace
    m-k8s: this with a newly generated keypair for better security.
    m-k8s:
    m-k8s: Inserting generated public key within guest...
    m-k8s: Removing insecure key from the guest if it's present...
    m-k8s: Key inserted! Disconnecting and reconnecting using new SSH key...
==> m-k8s: Machine booted and ready!
==> m-k8s: Checking for guest additions in VM...
    m-k8s: The guest additions on this VM do not match the installed version of
    m-k8s: VirtualBox! In most cases this is fine, but in rare cases it can
    m-k8s: prevent things such as shared folders from working properly. If you see
    m-k8s: shared folder errors, please make sure the guest additions within the
    m-k8s: virtual machine match the version of VirtualBox you have installed on
    m-k8s: your host and reload your VM.
    m-k8s:
    m-k8s: Guest Additions Version: 5.2.12
    m-k8s: VirtualBox Version: 6.1
==> m-k8s: Setting hostname...
==> m-k8s: Configuring and enabling network interfaces...
==> m-k8s: Running provisioner: shell...
    m-k8s: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20240212-25972-371kwv.sh
    m-k8s: Loaded plugins: fastestmirror
    m-k8s: Determining fastest mirrors
    m-k8s:  * base: mirror.kakao.com
    m-k8s:  * extras: mirror.kakao.com
    m-k8s:  * updates: mirror.kakao.com
    m-k8s: Resolving Dependencies
    m-k8s: --> Running transaction check
    m-k8s: ---> Package epel-release.noarch 0:7-11 will be installed
    m-k8s: --> Finished Dependency Resolution
    m-k8s:
    m-k8s: Dependencies Resolved
    m-k8s:
    m-k8s: ================================================================================
    m-k8s:  Package                Arch             Version         Repository        Size
    m-k8s: ================================================================================
    m-k8s: Installing:
    m-k8s:  epel-release           noarch           7-11            extras            15 k
    m-k8s:
    m-k8s: Transaction Summary
    m-k8s: ================================================================================
    m-k8s: Install  1 Package
    m-k8s:
    m-k8s: Total download size: 15 k
    m-k8s: Installed size: 24 k
    m-k8s: Downloading packages:
    m-k8s: Running transaction check
    m-k8s: Running transaction test
    m-k8s: Transaction test succeeded
    m-k8s: Running transaction
    m-k8s:   Installing : epel-release-7-11.noarch                                     1/1
    m-k8s:   Verifying  : epel-release-7-11.noarch                                     1/1
    m-k8s:
    m-k8s: Installed:
    m-k8s:   epel-release.noarch 0:7-11
    m-k8s:
    m-k8s: Complete!
    m-k8s: Loaded plugins: fastestmirror
    m-k8s: Loading mirror speeds from cached hostfile
    m-k8s:  * base: mirror.kakao.com
    m-k8s:  * epel: mirror-icn.yuki.net.uk
    m-k8s:  * extras: mirror.kakao.com
    m-k8s:  * updates: mirror.kakao.com
    m-k8s: Resolving Dependencies
    m-k8s: --> Running transaction check
    m-k8s: ---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed
    m-k8s: --> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    m-k8s: --> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    m-k8s: --> Running transaction check
    m-k8s: ---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed
    m-k8s: ---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed
    m-k8s: --> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64
    m-k8s: --> Running transaction check
    m-k8s: ---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed
    m-k8s: --> Finished Dependency Resolution
    m-k8s:
    m-k8s: Dependencies Resolved
    m-k8s:
    m-k8s: ================================================================================
    m-k8s:  Package              Arch         Version                  Repository     Size
    m-k8s: ================================================================================
    m-k8s: Installing:
    m-k8s:  vim-enhanced         x86_64       2:7.4.629-8.el7_9        updates       1.1 M
    m-k8s: Installing for dependencies:
    m-k8s:  gpm-libs             x86_64       1.20.7-6.el7             base           32 k
    m-k8s:  vim-common           x86_64       2:7.4.629-8.el7_9        updates       5.9 M
    m-k8s:  vim-filesystem       x86_64       2:7.4.629-8.el7_9        updates        11 k
    m-k8s:
    m-k8s: Transaction Summary
    m-k8s: ================================================================================
    m-k8s: Install  1 Package (+3 Dependent packages)
    m-k8s:
    m-k8s: Total download size: 7.0 M
    m-k8s: Installed size: 23 M
    m-k8s: Downloading packages:
    m-k8s: --------------------------------------------------------------------------------
    m-k8s: Total                                               17 MB/s | 7.0 MB  00:00
    m-k8s: Running transaction check
    m-k8s: Running transaction test
    m-k8s: Transaction test succeeded
    m-k8s: Running transaction
    m-k8s:   Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      1/4
    m-k8s:   Installing : 2:vim-common-7.4.629-8.el7_9.x86_64                          2/4
    m-k8s:   Installing : gpm-libs-1.20.7-6.el7.x86_64                                 3/4
    m-k8s:   Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        4/4
    m-k8s:   Verifying  : gpm-libs-1.20.7-6.el7.x86_64                                 1/4
    m-k8s:   Verifying  : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        2/4
    m-k8s:   Verifying  : 2:vim-common-7.4.629-8.el7_9.x86_64                          3/4
    m-k8s:   Verifying  : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      4/4
    m-k8s:
    m-k8s: Installed:
    m-k8s:   vim-enhanced.x86_64 2:7.4.629-8.el7_9
    m-k8s:
    m-k8s: Dependency Installed:
    m-k8s:   gpm-libs.x86_64 0:1.20.7-6.el7           vim-common.x86_64 2:7.4.629-8.el7_9
    m-k8s:   vim-filesystem.x86_64 2:7.4.629-8.el7_9
    m-k8s:
    m-k8s: Complete!
==> m-k8s: Running provisioner: file...
    m-k8s: ping_2_nds.sh => ping_2_nds.sh
==> m-k8s: Running provisioner: shell...
    m-k8s: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20240212-25972-xpjbvc.sh
==> w1-k8s: Importing base box 'sysnet4admin/CentOS-k8s'...
==> w1-k8s: Matching MAC address for NAT networking...
==> w1-k8s: Checking if box 'sysnet4admin/CentOS-k8s' version '0.8.0' is up to date...
==> w1-k8s: Setting the name of the VM: w1-k8s(github_SysNet4Admin)
==> w1-k8s: Clearing any previously set network interfaces...
==> w1-k8s: Preparing network interfaces based on configuration...
    w1-k8s: Adapter 1: nat
    w1-k8s: Adapter 2: hostonly
==> w1-k8s: Forwarding ports...
    w1-k8s: 22 (guest) => 60101 (host) (adapter 1)
==> w1-k8s: Running 'pre-boot' VM customizations...
==> w1-k8s: Booting VM...
==> w1-k8s: Waiting for machine to boot. This may take a few minutes...
    w1-k8s: SSH address: 127.0.0.1:60101
    w1-k8s: SSH username: vagrant
    w1-k8s: SSH auth method: private key
    w1-k8s: Warning: Remote connection disconnect. Retrying...
    w1-k8s: Warning: Connection aborted. Retrying...
    w1-k8s: Warning: Connection reset. Retrying...
    w1-k8s: Warning: Connection aborted. Retrying...
    w1-k8s: Warning: Remote connection disconnect. Retrying...
    w1-k8s: Warning: Connection reset. Retrying...
    w1-k8s: Warning: Connection aborted. Retrying...
    w1-k8s:
    w1-k8s: Vagrant insecure key detected. Vagrant will automatically replace
    w1-k8s: this with a newly generated keypair for better security.
    w1-k8s:
    w1-k8s: Inserting generated public key within guest...
    w1-k8s: Removing insecure key from the guest if it's present...
    w1-k8s: Key inserted! Disconnecting and reconnecting using new SSH key...
==> w1-k8s: Machine booted and ready!
==> w1-k8s: Checking for guest additions in VM...
    w1-k8s: The guest additions on this VM do not match the installed version of
    w1-k8s: VirtualBox! In most cases this is fine, but in rare cases it can
    w1-k8s: prevent things such as shared folders from working properly. If you see
    w1-k8s: shared folder errors, please make sure the guest additions within the
    w1-k8s: virtual machine match the version of VirtualBox you have installed on
    w1-k8s: your host and reload your VM.
    w1-k8s:
    w1-k8s: Guest Additions Version: 5.2.12
    w1-k8s: VirtualBox Version: 6.1
==> w1-k8s: Setting hostname...
==> w1-k8s: Configuring and enabling network interfaces...
==> w1-k8s: Running provisioner: shell...
    w1-k8s: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20240212-25972-jahhqc.sh
    w1-k8s: Loaded plugins: fastestmirror
    w1-k8s: Determining fastest mirrors
    w1-k8s:  * base: mirror.kakao.com
    w1-k8s:  * extras: mirror.kakao.com
    w1-k8s:  * updates: mirror.kakao.com
    w1-k8s: Resolving Dependencies
    w1-k8s: --> Running transaction check
    w1-k8s: ---> Package epel-release.noarch 0:7-11 will be installed
    w1-k8s: --> Finished Dependency Resolution
    w1-k8s:
    w1-k8s: Dependencies Resolved
    w1-k8s:
    w1-k8s: ================================================================================
    w1-k8s:  Package                Arch             Version         Repository        Size
    w1-k8s: ================================================================================
    w1-k8s: Installing:
    w1-k8s:  epel-release           noarch           7-11            extras            15 k
    w1-k8s:
    w1-k8s: Transaction Summary
    w1-k8s: ================================================================================
    w1-k8s: Install  1 Package
    w1-k8s:
    w1-k8s: Total download size: 15 k
    w1-k8s: Installed size: 24 k
    w1-k8s: Downloading packages:
    w1-k8s: Running transaction check
    w1-k8s: Running transaction test
    w1-k8s: Transaction test succeeded
    w1-k8s: Running transaction
    w1-k8s:   Installing : epel-release-7-11.noarch                                     1/1
    w1-k8s:   Verifying  : epel-release-7-11.noarch                                     1/1
    w1-k8s:
    w1-k8s: Installed:
    w1-k8s:   epel-release.noarch 0:7-11
    w1-k8s:
    w1-k8s: Complete!
    w1-k8s: Loaded plugins: fastestmirror
    w1-k8s: Loading mirror speeds from cached hostfile
    w1-k8s:  * base: mirror.kakao.com
    w1-k8s:  * epel: mirror-nrt.yuki.net.uk
    w1-k8s:  * extras: mirror.kakao.com
    w1-k8s:  * updates: mirror.kakao.com
    w1-k8s: Resolving Dependencies
    w1-k8s: --> Running transaction check
    w1-k8s: ---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed
    w1-k8s: --> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    w1-k8s: --> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    w1-k8s: --> Running transaction check
    w1-k8s: ---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed
    w1-k8s: ---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed
    w1-k8s: --> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64
    w1-k8s: --> Running transaction check
    w1-k8s: ---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed
    w1-k8s: --> Finished Dependency Resolution
    w1-k8s:
    w1-k8s: Dependencies Resolved
    w1-k8s:
    w1-k8s: ================================================================================
    w1-k8s:  Package              Arch         Version                  Repository     Size
    w1-k8s: ================================================================================
    w1-k8s: Installing:
    w1-k8s:  vim-enhanced         x86_64       2:7.4.629-8.el7_9        updates       1.1 M
    w1-k8s: Installing for dependencies:
    w1-k8s:  gpm-libs             x86_64       1.20.7-6.el7             base           32 k
    w1-k8s:  vim-common           x86_64       2:7.4.629-8.el7_9        updates       5.9 M
    w1-k8s:  vim-filesystem       x86_64       2:7.4.629-8.el7_9        updates        11 k
    w1-k8s:
    w1-k8s: Transaction Summary
    w1-k8s: ================================================================================
    w1-k8s: Install  1 Package (+3 Dependent packages)
    w1-k8s:
    w1-k8s: Total download size: 7.0 M
    w1-k8s: Installed size: 23 M
    w1-k8s: Downloading packages:
    w1-k8s: --------------------------------------------------------------------------------
    w1-k8s: Total                                               21 MB/s | 7.0 MB  00:00
    w1-k8s: Running transaction check
    w1-k8s: Running transaction test
    w1-k8s: Transaction test succeeded
    w1-k8s: Running transaction
    w1-k8s:   Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      1/4
    w1-k8s:   Installing : 2:vim-common-7.4.629-8.el7_9.x86_64                          2/4
    w1-k8s:   Installing : gpm-libs-1.20.7-6.el7.x86_64                                 3/4
    w1-k8s:   Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        4/4
    w1-k8s:   Verifying  : gpm-libs-1.20.7-6.el7.x86_64                                 1/4
    w1-k8s:   Verifying  : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        2/4
    w1-k8s:   Verifying  : 2:vim-common-7.4.629-8.el7_9.x86_64                          3/4
    w1-k8s:   Verifying  : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      4/4
    w1-k8s:
    w1-k8s: Installed:
    w1-k8s:   vim-enhanced.x86_64 2:7.4.629-8.el7_9
    w1-k8s:
    w1-k8s: Dependency Installed:
    w1-k8s:   gpm-libs.x86_64 0:1.20.7-6.el7           vim-common.x86_64 2:7.4.629-8.el7_9
    w1-k8s:   vim-filesystem.x86_64 2:7.4.629-8.el7_9
    w1-k8s:
    w1-k8s: Complete!
==> w2-k8s: Importing base box 'sysnet4admin/CentOS-k8s'...
==> w2-k8s: Matching MAC address for NAT networking...
==> w2-k8s: Checking if box 'sysnet4admin/CentOS-k8s' version '0.8.0' is up to date...
==> w2-k8s: Setting the name of the VM: w2-k8s(github_SysNet4Admin)
==> w2-k8s: Clearing any previously set network interfaces...
==> w2-k8s: Preparing network interfaces based on configuration...
    w2-k8s: Adapter 1: nat
    w2-k8s: Adapter 2: hostonly
==> w2-k8s: Forwarding ports...
    w2-k8s: 22 (guest) => 60102 (host) (adapter 1)
==> w2-k8s: Running 'pre-boot' VM customizations...
==> w2-k8s: Booting VM...
==> w2-k8s: Waiting for machine to boot. This may take a few minutes...
    w2-k8s: SSH address: 127.0.0.1:60102
    w2-k8s: SSH username: vagrant
    w2-k8s: SSH auth method: private key
    w2-k8s: Warning: Connection aborted. Retrying...
    w2-k8s: Warning: Connection reset. Retrying...
    w2-k8s: Warning: Remote connection disconnect. Retrying...
    w2-k8s: Warning: Connection aborted. Retrying...
    w2-k8s: Warning: Connection reset. Retrying...
    w2-k8s: Warning: Remote connection disconnect. Retrying...
    w2-k8s: Warning: Connection aborted. Retrying...
    w2-k8s:
    w2-k8s: Vagrant insecure key detected. Vagrant will automatically replace
    w2-k8s: this with a newly generated keypair for better security.
    w2-k8s:
    w2-k8s: Inserting generated public key within guest...
    w2-k8s: Removing insecure key from the guest if it's present...
    w2-k8s: Key inserted! Disconnecting and reconnecting using new SSH key...
==> w2-k8s: Machine booted and ready!
==> w2-k8s: Checking for guest additions in VM...
    w2-k8s: The guest additions on this VM do not match the installed version of
    w2-k8s: VirtualBox! In most cases this is fine, but in rare cases it can
    w2-k8s: prevent things such as shared folders from working properly. If you see
    w2-k8s: shared folder errors, please make sure the guest additions within the
    w2-k8s: virtual machine match the version of VirtualBox you have installed on
    w2-k8s: your host and reload your VM.
    w2-k8s:
    w2-k8s: Guest Additions Version: 5.2.12
    w2-k8s: VirtualBox Version: 6.1
==> w2-k8s: Setting hostname...
==> w2-k8s: Configuring and enabling network interfaces...
==> w2-k8s: Running provisioner: shell...
    w2-k8s: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20240212-25972-jrev3d.sh
    w2-k8s: Loaded plugins: fastestmirror
    w2-k8s: Determining fastest mirrors
    w2-k8s:  * base: mirror.kakao.com
    w2-k8s:  * extras: mirror.kakao.com
    w2-k8s:  * updates: mirror.kakao.com
    w2-k8s: Resolving Dependencies
    w2-k8s: --> Running transaction check
    w2-k8s: ---> Package epel-release.noarch 0:7-11 will be installed
    w2-k8s: --> Finished Dependency Resolution
    w2-k8s:
    w2-k8s: Dependencies Resolved
    w2-k8s:
    w2-k8s: ================================================================================
    w2-k8s:  Package                Arch             Version         Repository        Size
    w2-k8s: ================================================================================
    w2-k8s: Installing:
    w2-k8s:  epel-release           noarch           7-11            extras            15 k
    w2-k8s:
    w2-k8s: Transaction Summary
    w2-k8s: ================================================================================
    w2-k8s: Install  1 Package
    w2-k8s:
    w2-k8s: Total download size: 15 k
    w2-k8s: Installed size: 24 k
    w2-k8s: Downloading packages:
    w2-k8s: Running transaction check
    w2-k8s: Running transaction test
    w2-k8s: Transaction test succeeded
    w2-k8s: Running transaction
    w2-k8s:   Installing : epel-release-7-11.noarch                                     1/1
    w2-k8s:   Verifying  : epel-release-7-11.noarch                                     1/1
    w2-k8s:
    w2-k8s: Installed:
    w2-k8s:   epel-release.noarch 0:7-11
    w2-k8s:
    w2-k8s: Complete!
    w2-k8s: Loaded plugins: fastestmirror
    w2-k8s: Loading mirror speeds from cached hostfile
    w2-k8s:  * base: mirror.kakao.com
    w2-k8s:  * epel: mirror-nrt.yuki.net.uk
    w2-k8s:  * extras: mirror.kakao.com
    w2-k8s:  * updates: mirror.kakao.com
    w2-k8s: Resolving Dependencies
    w2-k8s: --> Running transaction check
    w2-k8s: ---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed
    w2-k8s: --> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    w2-k8s: --> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    w2-k8s: --> Running transaction check
    w2-k8s: ---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed
    w2-k8s: ---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed
    w2-k8s: --> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64
    w2-k8s: --> Running transaction check
    w2-k8s: ---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed
    w2-k8s: --> Finished Dependency Resolution
    w2-k8s:
    w2-k8s: Dependencies Resolved
    w2-k8s:
    w2-k8s: ================================================================================
    w2-k8s:  Package              Arch         Version                  Repository     Size
    w2-k8s: ================================================================================
    w2-k8s: Installing:
    w2-k8s:  vim-enhanced         x86_64       2:7.4.629-8.el7_9        updates       1.1 M
    w2-k8s: Installing for dependencies:
    w2-k8s:  gpm-libs             x86_64       1.20.7-6.el7             base           32 k
    w2-k8s:  vim-common           x86_64       2:7.4.629-8.el7_9        updates       5.9 M
    w2-k8s:  vim-filesystem       x86_64       2:7.4.629-8.el7_9        updates        11 k
    w2-k8s:
    w2-k8s: Transaction Summary
    w2-k8s: ================================================================================
    w2-k8s: Install  1 Package (+3 Dependent packages)
    w2-k8s:
    w2-k8s: Total download size: 7.0 M
    w2-k8s: Installed size: 23 M
    w2-k8s: Downloading packages:
    w2-k8s: --------------------------------------------------------------------------------
    w2-k8s: Total                                               17 MB/s | 7.0 MB  00:00
    w2-k8s: Running transaction check
    w2-k8s: Running transaction test
    w2-k8s: Transaction test succeeded
    w2-k8s: Running transaction
    w2-k8s:   Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      1/4
    w2-k8s:   Installing : 2:vim-common-7.4.629-8.el7_9.x86_64                          2/4
    w2-k8s:   Installing : gpm-libs-1.20.7-6.el7.x86_64                                 3/4
    w2-k8s:   Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        4/4
    w2-k8s:   Verifying  : gpm-libs-1.20.7-6.el7.x86_64                                 1/4
    w2-k8s:   Verifying  : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        2/4
    w2-k8s:   Verifying  : 2:vim-common-7.4.629-8.el7_9.x86_64                          3/4
    w2-k8s:   Verifying  : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      4/4
    w2-k8s:
    w2-k8s: Installed:
    w2-k8s:   vim-enhanced.x86_64 2:7.4.629-8.el7_9
    w2-k8s:
    w2-k8s: Dependency Installed:
    w2-k8s:   gpm-libs.x86_64 0:1.20.7-6.el7           vim-common.x86_64 2:7.4.629-8.el7_9
    w2-k8s:   vim-filesystem.x86_64 2:7.4.629-8.el7_9
    w2-k8s:
    w2-k8s: Complete!
==> w3-k8s: Importing base box 'sysnet4admin/CentOS-k8s'...
==> w3-k8s: Matching MAC address for NAT networking...
==> w3-k8s: Checking if box 'sysnet4admin/CentOS-k8s' version '0.8.0' is up to date...
==> w3-k8s: Setting the name of the VM: w3-k8s(github_SysNet4Admin)
==> w3-k8s: Clearing any previously set network interfaces...
==> w3-k8s: Preparing network interfaces based on configuration...
    w3-k8s: Adapter 1: nat
    w3-k8s: Adapter 2: hostonly
==> w3-k8s: Forwarding ports...
    w3-k8s: 22 (guest) => 60103 (host) (adapter 1)
==> w3-k8s: Running 'pre-boot' VM customizations...
==> w3-k8s: Booting VM...
==> w3-k8s: Waiting for machine to boot. This may take a few minutes...
    w3-k8s: SSH address: 127.0.0.1:60103
    w3-k8s: SSH username: vagrant
    w3-k8s: SSH auth method: private key
    w3-k8s: Warning: Connection aborted. Retrying...
    w3-k8s: Warning: Connection reset. Retrying...
    w3-k8s: Warning: Remote connection disconnect. Retrying...
    w3-k8s: Warning: Connection aborted. Retrying...
    w3-k8s: Warning: Connection reset. Retrying...
    w3-k8s: Warning: Connection aborted. Retrying...
    w3-k8s:
    w3-k8s: Vagrant insecure key detected. Vagrant will automatically replace
    w3-k8s: this with a newly generated keypair for better security.
    w3-k8s:
    w3-k8s: Inserting generated public key within guest...
    w3-k8s: Removing insecure key from the guest if it's present...
    w3-k8s: Key inserted! Disconnecting and reconnecting using new SSH key...
==> w3-k8s: Machine booted and ready!
==> w3-k8s: Checking for guest additions in VM...
    w3-k8s: The guest additions on this VM do not match the installed version of
    w3-k8s: VirtualBox! In most cases this is fine, but in rare cases it can
    w3-k8s: prevent things such as shared folders from working properly. If you see
    w3-k8s: shared folder errors, please make sure the guest additions within the
    w3-k8s: virtual machine match the version of VirtualBox you have installed on
    w3-k8s: your host and reload your VM.
    w3-k8s:
    w3-k8s: Guest Additions Version: 5.2.12
    w3-k8s: VirtualBox Version: 6.1
==> w3-k8s: Setting hostname...
==> w3-k8s: Configuring and enabling network interfaces...
==> w3-k8s: Running provisioner: shell...
    w3-k8s: Running: C:/Users/admin/AppData/Local/Temp/vagrant-shell20240212-25972-c38h33.sh
    w3-k8s: Loaded plugins: fastestmirror
    w3-k8s: Determining fastest mirrors
    w3-k8s:  * base: mirror.kakao.com
    w3-k8s:  * extras: mirror.kakao.com
    w3-k8s:  * updates: mirror.kakao.com
    w3-k8s: Resolving Dependencies
    w3-k8s: --> Running transaction check
    w3-k8s: ---> Package epel-release.noarch 0:7-11 will be installed
    w3-k8s: --> Finished Dependency Resolution
    w3-k8s:
    w3-k8s: Dependencies Resolved
    w3-k8s:
    w3-k8s: ================================================================================
    w3-k8s:  Package                Arch             Version         Repository        Size
    w3-k8s: ================================================================================
    w3-k8s: Installing:
    w3-k8s:  epel-release           noarch           7-11            extras            15 k
    w3-k8s:
    w3-k8s: Transaction Summary
    w3-k8s: ================================================================================
    w3-k8s: Install  1 Package
    w3-k8s:
    w3-k8s: Total download size: 15 k
    w3-k8s: Installed size: 24 k
    w3-k8s: Downloading packages:
    w3-k8s: Running transaction check
    w3-k8s: Running transaction test
    w3-k8s: Transaction test succeeded
    w3-k8s: Running transaction
    w3-k8s:   Installing : epel-release-7-11.noarch                                     1/1
    w3-k8s:   Verifying  : epel-release-7-11.noarch                                     1/1
    w3-k8s:
    w3-k8s: Installed:
    w3-k8s:   epel-release.noarch 0:7-11
    w3-k8s:
    w3-k8s: Complete!
    w3-k8s: Loaded plugins: fastestmirror
    w3-k8s: Loading mirror speeds from cached hostfile
    w3-k8s:  * base: mirror.kakao.com
    w3-k8s:  * epel: mirror-icn.yuki.net.uk
    w3-k8s:  * extras: mirror.kakao.com
    w3-k8s:  * updates: mirror.kakao.com
    w3-k8s: Resolving Dependencies
    w3-k8s: --> Running transaction check
    w3-k8s: ---> Package vim-enhanced.x86_64 2:7.4.629-8.el7_9 will be installed
    w3-k8s: --> Processing Dependency: vim-common = 2:7.4.629-8.el7_9 for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    w3-k8s: --> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-8.el7_9.x86_64
    w3-k8s: --> Running transaction check
    w3-k8s: ---> Package gpm-libs.x86_64 0:1.20.7-6.el7 will be installed
    w3-k8s: ---> Package vim-common.x86_64 2:7.4.629-8.el7_9 will be installed
    w3-k8s: --> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-8.el7_9.x86_64
    w3-k8s: --> Running transaction check
    w3-k8s: ---> Package vim-filesystem.x86_64 2:7.4.629-8.el7_9 will be installed
    w3-k8s: --> Finished Dependency Resolution
    w3-k8s:
    w3-k8s: Dependencies Resolved
    w3-k8s:
    w3-k8s: ================================================================================
    w3-k8s:  Package              Arch         Version                  Repository     Size
    w3-k8s: ================================================================================
    w3-k8s: Installing:
    w3-k8s:  vim-enhanced         x86_64       2:7.4.629-8.el7_9        updates       1.1 M
    w3-k8s: Installing for dependencies:
    w3-k8s:  gpm-libs             x86_64       1.20.7-6.el7             base           32 k
    w3-k8s:  vim-common           x86_64       2:7.4.629-8.el7_9        updates       5.9 M
    w3-k8s:  vim-filesystem       x86_64       2:7.4.629-8.el7_9        updates        11 k
    w3-k8s:
    w3-k8s: Transaction Summary
    w3-k8s: ================================================================================
    w3-k8s: Install  1 Package (+3 Dependent packages)
    w3-k8s:
    w3-k8s: Total download size: 7.0 M
    w3-k8s: Installed size: 23 M
    w3-k8s: Downloading packages:
    w3-k8s: --------------------------------------------------------------------------------
    w3-k8s: Total                                               23 MB/s | 7.0 MB  00:00
    w3-k8s: Running transaction check
    w3-k8s: Running transaction test
    w3-k8s: Transaction test succeeded
    w3-k8s: Running transaction
    w3-k8s:   Installing : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      1/4
    w3-k8s:   Installing : 2:vim-common-7.4.629-8.el7_9.x86_64                          2/4
    w3-k8s:   Installing : gpm-libs-1.20.7-6.el7.x86_64                                 3/4
    w3-k8s:   Installing : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        4/4
    w3-k8s:   Verifying  : gpm-libs-1.20.7-6.el7.x86_64                                 1/4
    w3-k8s:   Verifying  : 2:vim-enhanced-7.4.629-8.el7_9.x86_64                        2/4
    w3-k8s:   Verifying  : 2:vim-common-7.4.629-8.el7_9.x86_64                          3/4
    w3-k8s:   Verifying  : 2:vim-filesystem-7.4.629-8.el7_9.x86_64                      4/4
    w3-k8s:
    w3-k8s: Installed:
    w3-k8s:   vim-enhanced.x86_64 2:7.4.629-8.el7_9
    w3-k8s:
    w3-k8s: Dependency Installed:
    w3-k8s:   gpm-libs.x86_64 0:1.20.7-6.el7           vim-common.x86_64 2:7.4.629-8.el7_9
    w3-k8s:   vim-filesystem.x86_64 2:7.4.629-8.el7_9
    w3-k8s:
    w3-k8s: Complete!

처음으로 만들었던 가상머신에 접속해서 ping 테스트 파일을 실행해 통신에 문제가 없는지 확인 후 종료한다.

C:\Users\admin\vagrantTest>vagrant ssh m-k8s
[vagrant@m-k8s ~]$ ./ping_2_nds.sh
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=1.00 ms
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.192 ms
64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=0.205 ms

--- 192.168.1.101 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.192/0.467/1.005/0.380 ms
PING 192.168.1.102 (192.168.1.102) 56(84) bytes of data.
64 bytes from 192.168.1.102: icmp_seq=1 ttl=64 time=0.347 ms
64 bytes from 192.168.1.102: icmp_seq=2 ttl=64 time=0.194 ms
64 bytes from 192.168.1.102: icmp_seq=3 ttl=64 time=0.214 ms

--- 192.168.1.102 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.194/0.251/0.347/0.070 ms
PING 192.168.1.103 (192.168.1.103) 56(84) bytes of data.
64 bytes from 192.168.1.103: icmp_seq=1 ttl=64 time=0.360 ms
64 bytes from 192.168.1.103: icmp_seq=2 ttl=64 time=0.188 ms
64 bytes from 192.168.1.103: icmp_seq=3 ttl=64 time=0.220 ms

--- 192.168.1.103 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.188/0.256/0.360/0.074 ms
[vagrant@m-k8s ~]$ exit
logout
Connection to 127.0.0.1 closed.

 
우리는 한번에 여러대의 가상머신에 접근하는게 필요하므로 슈퍼푸티를 설치해준다.

 

 

이제 쿠버네티스/도커 테스트 환경을 위한 준비가 되었다. 다음 포스팅에선 본격적으로 쿠버네티스가 무엇이고 어떻게 구성되었는지 알아본다.


Reference

도서: 컨테이너 인프라 환경 구축을 위한 쿠버네티스/도커
https://kgw7401.tistory.com/44

 
 

728x90
반응형