1대의 개발PC에서

여러 대의 Server 환경을 구축하고자 할 때 VirtualBox를 이용하곤 한다.

 

VirtualBox

 

Kubernetes 실습 환경을 구축하기 위해서

master 1대 + worker 2대 = 총 3대의 Ubuntu Server 머신이 필요한 경우를 생각해보자.

 

개인적인 취향으로 Ubuntu를 애용하는데,

Ubuntu를 설치하고 나면 locale 설정, timezone 설정 等 나름 여러가지로 셋팅을 할 것들이 많다.

 

그렇게 우선 master 역할을 할 1대의 Ubuntu Server를 셋팅을 했다고 해보자.

- https://www.whatwant.com/entry/Ubuntu-Server-2204-LTS

 

이제 worker 역할을 할 2대의 Ubuntu Server를 만들어야 하는데,

다시 또 OS 설치하고 셋팅하는 과정을 반복해야하는 것은 너무나 비효율적인 것 같다.

 

그래서 VirtualBox의 머신 복제 기능을 이용해보고자 한다.

 

복제

 

좀 더 많은 정보를 보려면 "전문가 모드"를 선택하면 된다.

원하는 머신 이름과 경로(Path)를 입력하고, MAC 정책은 새로운 MAC 주소 설정을 하도록 하자.

 

설정

 

이걸로 준비는 끝났다.

"Finish"를 눌러주면 복사가 이뤄진다. 생각보다 오래걸린다(개인적인 PC 환경 차이일 수도 있다^^).

 

Finish

 

이것으로 끝났을까!? 아니다!!!

일단 시작해서 부팅해보자.

 

부팅

 

여기에서 어떤 것이 문제가 될 수 있는지 찾아보기 바란다! ^^

 

$ hostname

master

 

그렇다! 원본과 같은 hostname을 쓰고 있다.

그러면 바꿔주면 된다 ^^

 

$ sudo hostnamectl set-hostname worker01

$ hostname

worker01

 

여기까지~

 

반응형

 

간만에 Server 버전을 설치해야할 상황이 생겨서 기록을 남겨보고자 한다.

 

https://ubuntu.com/download/server

 

현재 정확한 버전은 22.04.02 LTS 이다.

Server 버전임에도 용량이 1.8GB 라니 .... 대박이구만...

 

일단 아래 과정은 Windows 10 Host 환경의 VirtualBox 7.0.6 버전에서 진행을 했다.

 

운영체제는 Ubuntu (64-bit) 로 선택해야 한다.

 

VirtualBox - OS

 

지금 필요로 하는 환경이 낮은 Spec이어야 해서 2GB 메모리로만 설정을 했고,

core가 2개 이상이어야 해서 일단 2개로 선택했다.

 

VirtualBox - HW

 

디스크 용량은 어짜피 동적 용량이기에 조금은 여유있게 설정해주는 것이

혹시 모를 나중에 대비해 바람직한 선택이다.

 

VirtualBox - HDD

 

네트워크 설정은 "NAT"를 선택하는 것이 일반적이지만,

여기에서는 "어댑터에 브리지"를 선택해서 Host와 동일한 레벨에서 IP를 받을 수 있도록 하겠다.

(집에서 공유기를 쓰는 환경이라고 하면 공유기로부터 IP를 직접 받도록 하는 것)

 

VirtualBox - Network

 

이제 다운로드 받은 Ubuntu Server ISO 이미지를 등록해서 부팅 및 설치를 진행하자.

별도로 설명하지 않은 부분은 기본 설정으로 진행한 것이다.

 

Ubuntu Server

 

IP도 잘 받아온 것을 볼 수 있다.

 

IP

 

기본이 LVM 이다. 흐음... 그냥 가자.

 

LVM

 

기본 설정은 free 공간을 두는데, 그냥 전체를 다 사용하는 것으로 변경해보자.

 

Before

 

ubuntu-lv 설정을 아래와 같이 잡아주면 된다.

 

edit

 

after

 

OpenSSH server 설치는 필수다!!!

 

OpenSSH server

 

설치가 끝나면 Close 해줘야 한다.

 

Close

 

재부팅 하면 아래와 같이 에러 화면이 나오기도 한다.

걱정하지 말자.

 

cloud-init

 

엔터 한 번 치고

앞에서 입력한 계정 및 패스워드 치면 로그인 된다.

 

login

 

기분 나쁘게 에러 발생한 패키지부터 삭제하자

 

$ sudo apt purge cloud-init

 

sudo 했을 때 패스워드 입력하는게 기분나쁘니(?) 해결하자.

 

$ sudo visudo

 

제일 밑에 아래와 같이 (각자 계정으로) 입력해놓고 저장하면 된다.

 

whatwant ALL=(ALL) NOPASSWD:ALL

 

패키지 전체적으로 업데이트 및 업그레이드 하자.

 

$ sudo apt update

$ sudo apt upgrade

 

아래와 같은 화면이 나올 수 있는데, 그냥 바로 OK 하자.

 

 

필요 없는 것들 지우고 깔끔히 재부팅하자.

 

$ sudo apt autoremove

$ sudo reboot

 

 

Server에서 굳이 한글이 필요할까 싶지만, 그래도 세종대왕님을 생각하며...

 

$ sudo apt install language-pack-ko

$ sudo locale-gen ko_KR.UTF-8

$ sudo dpkg-reconfigure locales

$ sudo update-locale LANG=ko_KR.UTF-8 LC_MESSAGES=POSIX

 

locale

 

네트워크 관련 도구들을 사용하기 위해 net-tools 패키지를 설치하자.

 

$ sudo apt install net-tools

 

많이 쓰는 git 패키지도 설치하고, 기본 환경 설정까지 해놓자.

 

$ sudo apt install git

$ git config --global user.name "whatwant"
$ git config --global user.email "whatwant@gmail.com"

 

우리는 한국에 살고 있으니, TimeZone을 맞춰보자.

 

$ sudo timedatectl

               Local time: 금 2023-04-14 16:14:51 UTC
           Universal time: 금 2023-04-14 16:14:51 UTC
                 RTC time: 금 2023-04-14 16:14:51
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

 

정확한 TimeZone 명칭을 확인해보고,

 

$ sudo timedatectl list-timezones | grep Seoul

Asia/Seoul

 

설정해주면 된다.

 

$ sudo timedatectl set-timezone Asia/Seoul

$ sudo timedatectl

               Local time: 토 2023-04-15 01:16:05 KST
           Universal time: 금 2023-04-14 16:16:05 UTC
                 RTC time: 금 2023-04-14 16:16:05
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

 

심지어 "System clock synchronized: yes"라고 되어있는 것을 보면 시간 동기화 설정도 이미 되어있다!

 

 

 

개인적인 취향에 따른 설정도 추가적으로 해보자.

 

vi를 싫어하고 nano를 사용하기에 nano 기본 설정값을 넣어보겠다.

 

$ nano ~/.nanorc

 

tab을 공백 4칸으로 설정하는 것이다.

 

set tabsize 4
set tabstospaces

 

root 권한으로 사용하는 경우, 특히 sudo 사용할 때를 위해서 추가적으로... (내용은 동일)

 

 $ sudo nano /root/.nanorc

 

 

지극히 개인적인 취향으로 작업 공간 설정도 해놓겠다.

 

$ sudo mkdir /srv/workspace
$ sudo mkdir /srv/install

$ sudo chown whatwant:whatwant /srv/workspace/
$ sudo chown whatwant:whatwant /srv/install/

 

Server 환경이니만큼 굳이 zsh 등까지는 설치하지 않겠다.

 

 

추가적으로 VirtualBox Guest-Additions를 설치해보자.

GUI 환경이 없기에 생략할 수도 있긴 한데.... 그래도 성능 향상이 있다고 하니 해보자.

 

게스트 확장 CD 이미지

 

우리는 지금 Server 버전의 Ubuntu이기에 직접 마운트 작업을 해줘야 한다 ^^

 

$ sudo mkdir /media/cdrom

$ sudo mount /dev/cdrom /media/cdrom

 

해당 디렉토리로 이동해보자.

 

$ cd /media/cdrom/

$ ls -al

total 41763
dr-xr-xr-x 5 root root     2570  1월 12 01:28 .
drwxr-xr-x 3 root root     4096  4월 15 13:40 ..
-r--r--r-- 1 root root     1049  8월 23  2022 AUTORUN.INF
dr-xr-xr-x 2 root root     1252  1월 12 01:28 NT3x
dr-xr-xr-x 2 root root     2828  1월 12 01:28 OS2
-r--r--r-- 1 root root      592  1월 12 01:28 TRANS.TBL
-r--r--r-- 1 root root  2202917  1월 11 23:38 VBoxDarwinAdditions.pkg
-r-xr-xr-x 1 root root     4225  1월 11 23:35 VBoxDarwinAdditionsUninstall.tool
-r-xr-xr-x 1 root root  5968312  1월 11 23:36 VBoxLinuxAdditions.run
-r--r--r-- 1 root root  9332736  1월 11 23:38 VBoxSolarisAdditions.pkg
-r-xr-xr-x 1 root root 15755216  1월 12 01:27 VBoxWindowsAdditions-amd64.exe
-r-xr-xr-x 1 root root  9227840  1월 12 01:08 VBoxWindowsAdditions-x86.exe
-r-xr-xr-x 1 root root   243728  1월 11 23:38 VBoxWindowsAdditions.exe
-r-xr-xr-x 1 root root     6849  1월 11 23:35 autorun.sh
dr-xr-xr-x 2 root root     1468  1월 12 01:28 cert
-r-xr-xr-x 1 root root     5097  1월 11 23:35 runasroot.sh
-r--r--r-- 1 root root      259 10월  2  2021 windows11-bypass.reg

 

Guest-Additions를 설치하기 위해서 필요한 패키지들을 먼저 설치해줘야 한다.

 

$ sudo apt install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)

 

이제 설치를 진행하면 된다.

 

$ sudo ./VBoxLinuxAdditions.run

 

무슨 이상한 에러메시지가 나올 수 있으나 쫄지 말자.

GUI 환경이 없기에 발생하는 것이다.

 

재부팅하고 잘 설치되었는지 확인까지 해보자.

 

$ sudo reboot

---

$ lsmod | grep vbox

vboxguest             434176  0

$ modinfo vboxguest

filename:       /lib/modules/5.15.0-69-generic/misc/vboxguest.ko
version:        7.0.6 r155176
license:        GPL
description:    Oracle VM VirtualBox Guest Additions for Linux Module
author:         Oracle and/or its affiliates
srcversion:     55B45B43FE1759D12174E93
alias:          pci:v000080EEd0000CAFEsv00000000sd00000000bc*sc*i*
depends:
retpoline:      Y
name:           vboxguest
vermagic:       5.15.0-69-generic SMP mod_unload modversions

 

여기까지~ 끝~

반응형

 

오늘 포스팅을 위해

그동안 많은 과정을 거쳐왔나보다 ^^

 

- 오래된 노트북 - 우분투 서버로 만들기 (Ubuntu 20.04 Server)

- Ubuntu 18.04 에서 Python3 편하게 사용하기
- Kubernetes Install (Ubuntu 20.04)
- Kubespray 이용하여 Kubernetes 설치하기
- Vagrant 이미지 업로드 (VirtualBox)
- Vagrant 사용하기 - 기본

- Vagrant 여러 개의 VM 생성하기

 

포스팅으로만 하면 위의 내용 정도뿐이지만,

그 뒤에서 공부하고 시행착오를 겪은 것을 합치면.... 에휴...

멍청하면 손발 뿐만 아니라 온몸이 고생한다더니...

 

 

로컬 환경에서 VM을 이용한 Kubernetes 실습 환경을 갖추는 것이 목표이다.

 

VM 생성도 Vagrant를 이용해서 기본적인 사항은 편하게 할 수 있도록 했고,

Kubernetes 설치 과정은 공부를 위해 직접 수행하는 방식으로 구성했다.

 

즉, Ubuntu 꾸미기(?) 등과 같은 과정은 Skip 하고

공부가 필요한 Kubernetes 설치 과정은 가급적 직접 수행해보자.

 

(물론 Kubespray를 사용하지 않고 정말 쌩으로 해보면 좋겠지만... 어느 정도는 ^^)

 

 

 

0. Host Environment

  - 다음 Spec이 최소사양이라는 말은 아니고, 참고하시라고...

    . CPU: AMD Ryzen 5 3600X

    . RAM: 32GB

    . VGA: Nvidia GeForce RTX 2060

    . OS: Windows 10 Pro

 

 

1. Vagrant 설치

  - https://www.vagrantup.com/

 

 

2. VirtualBox 설치

  - https://www.virtualbox.org/

 

 

3. Vagrant Up

  - 다음 내용의 Vagrantfile을 이용해서 VM을 생성하자

    (개인적인 취향으로 Host의 git-bash 환경에서 작업하는 것을 좋아하기에

     아래 sh 명령어들이 linux 스타일로 되어있다)

 

host$ mkdir k8s-vm
host$ cd k8s-vm
host$ nano Vagrantfile
host$ vagrant up

 

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

N = 2


Vagrant.configure("2") do |config|


  config.vm.define "w-k8s-master" do |cfg|

    cfg.vm.box = "whatwant/Ubuntu-20.04-Server"
    cfg.vm.box_version = "0.2.0"

    cfg.vm.hostname = "master"
    cfg.vm.network "public_network", ip: "192.168.100.200"

    cfg.vm.provider "virtualbox" do |vb|
      vb.gui = false
      vb.cpus = "2"
      vb.memory = "2048"
    end

    cfg.vm.provision "shell", inline: <<-SHELL
      apt-get update
      apt-get upgrade -y
    SHELL

  end


  (1..N).each do |i|
    config.vm.define "w-k8s-worker#{i}" do |cfg|

      cfg.vm.box = "whatwant/Ubuntu-20.04-Server"
      cfg.vm.box_version = "0.2.0"

      cfg.vm.hostname = "worker#{i}"
      cfg.vm.network "public_network", ip: "192.168.100.20#{i}"

      cfg.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.cpus = "1"
        vb.memory = "1280"
      end

      cfg.vm.provision "shell", inline: <<-SHELL
        apt-get update
        apt-get upgrade -y
      SHELL

    end
  end

end

 

  - master 1대, worker 2대 구성으로 했다.

  - VM 이미지는 Ubuntu 20.04 Server 기반으로 미리 살짝 꾸며둔 것을 이용했다.

  - VM의 CPU/RAM 설정은 가급적 최소한의 규격으로 잡아두었다.

  - `vagrant up` 했을 때 종종 실패를 하는데, 여러 번 try하면 결국 된다.

  - IP 설정은 각자의 공유기 셋팅에 따라 수정이 필요하다.

 

 

4. (master) Kubespray 실행 환경 만들기

  - Kubespray는 ansible 기반이기에 그에 따른 환경을 갖춰야 한다.

  - 필요한 package 설치 후 ssh 접근이 가능하도록 키 생성 & 배포를 진행한다.

  - 패스워드는 `vagrant`이다.

 

host$ ssh vagrant@192.168.100.200

master$ sudo apt install ansible python3-argcomplete

master$ ssh-keygen

master$ ssh-copy-id 192.168.100.200

master$ ssh-copy-id 192.168.100.201

master$ ssh-copy-id 192.168.100.202

 

  - ansible에서 접근할 서버 정보들을 입력해놓자

$ sudo nano /etc/ansible/hosts
[all]
master  ansible_ssh_host=192.168.100.200 ip=192.168.100.200 ansible_user=vagrant
worker1 ansible_ssh_host=192.168.100.201 ip=192.168.100.201 ansible_user=vagrant
worker2 ansible_ssh_host=192.168.100.202 ip=192.168.100.202 ansible_user=vagrant

[k8s_master]
master

[k8s_worker]
worker1
worker2

  - 테스트

$ ansible all -m ping

 

 

5. (master/worker) Kubernetes 설치를 위한 환경 설정

  - master/worker 모두 Kubernetes 설치를 위한 환경 설정을 진행해야 한다.

  - swap 공간 사용하지 않도록 하고, 서로 접근이 용이하게 되도록 host 설정을 해주자.

  - ip forward 기능도 활성화 시켜줘야 한다.

 

  - master/worker 접근은 앞에서 했던 것과 마찬가지로 `ssh vagrant@192.168.100.200/201/202` 방식으로...

 

master/worker$ sudo swapoff -a

master/worker$ sudo nano /etc/fstab
# /swap.img   none    swap    sw  0   0

master/worker$ sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'

master/worker$ sudo nano /etc/hosts
192.168.100.200 master
192.168.100.201 worker1
192.168.100.202 worker2

 

 

6. (master/worker) Restart

  - 깔끔한 진행을 위해 이 시점에서 모두 restart 진행하고 이후 진행하자!

 

 

7. (master) Kubespray 이요한 Kubernetes 설치

  - 이제 기본환경 준비는 끝났다.

  - Kubespray 설치 준비를 할 차례다.

host$ ssh vagrant@192.168.100.200

master$ cd /srv/install

master$ git clone https://github.com/kubernetes-sigs/kubespray.git

master$ cd kubespray

master$ git checkout v2.16.0

master$ sudo pip install -r requirements.txt

master$ cp -rfp inventory/sample inventory/mycluster

master$ declare -a IPS=(192.168.100.200 192.168.100.201 192.168.100.202)

master$ CONFIG_FILE=inventory/mycluster/hosts.yaml python contrib/inventory_builder/inventory.py ${IPS[@]}

master$ nano ./inventory/mycluster/hosts.yaml

  - 아래와 같이 수정해보자.

all:
  hosts:
    master:
      ansible_host: 192.168.100.200
      ip: 192.168.100.200
      access_ip: 192.168.100.200
    worker1:
      ansible_host: 192.168.100.201
      ip: 192.168.100.201
      access_ip: 192.168.100.201
    worker2:
      ansible_host: 192.168.100.202
      ip: 192.168.100.202
      access_ip: 192.168.100.202
  children:
    kube_control_plane:
      hosts:
        master:
    kube_node:
      hosts:
        worker1:
        worker2:
    etcd:
      hosts:
        master:
    k8s_cluster:
      children:
        kube_control_plane:
        kube_node:
    calico_rr:
      hosts: {}

  - 당연하게도 위의 설정은 각자 IP 환경에 맞게 업데이트

 

master$ nano ./inventory/mycluster/group_vars/k8s_cluster/addons.yml

 

  - addons는 아래 3개 정도만 해보자. (ingress는 나중에 직접 설치할 것이다)

dashboard_enabled: true
helm_enabled: true
metrics_server_enabled: true

 

  - proxy mode도 iptables로 변경해보자

master$ nano ./inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml
# Kube-proxy proxyMode configuration.
# Can be ipvs, iptables
kube_proxy_mode: iptables

 

 

8. (master) execute

  - 이제 정말로 준비는 끝났다. 설치 시작~!!

master$ cd /srv/install/kubespray

master$ ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml

 

 

9. (master) 계정 설정

  - root가 아닌 일반 계정에서 `kubectl` 명령어를 사용하기 위한 설정을 하자

 

master$ mkdir -p $HOME/.kube

master$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

master$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

master$ echo "source <(kubectl completion zsh)" >> ~/.zshrc

master$ source ~/.zshrc

 

 

10. (master) 점검

  - 잘 되었는지 살펴보자.

master$ kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:6443

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.



master$ kubectl get nodes
NAME    STATUS     ROLES                  AGE   VERSION
node1   Ready      control-plane,master   14m   v1.20.7
node2   NotReady   <none>                 13m   v1.20.7
node3   NotReady   <none>                 13m   v1.20.7

 

 

성공~!!!

반응형

'Dev Tools > Kubernetes' 카테고리의 다른 글

Kubernetes 설치  (0) 2023.04.17
Install `NGINX Ingress Controller` in Kubernetes  (4) 2021.09.18
MinIO StandAlone in Kubernetes  (0) 2021.05.13
Kubespray 이용하여 Kubernetes 설치하기  (4) 2021.05.04
Kubernetes Install (Ubuntu 20.04)  (0) 2020.12.28

 

최근 Docker 또는 Kubernetes 인기로 인하여 Container가 인기의 주역이 되면서

주로 VM 환경과 같이 사용되는 Vagrant의 인기가 많이 줄어든 것 같다.

 

하지만, 여전히 VM에 대한 수요는 있고

Vagrant의 효용성도 여전히 높다고 여겨지기에 공부를 해보려 한다.

 

 

01. Vagrant

  - Vagrant 메인 사이트는 vagrant.com이 아니라 vagrantup.com 이다 ^^

  - https://www.vagrantup.com/

 

 

02. Install

  - 설치는 별거 없다. 그냥 슝슝~

 

 

03. Vagrant Hub ?

  - DockerHub처럼 Vagrant에서도 Hub가 있다 !!

  - https://app.vagrantup.com/

 

 

04. VirtualBox Guest OS 준비

  - Ubuntu 20.04 Server 이미지를 만들어서 업로드 해봤다.

  - Vagrant Box로 만들기 위해서는 다음의 과정을 거쳐야 한다.

 

  ① 작업 환경

    - Host PC(Windows 10)에서 VirtualBox 설치

    - VirtualBox에서 Guest OS로 Ubuntu 20.04 Server 설치

    → Vagrant Box 업로드 用 이미지로 만들기 위한 과정 진행 !!

 

  ② vagrant 계정 생성
    - 패스워드도 vagrant로 설정

$ sudo adduser vagrant

 

 

  ③ visudo 등록

 

$ sudo visudo

# Add the following line to the end of the file.
vagrant ALL=(ALL) NOPASSWD:ALL

 

  ④ SSH 설정

 

$ sudo su vagrant


$ cd

$ mkdir .ssh

$ wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O .ssh/authorized_keys

--2021-07-04 18:37:56--  https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
Resolving raw.github.com (raw.github.com)... 185.199.111.133, 185.199.109.133, 185.199.108.133, ...
Connecting to raw.github.com (raw.github.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub [following]
--2021-07-04 18:37:57--  https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.111.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 409 [text/plain]
Saving to: ‘.ssh/authorized_keys’

.ssh/authorized_keys             100%[========================================================>]     409  --.-KB/s    in 0s

2021-07-04 18:37:57 (36.9 MB/s) - ‘.ssh/authorized_keys’ saved [409/409]

 

  ⑤ SSH Server 설치

 

$ sudo apt install -y openssh-server

$ sudo nano /etc/ssh/sshd_config

Port 22
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no

$ sudo service ssh restart

 

  ⑥ hostname 변경

    - 이 부분은 꼭 필요한 과정은 아니고, 필요에 따라서...

 

$ hostnamectl set-hostname whatwant

 

  ⑦ 불필요한 계정 정리

    - 이 부분 역시 꼭 필요한 과정은 아니고, 필요에 따라서...

 

$ sudo deluser whatwant

 

  ⑧ 동적 디스크 정리

    - VIrtualBox의 디스크 영역을 깨끗하게 정리하기 위해서 수행

 

$ sudo dd if=/dev/zero of=/EMPTY bs=1M

$ sudo rm -f /EMPTY

 

  ⑨ 시스템 종료

 

$ sudo shutdown -h now

 

 

05. convert Image(Vagrant Box)

  - 이제 준비된 VirtualBox Image를 Vagrant Image로 convert 해보자.

  - VirtualBox Guest 파일들이 저장된 위치를 찾아서 이동

> dir
total 14473272
drwxr-xr-x 1 whatw 197609           0  7월  4 18:30  Logs/
drwxr-xr-x 1 whatw 197609           0  7월  4 18:23  Snapshots/
-rw-r--r-- 1 whatw 197609       20613  7월  4 18:30 'Ubuntu 20.04 Server Worker1.vbox'
-rw-r--r-- 1 whatw 197609       20642  7월  4 18:23 'Ubuntu 20.04 Server Worker1.vbox-prev'
-rw-r--r-- 1 whatw 197609 14820573184  5월  5 16:49 'Ubuntu Server 20.vdi'

  - `package` 명령어를 이용해서 convert 하면 된다.

  - 아래 타이핑한 내역을 잘 살펴보기 바란다 (.vbox 사용하지 않기와 같은...^^)

> vagrant package --base "Ubuntu 20.04 Server Worker1" --out "ubuntu2004server.box"
==> Ubuntu 20.04 Server Worker1: Attempting graceful shutdown of VM...
    Ubuntu 20.04 Server Worker1: Guest communication could not be established! This is usually because
    Ubuntu 20.04 Server Worker1: SSH is not running, the authentication information was changed,
    Ubuntu 20.04 Server Worker1: or some other networking issue. Vagrant will force halt, if
    Ubuntu 20.04 Server Worker1: capable.
==> Ubuntu 20.04 Server Worker1: Forcing shutdown of VM...
==> Ubuntu 20.04 Server Worker1: Exporting VM...
==> Ubuntu 20.04 Server Worker1: Compressing package to: C:/Users/whatw/VirtualBox VMs/Ubuntu 20.04 Server Worker1/ubuntu2004server.box

 

 

06. add Box

  - 위에서 만든 Box를 등록하는 과정이다

> vagrant box add "ubuntu2004server" "C:\Users\whatw\ubuntu2004server.box"

==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu2004server' (v0) for provider:
    box: Unpacking necessary files from: file:///C:/Users/whatw/ubuntu2004server.box
    box:
==> box: Successfully added box 'ubuntu2004server' (v0) for 'virtualbox'!

 

 

07. SHASUM

  - 뒤에 사용될 것을 미리 확인해놓자

  - 파일 이름 뒤의 `SHA256`을 꼭 써줘야 한다!!!

> certutil -hashfile .\ubuntu2004server.box sha256

SHA1의 .\ubuntu2004server.box 해시:
7e6b73addaaea6c430c54dc16fd968ba740c7272e68807e0cf57f6fa5e28c499
CertUtil: -hashfile 명령이 성공적으로 완료되었습니다.

 

08. Vagrant Cloud 준비

  - `03. Vagrant Hub ?`에서 회원가입을 했다면 아래와 같은 화면을 확인할 수 있다.

 

 

  - `Create a new Vagrant Box` 클릭하고 계속 진행해보자.

 

 

 

  - 버전은... 링크로 있는 `RubyGems versioning`을 한 번 확인해보기 바란다.

  - 제대로 사용하도록 하려면 사실 `1.0.0`으로 해주는 것이...

 

 

  - 앞에서 미리 확인한 SHA Checksum 값을 넣어주면 된다. (위의 이미지에 있는 Checksum 값은 틀렸다 ^^)

 

 

  - 업로드~ 쭉~ 쭉~ 쭉쭉쭉~

 

 

  - 처음에는 위와 같이 `unreleased` 상태로 나온다.

  - `Release` 버튼을 눌러버리면 ...

 

 

  - 이제 뭔가 잘 된 것 같다!

 

 

끄읕~~~ (정리는 왠지 항상 힘들어...)

반응형



Minikube를 가지고 놀고 싶은데,

내 PC를 지저분하게 만들기가 싫어서...


최애하는 VirtualBox에 Ubuntu 설치해놓고

그 안에 Minikube를 설치해보고자 한다.



Reference: https://kubernetes.io/ko/docs/tasks/tools/install-minikube/



작업환경

    - Host OS: Windows 10

    - VirtualBox v6.1.12 r139181 (Qt5.6.2)

    - Guest OS: Ubuntu 18.04 Desktop

        . 2 CPU, 8192 Memory




1. 가상화 환경?!


    - "가상화 지원 여부를 확인"하란다. 현재 작업하고 있는 PC가 AMD라서 좀 찝찝한데...

    - VirtualBox의 Guest 환경에서 아래와 같이 "네스티드 VT-x/AMD-V 사용하기(V)"에 체크를 해주었다.




    - 뭔가 나오니까 된 것 같다.


❯ grep -E --color 'vmx|svm' /proc/cpuinfo

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch ssbd vmmcall fsgsbase avx2 clflushopt arat nrip_save flushbyasid decodeassists

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch ssbd vmmcall fsgsbase avx2 clflushopt arat nrip_save flushbyasid decodeassists




2. VirtualBox 설치 ?


    - VirtualBox in VirtualBox ??? 뭔가 이상하지만... 훌륭한 우리 VirtualBox는 이게 된다.


❯ sudo apt install -y virtualbox virtualbox-ext-pack




3. kubectl 설치


    - 제일 먼저 할 것은 현재 최신 버전이 뭔지 확인하는 것이다.


https://storage.googleapis.com/kubernetes-release/release/stable.txt


    - 지금 확인해본 결과는 v1.18.8 이었다.

    - 다운로드 받자. (다운로드 받는 경로나 wget을 사용하는 것은 개인적인 


> cd /srv/install/kubectl


> wget https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl


    - 설치하자


❯ chmod +x ./kubectl 


❯ sudo cp ./kubectl /usr/local/bin/kubectl


    - 잘 설치되었는지 확인해보자.


❯ kubectl version --client


Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.1", GitCommit:"7879fc12a63337efff607952a323df90cdc7a335", GitTreeState:"clean", BuildDate:"2020-04-08T17:38:50Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}




4. Minikube 설치


    - 다운로드 받아보자


> cd /srv/install/minikube


> wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube


    - 설치하자


❯ chmod +x ./minikube 


❯ sudo install minikube /usr/local/bin





5. Minikube 실행


    - 실행은 엄청 쉽다


❯ minikube start





6. dashboard


    - minikube는 대시보드도 간단히 제공해준다.


❯ minikube dashboard


🔌  대시보드를 활성화하는 중 ...

🤔  Verifying dashboard health ...

🚀  프록시를 시작하는 중 ...

🤔  Verifying proxy health ...

🎉  Opening http://127.0.0.1:40647/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...

[7090:7090:0822/025314.671219:ERROR:viz_main_impl.cc(150)] Exiting GPU process due to errors during initialization


    - 알아서 Chrome이 뜬다. (아! 개인적인 취향으로 VirtualBox에 Ubuntu 설치하자마자 Chrome을 미리 설치해놨다)





7. docker 설치


    - minikube를 가지고 놀기 위해서는 docker가 필요하다.


❯ sudo apt install -y docker.io


    - 현재 사용자 계정으로 docker를 실행할 수 있도록 하자


❯ sudo usermod -aG docker $USER


❯ newgrp docker


    - 현재 계정을 docker 그룹에 넣어도 바로 적용되지 않는다. 재부팅하기 귀찮아서 newgrp으로 지금 docker 그룹에 속한 것처럼 해버렸다.


    - 잘 설치되었는지 실행해보자. Permission 에러가 안나오면 된다.


❯ docker ps -a


CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES



가지고 노는 것은 다음 기회에~

반응형

기본적인 공유에 대해서는 다음 아티클로 포스팅을 했었다.

   - http://whatwant.tistory.com/381

공용폴더를 설정한 후 우분투를 부팅하게 되면 아래와 같이 공유 폴더가 /media/ 디렉토리 밑에 보이게 된다.


$ ls -al

합계 12

drwxr-xr-x     4  root   root      4096  8월 17 16:12 ./

drwxr-xr-x   23   root   root     4096  8월 17 14:02 ../

drwxrwx---   1   root   vboxsf      0  8월 17 16:14 sf_Share/


소유권한 부분을 보면 알겠지만, root 계정과 vboxsf 그룹에 속한 디렉토리이다.

그렇기에 일반 계정으로는 접근하려면 상당히 귀찮다. 권한에 막혀버리니...

$ sudo usermod -G vboxsf -a <계정>


위와 같이 사용하고 있는 계정을 [ vboxsf ] 그룹에 속하게 해주면 된다.



VirtualBox를 사용하는 많은 분들이 게스트 운영체제로 리눅스를 사용할 때에
공용 폴더를 자동으로 마운트를 하고서도 다시 마운트를 잡아주곤 한다.

경로를 다시 잡아주기 위해서라거나 분명한 사유가 있어서라면 그렇게 해도 되겠지만,
자동으로 마운트 설정을 잡아준 상황에서 궂이 그렇게 할 필요가 있나 싶다.

다만, 권한 문제로 사용하기가 불편하니 위와 같이 권한 설정으로 편하게 사용하자.


반응형

VirtualBox : https://www.virtualbox.org/
v4.3.6
2013.12.18


Git : http://git-scm.com/
v1.8.5.2
2013.12.17


Subversion : http://subversion.apache.org/
v1.8.5
2013.11.25


Redmine : http://www.redmine.org/
v2.4.1
2013.11.23


Jenkins : http://jenkins-ci.org/
v1.542
2013.12.02
LTS
v1.509.4
2013.10.09


Gerrit : http://code.google.com/p/gerrit/
v2.8
2013.12.04 
반응형

'Development Tools' 카테고리의 다른 글

EGit 건드려 보기- 기본빌드  (0) 2014.07.17

정신없는 업무로 한동안 집에서 컴퓨터를 만지지 못하다가,
간만에 집에서 뭔가 해보려 VirtualBox를 실행했는데... 새로운 버전이 나왔단다.


VirtualBox 4.3.6 (released 2013-12-18)
   This is a maintenance release. The following items were fixed and/or added:

   VMM: fixed a Guru Meditation VINF_EM_TRIPLE_FAULT caused by VMCB caching with nested paging on certain AMD CPUs (bug #12451)
   VMM: fixed a Guru Meditation VERR_VMX_UNEXPECTED_INTERRUPTION_EXIT_TYPE while intercepting debug exceptions (VT-x only; bug #12410)
   VMM: fixed a Guru Meditation VERR_SVM_UNEXPECTED_EXIT while intercepting debug register accesses (AMD-V only; bug #12481)
   VMM: fixed a VERR_SSM_STRUCTURE_MAGIC error when trying to load a saved state made with VBox 4.3.4 when VT-x/AMD-V is disabled. Unfortunately, VBox 4.3.4 produced broken saved states for this configuration so you have to discard these states (bug #12414)
   VMM: added a few more MSRs to the whitelist required by certain guests (bug #12245)
   GUI: fixed deleting of inaccessible VMs (4.3 regression, bug #12205)
   GUI: fixed warnings in VM settings / number of guest processors (bug #12480)
   Main: don't automatically enable 64-bit guests on 64-bit hosts if VT-x/AMD-V is not available (bug #12424)
   Main: always expose the DMI memory information to Windows 2012 guests (bug #12017)
   Main: fixed occasional crashes on guest display resolution change (bug #7063)
   Main: fixed reporting back temporary name when calling IGuestSession::DirectoryCreateTemp() (bug #12498)
   API: fix for a hang when launching a GUI VM through the API, which crashes due to GUI unavailability
   Storage: fix for BLKCACHE_IOERR runtime errors under rare circumstances (bug #11030)
   Network: allow to start more than 5 PCNet instances (bug #12426)
   E1000: if the cable was disconnected before the guest initialized the device, the link status was not properly set to 'down' after the initialization completed despite the fact that there was no connection
   3D support: fixed offset of guest 3D image elements (Mac OS X Retina hosts only; bug #11021)
   Solaris hosts: fixed accessing the host driver from non-global zones (4.3 regression, bug #12271)

뭔가 어려운 내용들이 개선이 된 것 같은데, 피부에 와닿는 부분은 잘 모르겠다 ^^
그냥 계속 되는 개선이 고마울 뿐....

반응형

+ Recent posts