쿠버네티스 핸즈온 환경 만들기

· Vagrant, k3d

CNI 개념과 여러 종류의 CNI를 공부하면서 직접 실습해볼 필요성을 느꼈다. KANS 스터디 관련 블로그 글들을 보면서 핸즈온의 욕구가 샘솟아서 Vagrant로 로컬에서 실습을 해보려고 했는데, 세팅 작업부터 난관을 맞이했다.

Vagrant가 Silicon Mac에서 제대로 동작하지 않아..?

Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 50022 is already in use
on the host machine.

To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

  config.vm.network :forwarded_port, guest: 24, host: 1234

Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding. You could
try 'vagrant reload' (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.

처음에는 내가 포트를 잘못 설정해준 줄 알았다. 그런데 내 Vagrantfile에는 오류에 나오는 50022 포트에 관한 내용이 없다.

master.vm.network :forwarded_port, guest: 22, host:19000, id: "ssh", auto_correct: true

이게 내 컨트롤플레인 노드 VM 관련 설정이였다. 애초에 50022 포트로 설정한 적도 없었다. 열심히 검색을 하다 레딧에서 나와 같은 문제를 겪는 사람을 발견했다.

레딧 글 - Vagrant help

댓글의 답변을 살펴보던 중 다음과 같은 댓글을 발견했다.

Personal suggestion is to avoid using Vagrant, it is quite abandoned (I used to use it for many years), especially on M1. You can try k3d, it will bring up a cluster on your laptop quickly, with the amount of nodes that you prefer.

Vagrant는 Silicon Mac을 제대로 지원하지 않는다는 내용이였다. 이 댓글 외에도 M1에서는 안될 수도 있다는 댓글이 몇 개 더 있는 것으로 보아 Vagrant와 Silicon Mac 간의 호환성 문제가 있는 것 같았다.

아직 시작도 못한 내 핸즈온… 레딧 댓글을 살펴보니 CKA 관련 쿠버네티스 실습을 할 생각이면 k3d도 좋다는 댓글이 달려 있었다. 레딧 글쓴이가 CKA 공부를 하고 있다는 내용을 보고 댓글을 달아준 것 같았다. 나의 경우 CKA 공부가 목적은 아니였지만 쿠버네티스 공부라는 점에 일맥상통하니 k3d를 살펴보기로 했다.

k3d, 너 CNI 핸즈온도 할 수 있어?

k3d를 살펴보면서 네트워크 인터페이스의 구성 형태를 가장 관심 깊게 찾아보았다. 도커 위에서 컨테이너 형태로 가상의 노드를 만드는 구조라고 이해했는데, 그렇다면 네트워크 인터페이스는 어떻게 구성되는 것인지 궁금했다. 난 Calico의 VXLAN, IP in IP, Direct까지 모든 모드를 써보고 싶었기 때문이다.