Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 4개 있습니다.)
개발 환경 구성: 557. Docker Desktop for Windows에서 DockerDesktopVM 기반의 Kubernetes 구성
; https://www.sysnet.pe.kr/2/0/12575

개발 환경 구성: 558. Docker Desktop for Windows에서 DockerDesktopVM 기반의 Kubernetes 구성 (2) - k8s 서비스 위치
; https://www.sysnet.pe.kr/2/0/12576

개발 환경 구성: 559. Docker Desktop for Windows 기반의 Kubernetes 구성 - WSL 2 인스턴스에 kind 도구로 k8s 클러스터 구성
; https://www.sysnet.pe.kr/2/0/12577

개발 환경 구성: 560. Docker Desktop for Windows 기반의 Kubernetes 구성 (2) - WSL 2 인스턴스에 kind가 구성한 k8s 서비스 위치
; https://www.sysnet.pe.kr/2/0/12578




Docker Desktop for Windows에서 DockerDesktopVM 기반의 Kubernetes 구성 (2) - k8s 서비스 위치

지난 글에서 설명한 환경에서는,

Docker Desktop for Windows에서 DockerDesktopVM 기반의 Kubernetes 구성
; https://www.sysnet.pe.kr/2/0/12575

Docker Desktop for Windows의 경우 실질적인 docker 서비스는 Hyper-V의 DockerDesktopVM에 설치됩니다. 그리고 당연히 k8s도 DockerDesktopVM에 설치됩니다. 이것을 한 번 확인해 볼까요? ^^

이를 위해 다음의 글에 설명한,

DockerDesktopVM의 파일 시스템 접근
; https://www.sysnet.pe.kr/2/0/12174

방법으로 alpine container를 실행시키면 DockerDesktopVM에 어떤 식으로 k8s가 구성되었는지 파헤쳐 볼 수 있습니다.

c:\temp> docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
/ #

일례로, docker 및 k8s의 여러 서비스들(예: kube-apiserver)이 다음과 같이 DockerDesktopVM 내에 프로세스로 실행 중임을 알 수 있고,

/ # ps aux | grep docker
 1015 root      0:06 /usr/bin/containerd-shim-runc-v2 -namespace services.linuxkit -id docker -address /run/containerd/containerd.sock
 1037 root      0:03 /usr/bin/docker-init /usr/bin/entrypoint.sh
 1361 root      0:00 /usr/bin/trim-after-delete -- /sbin/fstrim /var/lib/docker
 1443 root      0:54 /usr/bin/logwrite -n dockerd /usr/local/bin/dockerd --containerd /var/run/desktop-containerd/containerd.sock --pidfile /run/desktop/docker.pid --config-file /run/config/docker/daemon.json --swarm-default-advertise-addr=eth0 --host-gateway-ip 192.168.65.1
 1449 root     46:39 /usr/local/bin/dockerd --containerd /var/run/desktop-containerd/containerd.sock --pidfile /run/desktop/docker.pid --config-file /run/config/docker/daemon.json --swarm-default-advertise-addr=eth0 --host-gateway-ip 192.168.65.1
 1985 root      1h54 ...[생략]...
 3522 root      1h02 etcd --advertise-client-urls=https://192.168.65.3:2379 --cert-file=/run/config/pki/etcd/server.crt --client-cert-auth=true --data-dir=/var/lib/etcd --initial-advertise-peer-urls=https://192.168.65.3:2380 --initial-cluster=docker-desktop=https://192.168.65.3:2380 --key-file=/run/config/pki/etcd/server.key --listen-client-urls=https://127.0.0.1:2379,https://192.168.65.3:2379 --listen-metrics-urls=http://127.0.0.1:2381 --listen-peer-urls=https://192.168.65.3:2380 --name=docker-desktop --peer-cert-file=/run/config/pki/etcd/peer.crt --peer-client-cert-auth=true --peer-key-file=/run/config/pki/etcd/peer.key --peer-trusted-ca-file=/run/config/pki/etcd/ca.crt --snapshot-count=10000 --trusted-ca-file=/run/config/pki/etcd/ca.crt
 4934 root      0:28 ...[생략]...
29844 root      0:00 ...[생략]...

/ # ps aux | grep kube
 1981 root      0:00 /usr/bin/logwrite -n kubelet /usr/bin/kubelet.sh
 1985 root      1h49 kubelet --kubeconfig=/etc/kubernetes/kubelet.conf --config /etc/kubeadm/kubelet.yaml --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/var/lib/cni-plugins/bin --kube-reserved-cgroup=podruntime --system-reserved-cgroup=systemreserved --cgroup-root=kubepods --hostname-override=docker-desktop
 3477 root      1h37 kube-apiserver --advertise-address=192.168.65.3 --allow-privileged=true --authorization-mode=Node,RBAC --client-ca-file=/run/config/pki/ca.crt --enable-admission-plugins=NodeRestriction --enable-bootstrap-token-auth=true --etcd-cafile=/run/config/pki/etcd/ca.crt --etcd-certfile=/run/config/pki/apiserver-etcd-client.crt --etcd-keyfile=/run/config/pki/apiserver-etcd-client.key --etcd-servers=https://127.0.0.1:2379 --insecure-port=0 --kubelet-client-certificate=/run/config/pki/apiserver-kubelet-client.crt --kubelet-client-key=/run/config/pki/apiserver-kubelet-client.key --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname --proxy-client-cert-file=/run/config/pki/front-proxy-client.crt --proxy-client-key-file=/run/config/pki/front-proxy-client.key --requestheader-allowed-names=front-proxy-client --requestheader-client-ca-file=/run/config/pki/front-proxy-ca.crt --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-group-headers=X-Remote-Group --requestheader-username-headers=X-Remote-User --secure-port=6443 --service-account-key-file=/run/config/pki/sa.pub --service-cluster-ip-range=10.96.0.0/12 --tls-cert-file=/run/config/pki/apiserver.crt --tls-private-key-file=/run/config/pki/apiserver.key --watch-cache=false
 4934 root      0:26 /usr/local/bin/kube-proxy --config=/var/lib/kube-proxy/config.conf --hostname-override=docker-desktop
 5019 root      0:26 /kube-vpnkit-forwarder -path /run/host-services/backend.sock
 5336 root     54:46 kube-controller-manager --authentication-kubeconfig=/etc/kubernetes/controller-manager.conf --authorization-kubeconfig=/etc/kubernetes/controller-manager.conf --bind-address=127.0.0.1 --client-ca-file=/run/config/pki/ca.crt --cluster-name=kubernetes --cluster-signing-cert-file=/run/config/pki/ca.crt --cluster-signing-key-file=/run/config/pki/ca.key --controllers=*,bootstrapsigner,tokencleaner --horizontal-pod-autoscaler-sync-period=60s --kubeconfig=/etc/kubernetes/controller-manager.conf --leader-elect=false --node-monitor-grace-period=180s --node-monitor-period=30s --port=0 --pvclaimbinder-sync-period=60s --requestheader-client-ca-file=/run/config/pki/front-proxy-ca.crt --root-ca-file=/run/config/pki/ca.crt --service-account-private-key-file=/run/config/pki/sa.key --use-service-account-credentials=true
 5595 1001      1:47 /dashboard --insecure-bind-address=0.0.0.0 --bind-address=0.0.0.0 --auto-generate-certificates --namespace=kubernetes-dashboard
25659 root      0:40 kube-scheduler --authentication-kubeconfig=/etc/kubernetes/scheduler.conf --authorization-kubeconfig=/etc/kubernetes/scheduler.conf --bind-address=127.0.0.1 --kubeconfig=/etc/kubernetes/scheduler.conf --leader-elect=true --port=0
80497 root      0:00 ...[생략]...

/*
pstree -p | grep kube
*/

이에 따라 열려 있는 포트들도,

Installing kubeadm - Check required ports
; https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#check-required-ports

프로세스 별로 확인이 됩니다.

/ # netstat -atp | grep LISTEN
tcp        0      0 localhost:10248         0.0.0.0:*               LISTEN      1985/kubelet
tcp        0      0 localhost:10249         0.0.0.0:*               LISTEN      4934/kube-proxy
tcp        0      0 192.168.65.3:2379       0.0.0.0:*               LISTEN      3522/etcd
tcp        0      0 localhost:2379          0.0.0.0:*               LISTEN      3522/etcd
tcp        0      0 192.168.65.3:2380       0.0.0.0:*               LISTEN      3522/etcd
tcp        0      0 localhost:2381          0.0.0.0:*               LISTEN      3522/etcd
tcp        0      0 localhost:59117         0.0.0.0:*               LISTEN      1985/kubelet
...[생략]...
tcp        0      0 localhost:10257         0.0.0.0:*               LISTEN      5336/kube-controlle
tcp        0      0 localhost:10259         0.0.0.0:*               LISTEN      25659/kube-schedule
...[생략]...
tcp        0      0 :::10250                :::*                    LISTEN      1985/kubelet
tcp        0      0 :::6443                 :::*                    LISTEN      3477/kube-apiserver
...[생략]...
tcp        0      0 :::10256                :::*                    LISTEN      4934/kube-proxy

나아가서 명령행 인자를 통해 kubernetes의 바이너리와,

/ # ls /host/usr/bin/kube* -l
-rwxr-xr-x    1 root     root           959 Mar 16 08:56 /host/usr/bin/kube-pull.sh
-rwxr-xr-x    1 root     root           508 Mar 16 08:56 /host/usr/bin/kube-reset.sh
-rwxr-xr-x    1 root     root           106 Mar 16 08:56 /host/usr/bin/kube-restart.sh
-rwxr-xr-x    1 root     root           198 Mar 16 08:56 /host/usr/bin/kube-start.sh
-rwxr-xr-x    1 root     root           685 Mar 16 08:56 /host/usr/bin/kube-stop.sh
lrwxrwxrwx    1 root     root            41 Mar 20 00:19 /host/usr/bin/kubeadm -> /var/lib/kube-binary-cache-debian/kubeadm
-rwxr-xr-x    1 root     root           710 Mar 16 08:56 /host/usr/bin/kubeadm-init.sh
lrwxrwxrwx    1 root     root            41 Mar 20 00:19 /host/usr/bin/kubectl -> /var/lib/kube-binary-cache-debian/kubectl
lrwxrwxrwx    1 root     root            41 Mar 20 00:19 /host/usr/bin/kubelet -> /var/lib/kube-binary-cache-debian/kubelet
-rwxr-xr-x    1 root     root          2408 Mar 16 08:56 /host/usr/bin/kubelet.sh

인증서 목록까지 확인할 수 있습니다.

/ # ls /host/run/config/pki -l
total 56
-rw-r--r--    1 root     root          1090 Mar 20 09:19 apiserver-etcd-client.crt
-rw-r--r--    1 root     root          1675 Mar 20 09:19 apiserver-etcd-client.key
-rw-r--r--    1 root     root          1099 Mar 20 09:19 apiserver-kubelet-client.crt
-rw-r--r--    1 root     root          1679 Mar 20 09:19 apiserver-kubelet-client.key
-rw-r--r--    1 root     root          1334 Mar 20 09:19 apiserver.crt
-rw-r--r--    1 root     root          1675 Mar 20 09:19 apiserver.key
-rw-r--r--    1 root     root          1025 Mar 20 09:19 ca.crt
-rw-r--r--    1 root     root          1679 Mar 20 09:19 ca.key
drwxr-xr-x    2 root     root           200 Mar 20 09:19 etcd
-rw-r--r--    1 root     root          1038 Mar 20 09:19 front-proxy-ca.crt
-rw-r--r--    1 root     root          1679 Mar 20 09:19 front-proxy-ca.key
-rw-r--r--    1 root     root          1058 Mar 20 09:19 front-proxy-client.crt
-rw-r--r--    1 root     root          1679 Mar 20 09:19 front-proxy-client.key
-rw-r--r--    1 root     root          1679 Mar 20 09:19 sa.key
-rw-r--r--    1 root     root           451 Mar 20 09:19 sa.pub

그리고 여기 있는 인증서들은 윈도우 호스트 측의 "%LOCALAPPDATA%\Docker\pki" 폴더 목록과 일치합니다. 실제로, 인증서 내용도 완전히 동일합니다.

/host/run/config/pki # cat ca.crt
-----BEGIN CERTIFICATE-----
MIICyDCCAbCgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl
...[생략]...
8FBcTBqYAlRJRiDWefzIy7tEPiSkOnLqtoVhBqL8WK6Xu15xzHJ5yO2yHTs=
-----END CERTIFICATE-----

C:\temp> type "%LOCALAPPDATA%\Docker\pki\ca.crt" 
-----BEGIN CERTIFICATE-----
MIICyDCCAbCgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl
...[생략]...
8FBcTBqYAlRJRiDWefzIy7tEPiSkOnLqtoVhBqL8WK6Xu15xzHJ5yO2yHTs=
-----END CERTIFICATE-----




그나저나, 정작 신기한 것은 DockerDesktopVM의 네트워크 구조입니다. Hyper-V에서 해당 VM의 설정을 보면 가상 네트워크 어댑터가 존재하지 않는데요, 정확히는 알 수 없지만 보이지 않는 것일 뿐 내부적으로는 존재하는 것으로 예상이 됩니다.

/ # ifconfig | grep "inet addr"
          inet addr:10.1.0.1  Bcast:10.1.255.255  Mask:255.255.0.0
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          inet addr:192.168.65.3  Bcast:192.168.65.15  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet addr:192.168.65.4  Bcast:0.0.0.0  Mask:255.255.255.255
/ # cat /etc/resolv.conf
# DNS requests are forwarded to the host. DHCP DNS options are ignored.
nameserver 192.168.65.5

또한, DockerDesktopVM 측에서 윈도우 호스트 측으로의 통신은 모든 Hyper-V의 Internal Network Switch(Default Switch, WSL)에 대해 (따라서 당연히 External 유형의 스위치에 대해서도) 통신이 됩니다.

/* 아래의 모든 IP를 DockerDesktopVM 측에서 ping으로 확인 가능 */

c:\temp> ipconfig | findstr IPv4
   Autoconfiguration IPv4 Address. . : 169.254.215.170
   IPv4 Address. . . . . . . . . . . : ...[공용 IP]...
   IPv4 Address. . . . . . . . . . . : 192.168.240.1
   IPv4 Address. . . . . . . . . . . : 172.19.64.1

이제서야 생각해 보면, 마이크로소프트가 DockerDesktopVM을 어쩌면 버리고 싶은 것이 아닌가 생각됩니다. 그동안의 마이크로소프트 자세를 보면, 개발자들이 가능한 이용할 수 있는 쪽으로 자료 공개를 많이 해왔던 것에 비하면 유독 DockerDesktopVM은 관련 자료가 거의 전무한 상태입니다. 어차피 WSL 2도 나왔고 docker와 k8s도 포팅을 했으니 DockerDesktopVM을 더 이상 지원하고 싶지 않아 개발자들로 하여금 그 내부에서 뭔가를 하지 않기를 바라는 듯한 느낌이 드는군요. ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 9/28/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 76  77  78  79  80  81  82  83  [84]  85  86  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
11837정성태3/6/201939811기타: 74. 도서: 시작하세요! C# 7.3 프로그래밍 [10]
11836정성태3/5/201923388오류 유형: 525. Visual Studio 2019 Preview 4/RC - C# 8.0 Missing compiler required member 'System.Range..ctor' [1]
11835정성태3/5/201921862.NET Framework: 810. C# 8.0의 Index/Range 연산자를 .NET Framework에서 사용하는 방법 및 비동기 스트림의 컴파일 방법 [3]파일 다운로드1
11834정성태3/4/201920655개발 환경 구성: 432. Visual Studio 없이 최신 C# (8.0) 컴파일러를 사용하는 방법
11833정성태3/4/201921208개발 환경 구성: 431. Visual Studio 2019 - CMake를 이용한 공유/실행(so/out) 리눅스 프로젝트 설정파일 다운로드1
11832정성태3/4/201917120오류 유형: 524. Visual Studio CMake - rsync: connection unexpectedly closed
11831정성태3/4/201916950오류 유형: 523. Visual Studio 2019 - 새 창으로 뜬 윈도우를 닫을 때 비정상 종료
11830정성태2/26/201916638오류 유형: 522. 이벤트 로그 - Error opening event log file State. Log will not be processed. Return code from OpenEventLog is 87.
11829정성태2/26/201918327개발 환경 구성: 430. 마이크로소프트의 CoreCLR 프로파일러 예제 빌드 방법 - 리눅스 환경 [1]
11828정성태2/26/201926248개발 환경 구성: 429. Component Services 관리자의 RuntimeBroker 설정이 2개 있는 경우 [8]
11827정성태2/26/201919186오류 유형: 521. Visual Studio - Could not start the 'rsync' command on the remote host, please install it using your system package manager.
11826정성태2/26/201919361오류 유형: 520. 우분투에 .NET Core SDK 설치 시 패키지 의존성 오류
11825정성태2/25/201924633개발 환경 구성: 428. Visual Studio 2019 - CMake를 이용한 리눅스 빌드 환경 설정 [1]
11824정성태2/25/201919062오류 유형: 519. The SNMP Service encountered an error while accessing the registry key SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration. [1]
11823정성태2/21/201920653오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201919031오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201919775오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201922832오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201922102Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201920188VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/201916534오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201920009Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201918252오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/201917074오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
11813정성태2/12/201918397.NET Framework: 809. C# - ("Save File Dialog" 등의) 대화 창에 확장 속성을 보이는 방법
11812정성태2/11/201915706오류 유형: 511. Windows Server 2003 VM 부팅 후 로그인 시점에 0xC0000005 BSOD 발생
... 76  77  78  79  80  81  82  83  [84]  85  86  87  88  89  90  ...