[컴] Windows Docker 설치 후 VMbox 가 안되는 경우

 vmbox 설치 에러 / 우분투 vmbox 설치에러 / kali vm box 설치 에러 /ubuntu checking disks error / vtx / hyperv

 

Windows Docker 설치 후 VMbox 가 안되는 경우

일단 결론

아직은 wsl1 과 함께 virtual box 를 사용하는 것이 나아 보인다. (2020-09-13)
 

2021-06-06: 지금 생각은 wsl2 와 docker 로 사용을 하는 것이 좋아 보인다. 이전에 wsl2 를 쓰지 않았던 또 하나의 이유는 distro image 의 path 를 변경할 수 없었던 것이었는데, 그것도 해결된 것 같다.(참고)

hyper-v 실행으로 vmbox 가 안된다.

Docker 를 설치후 vmbox 의 vm 이 실행이 안되거나, 설치가 안되는 문제가 있다. 이유는 docker 에서 windows 의 hyper-v 를 이용해야 해서, windows 의 hyper-v 를 설치하고 enable 하게 된다.

windows hyper-v 와 vm 의 os kernel 에서 모두 cpu 의 가상화 기술(Intel virtualization technology (VT-x), AMD-V) 를 사용하기 때문에 2개가 동시에 사용될 수 없다.[ref. 1] 하지만 이것이 Windows v1803 update 이후로 변경됐다고 한다. windows 에서 자신들이 VT-x 를 점유하고 있을 때도 다른 vm os 에서 hypervisor 를 사용할 수 있게 interface 를 마련한것이다. (참고: Hyper-V Architecture | Microsoft Docs)

Windows 하이퍼바이저 플랫폼 켜기

아래 처럼 제어판에가서 기능을 켜고, 재부팅을 하자.


그리고 나서 vmbox 에서 아래처럼 hyper-v 를 사용한다고 설정을 변경해 주자.

문제점


hyper V 를 끄고, 재부팅 하는 방법

  • bcdedit /set hypervisorlaunchtype off
  • shutdown -r -t 0

다시 enable 하려면  

  • bcdedit /set hypervisorlaunchtype auto

를 사용하면 된다.

"Hyper-V 가상 컴퓨터 관리" 서비스 만 '중지

참고로 ref. 3 에서 hyber-v 를 disable 하는 방법중에 service 를 중지하는 법이 나오는데, "Hyper-V 가상 컴퓨터 관리" 서비스 만 '중지' 하는 것으로는 여전히 vmbox 에서 문제가 된다.

 


References

  1. How to use VirtualBox and Hyper-V together on Windows 10 - H2S Media
  2. BCDEdit Command-Line Options | Microsoft Docs
  3. system installation - Error when installing Ubuntu 20.04 in VirtualBox - Ask Ubuntu
  4. How to Disable or Turn off Hyper-V in Windows 10 - Four Options

[컴][윈도우즈] WSL 에서 VM disk 위치

wsl file 위치 /윈도우 폴더 / 파일 폴더 path / 어디 / 위치 / wsl위치 / 가상디스크 위치 

WSL 에서 VM disk 위치

Get-AppxPackage -Name "*<distro>*" | Select PackageFamilyName %LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\<disk>.vhdx

  • path example
    • c:\Users\<user>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rxxx1xxxxgsc
    • c:\Users\<user>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rxxx1xxxxgsc\LocalState\ext4.vhdx
  • 기본 size : ubuntu 20 의 경우 기본 size 가 1.2GB 정도 됐다. 대부분 vhdx 의 size 이다.
  • 기본적으로 ref. 1 --> note 에서는 이 .vhdx 의 경로를 바꾸지 말라고 한다.

See Also

  1. Mount vdi as drive in Windows - Super User: windows 에서 ImDrive 로 mount 를 할 수는 있지만, file system 이 NTFS/FAT 이 아니라면, 인식을 할 수 없다. 
  2. 쿠…sal: [컴] wsl command : 여기서 wsl --export 를 이용하면 wsl 의 image path 를 변경할 수 있다.

Reference

  1. Comparing WSL 2 and WSL 1 | Microsoft Docs

[컴] microk8s 설치

 

microk8s

windows 10

  1. multipass 설치
  2. Microk8s 설치 : microk8s 실행(microk8s install)
  3. microk8s status --wait-ready :상태확인
  4. Kubernetes 접근

아래처럼 microk8s kubectl 를 실행하면 microk8s 가 가지고 있는 kubectl 을 실행하게 된다. microk8s kubectl get nodes

  • microk8s kubectl get nodes
  • microk8s kubectl get pods
  • microk8s kubectl get services
  • microk8s kubectl create deployment hello-namh --image=k8s.gcr.io/echoserver:1.10
  • microk8s kubectl get all --all-namespaces

dashboard

microk8s enable dashboard
microk8s dashboard-proxy

만약 기능을 끄려면 disable 을 사용하면 된다.

microk8s disable 

화면에 접속주소(ex: https://172.19.250.254:10443) 와 login 할 때 사용하는 token 이 나온다. 접속하고나서 token 을 이용해서 접속하면 된다.

on/off

microk8s startmicrok8s stop 로 microk8s 를 켜고 끌 수 있다.

테스크용 쿠버네티스 클라우드

[컴] Minikube 설치 및 실행

 미니큐브 / 쿠버네티스 테스트 방법 /로컬에서 쿠버 k8s 


Minikube

minikube 로 local 에서 kubernetes 를 경험할 수 있다. 그래서 일단 minikube 를 설치하자. 여기서는 linux 를 기준으로 설명한다.

참고로 kind 라는 것도 존재한다.
Okteto kubernetes 에서 개발용도로 kubernetes 를 쉽게 사용할 수 있게 해준다.

 

Minikube Features

Minikube 는 Kubernetes 기능중 아래 것들을 제공해 준다.

  • DNS
  • NodePorts
  • ConfigMaps and Secrets
  • Dashboards
  • Container Runtime: Docker, CRI-O, and containerd
  • Enabling CNI (Container Network Interface)
  • Ingress

vmbox 를 사용하는 경우

  • core 는 2개 이상
  • memory 는 4GB 이상이 좋다. 3GB 로 했을때는 system overhead 에 대한 여유공간이 없다고 메시지가 뜬다.

kubectl 설치

minikube 설치

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube

sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/

minikube start --driver=docker

<diver_name> 은 아래 중 하나를 택할 수 있다. 여기선 docker 를 택해보자.

  • docker
  • kvm2
  • none
  • podman
  • virtualbox
  • vmware

Docket 설치는 Install Docker Engine on Ubuntu | Docker Documentation 를 참고하자.

vmbox 에서 1 core cpu 를 사용하면, 아래같은 error 를 확인할 수 있다.

Exiting due to RSRC_INSUFFICIENT_CORES: Docker has less than 2 CPUs available, but Kubernetes requires at least 2 to be available

docker permission

아래처럼 docker group 에 user 를 넣어줘야 한다.

$ sudo usermod -aG docker $USER && newgrp docker

안그러면 아래같은 error 를 만나게 된다.

Exiting due to PROVIDER_DOCKER_ERROR: "docker version --format -" exit status 1: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix /var/run/docker.sock: connect: permission denied
💡  Suggestion: Add your user to the 'docker' group: 'sudo usermod -aG docker $USER && newgrp docker'

minikube start --driver=docker

이 명령어가 VM 을 생성하고 설정(configure) 한다. 그리고 이 VM 에서 single-node Kubernetes cluster 를 실행한다. 또한 이 cluster 와 통신하기 위해 kubectl 설정도 한다.[ref. 2]

--driver 로 vm driver 를 설정하게 된다. 한 번 설정되면, 그냥 minikube start 로 수행하면 된다. 다시 변경하려면 다시 --driver 를 이용해서 설정하면 된다. 자세한 내용은 여기를 참고하자

현재 3.08GB 인데 아래같은 error 가 떴다. 그래서 minikube start --memory=2200mb 를 해서 실행했다.

na@na-VirtualBox:~$ minikube start --driver=docker
😄  Ubuntu 20.04 (vbox/amd64) 위의 minikube v1.13.0
✨  유저 환경 설정 정보에 기반하여 docker 드라이버를 사용하는 중

🧯  The requested memory allocation of 2200MiB does not leave room for system overhead (total system memory: 3000MiB). You may face stability issues.
💡  Suggestion: Start minikube with less memory allocated: 'minikube start --memory=2200mb'

3GB ram 에서 실행한 경우

na@na-VirtualBox:~$ minikube start --driver=docker
😄  Ubuntu 20.04 (vbox/amd64) 위의 minikube v1.13.0
✨  유저 환경 설정 정보에 기반하여 docker 드라이버를 사용하는 중

🧯  The requested memory allocation of 2200MiB does not leave room for system overhead (total system memory: 3000MiB). You may face stability issues.
💡  Suggestion: Start minikube with less memory allocated: 'minikube start --memory=2200mb'

👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
💾  Downloading Kubernetes v1.19.0 preload ...
    > preloaded-images-k8s-v6-v1.19.0-docker-overlay2-amd64.tar.lz4: 486.28 MiB

🔥  Creating docker container (CPUs=2, Memory=2200MB) ...
🐳  쿠버네티스 v1.19.0 을 Docker 19.03.8 런타임으로 설치하는 중
🔎  Verifying Kubernetes components...
🌟  Enabled addons: default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube" by default

4GB ram 에서 실행한 경우

na@na-VirtualBox:~$ minikube start
😄  Ubuntu 20.04 (vbox/amd64) 위의 minikube v1.13.0
✨  기존 프로필에 기반하여 docker 드라이버를 사용하는 중
👍  Starting control plane node minikube in cluster minikube
🔄  Restarting existing docker container for "minikube" ...
🐳  쿠버네티스 v1.19.0 을 Docker 19.03.8 런타임으로 설치하는 중
🔎  Verifying Kubernetes components...
🌟  Enabled addons: default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube" by default

그밖의 명령어

  • minikube status
  • minikube stop
    • cluster 를 멈추고, Minikube Virtual Machine 끈다(shut down)
    • 모든 cluster state 와 data 는 보존된다.
  • minikube delete : clear minikube's local state
    • delete을 한 이후에는 minikube start 로 다시 minikube cluster 를 생성해야 한다.

etc

vm(minikube 같은) 을 띄우지 않고 바로 kubernetes 를 사용하려면 MicroK8s 도 괜찮을 수 있다.(linux, windows, macos 용을 제공한다.)

아래 site 에서 무료로 사용해 볼 수 있다.

[컴][nodejs] SocketCluster

 

SocketCluster 

nodejs 에서 사용할 수 있는 scalable 한 famework 이다.

v15 이상 버전의 예제에서는 vertically scale 하는 것은 찾을 수 없는듯 보인다.

scc-guide.md 정리

SCC 는 SocketCluster 를 여러머신에서 scale 하고 deploy 하기 쉽게 도와주는 서비스들의 모음. SCC 는 쿠버네티스(Kubernetes)에서 실행되는 것에 최적화 되어 있지만, 쿠버네티스가 없어도 setup 할 수 있다.

SCC 의 구성

  • scc-worker
  • scc-broker
  • scc-state
  • scc-ingress (Kubernetes only)

각 SCC service 설명

  • scc-worker (SocketCluster) https://github.com/SocketCluster/socketcluster
    • 일반적인 SocketCluster instance 들로 이뤄졌다.
    • single instance 를 돌리는 것과 cluster 로 돌리는 것의 차이는 각각의 scc-worker instance 에게 동작하고 있는 scc-state instance 알려줘야 한다?
  • scc-broker service https://github.com/SocketCluster/scc-broker
    • scc-broker instance 들로 이뤄졌다.
    • frontend 와 맞닿아 있는 scc-worker instance 들 사이의 broker message 를 위해 design 된 특별한 backend-only service
    • 전체 시스템안에 있는 모든 pub/sub 채널들은 available scc-broker instance 들 위에서 평등하게 sharded 된다
    • scc-worker instance 처럼, 각가의 scc-broker instance 에게 state server 를 알려줘야 한다.
  • scc-state service https://github.com/SocketCluster/scc-state
    • 하나의 instance 로 되어 있다.
    • cluster 의 state 를 모든 관심있는 service 들에 dispatch 해서 그들이 reshard 가 가능하게 하도록 해준다.
    • ssc-state instance 는 새로운 backend scc-broker 가 cluster 에 join 할 때마다 모든 frontend scc-worker instance 들에게 알려준다.
      • 이것은 새로운 scc-broker instance 가 cluster 에 join 할 때마다, scc-worker instance 들이 pub/usb 채널들을 available broker들을 공평하게 rebalance 할 수 있게 해준다.

데모영상 with v14

 

 

 

[컴] Akka Streams

 

아래 내용을 일부 번역했다. 

Akka Streams 의 핵심 개념

  • Akka Streams 는 bounded buffer space 를 사용해서 sequence of elements 를 처리하고, 전송하기 위한 library 이다. 이 bounded buffer space 를 사용하는 속성은 우리가 boundedness 라고 부르는 것이다.
  • 그리고 이것은 Akka Streams 의 특징을 정의하고 있다.
  • entity 들을 처리하는 것의 chain 을 표현하는 것이 가능하다.(graphs)
  • 이 각각의 entity 들은 각각 독립적으로 수행된다. 그리고 동시에 수행 가능하다.
  • 반면에 특정시간에 단순히 제한된 elements의 수를 buffering 한다.
    • bounded buffer 들의 이 속성은 actor model 과의 다른점 중 하나이다.
  • 일반적으로 각각의 actor 는 unbounded mailbox 나 bouned 지만 dropping mailbox 를 가지고 있다.
  • Akka Streams processing entity들은 drop 을 하지 않는 bounded mailbox 들을 가지고 있다.

Stream

  • data를 움직이고, 전송하는 active process

Element

  • stream 의 processing unit
  • 모든 operation들은 elements의 모습을 변경하거나 upstream 에서 downstream 으로 전송한다.
  • Buffer 사이즈들은 언제나 elements의 수로서 표현된다. elements의 실제 사이즈와 상관없이

Back-pressure

  • flow-control 의 방법
    • flow-control :consumer 가 그들의 현재 availability 를 producer 에게 알리는 방법
  • 효과적으로 the upstream producer 를 slowing down 한다. 그래서 consumption speed 들을 맞춘다.
  • Akka Streams 의 context 에서 back-pressure는 언제나 non-blocking 과 비동기로 이해되어진다.

Graph

  • 그래프는 pathway 들을 정의해서 stream processing topology 를 설명한다.
  • stream 이 실행되고 있을 때, 이 그래프를 통해서 elemnt 들은 flow 해야 한다.

Operator

streams 을 정의하고, 실행하는 것

linear processing pipeline 은 Akka Streams 에서 다음과 같은 core concept 을 사용해서 표현되어질 수 있다.

Source

  • 하나의 output 을 갖는 operator 이다.
  • downstream operator 들이 data elements을 receive 할 준비가 되면 항상 data elements 를 방출한다.

Sink

  • 하나의 input 을 갖는 operator 이다.
  • data elements를 request 하고, accept 하는
  • element 들의 upstream producer 를 slowing down 하는 것이 가능하다.

Flow

  • 하나의 input 과 output 을 갖는 operator이다.
  • Flow 는 그것으로 흘러 가는 data elements 를 transforming 하는 것에 의해 upstream 과 downstream 을 연결한다.

RunnableGraph

양쪽 끝이 각각 Source 와 Sink 에 attached 된 Flow 은 run() 할 수 있는 상태이다.

Flow 를 Source 에 붙여서 composite source 를 만드는 것이 가능하고, Sink 에 Flow 를 prepend 해서 새로운 sink 를 만드는 것도 가능하다.

stream 이 적절하게 양쪽에 source 와 sink 를 갖고 만들어지면, 이것은 RunnableGraph type 에 의해 표현된다. 그리고 이것은 실행될 수 있는 상태라는 것을 가리키는 것이다.

RunnableGraph 를 만들고 나서 모든 source, sink, 다른 operator 들을 연결하는 것에 의해서 RunnableGraph를 만들고 난 이후에도 이것이 materialized 되기 전까지는 data 가 들어오지 않는다. Materialization 은 Graph 에 의해 설명된 계산을 실행하기 위해 필요한 모든 리소스들을 할당하는 절차이다.


사용 예시

아래처럼 source -- flow ---> sink 를 연결한다.

// Explicitly creating and wiring up a Source, Sink and Flow
Source(1 to 6).via(Flow[Int].map(_ * 2)).to(Sink.foreach(println(_)))

아래처럼 Flow 가 생략될 수도 있다.

// Starting from a Source
val source = Source(1 to 6).map(_ * 2)
source.to(Sink.foreach(println(_)))