lima를 통해서 ELK를 구동하는 방법에 대해 이전에 작성한적이 있다.
해당 서비스를 잘 사용하고 있었는데, 이슈가 하나 발생하였다.
"MySQL, MariaDB가 구동된 이후, Localhost:3306으로 연결이 되질 않는다."
처음에는 설정의 문제인듯 하여 정말 여러 버전을 설치하고, 직접 CentOS에 MySQL을 설치하여 연결도 해보았지만, 연결이 되질 않았다. 결국 Docker-Desktop을 통해 설치하여 문제가 발생하지 않는것을 확인하였고, Lima의 문제인것을 깨달았다.
Http 통신은 문제가 없었는데, TCP/IP로 통신하는 것이 문제인듯하다. 바인딩이 제대로 이뤄지지 않는다.
다른 여러 삽질의 방식이나, 다른 옵션들에 대한 설명은 필요없을듯하고, 가장 중요한 부분만을 설명해보도록 한다.
containerd
는 컨테이너 런타임과 관련된 여러 기능을 제공하는 데몬입니다. containerd의 system과 user 모드는 해당 데몬이 실행되는 권한 및 환경과 관련된 옵션입니다.
system 모드는 containerd가 시스템 데몬으로 실행되는 모드
입니다. 즉, systemd나 init과 같은 시스템 서비스로 등록되어 시스템 부팅시 자동으로 시작됩니다. 이 모드에서 containerd는 루트 권한으로 실행
되며, 시스템 전역에서 모든 컨테이너를 관리합니다. 이 모드에서는 시스템 레벨에서의 설정 변경이 가능하며, 다른 사용자가 containerd에 접근할 수 있습니다.
user 모드는 사용자 수준에서 containerd를 실행하는 모드
입니다. 이 모드에서는 containerd가 특정 사용자 계정으로 실행되며, 해당 계정에만 속한 컨테이너를 관리합니다. 또한 이 모드에서는 시스템 전역에서 설정 변경이 불가능하며, 해당 사용자가 설정 변경 및 컨테이너 관리 권한을 갖습니다.
따라서, system 모드는 시스템 전역에서 모든 컨테이너를 관리하고, user 모드는 특정 사용자 계정에 속한 컨테이너를 관리하는데 사용됩니다. 이러한 모드는 containerd를 사용하는 환경에 따라 선택할 수 있으며, 보안 및 관리 측면에서 필요에 따라 선택할 수 있습니다.
사실 해당 옵션에 대한 설명만을 들으면 무슨 소린지 모른다. system, user가 각각 true, false로 값을 지정할 수 있는데, 이때 지정된 옵션에 따라 컨테이너의 동작 방식이 변경된다. 처음 ELK를 구축하기 위해서는 docker로 기동하였으며, 직접적으로 Localhost와 통신하기 위해서는 Nerdctl을 이용한 구동방식이 되어야 한다.
limactl은 호스트 시스템의 containerd 데몬을 사용하여 컨테이너를 실행합니다. 이 경우, containerd 설정은 limactl에서 관리되지 않습니다.
limactl은 가상 머신 내부에서 containerd 데몬을 실행합니다. 이 경우, lima 설정 파일에서 containerd 옵션에 따라 containerd 데몬이 구성됩니다.
limactl을 사용하여 containerd의 user 모드로 lima 가상 머신을 실행하면 nerdctl이 자동으로 설치
됩니다. 이는 limactl이 containerd-shim-runsc-v1을 사용하여 컨테이너를 실행하기 때문입니다.
따라서, limactl을 사용하여 containerd의 user 모드로 lima 가상 머신을 실행하면 nerdctl을 사용하여 컨테이너를 관리
할 수 있습니다.
limactl은 호스트 시스템의 docker 데몬을 사용하여 컨테이너를 실행합니다. 이 경우, limactl에서 containerd 설정은 무시됩니다.
containerd:
system: false
user: true
mounts:
- location: "/Users/liam/data"
writable: true
limactl start nerdctl.yml
INFO[0027] [hostagent] Mounting "/Users/liam/data" on "/Users/liam/data"
INFO[0027] [hostagent] Waiting for the optional requirement 1 of 2: "systemd must be available"
INFO[0027] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/Users/liam/.lima/nerdctl/ga.sock" (host)
INFO[0027] [hostagent] The optional requirement 1 of 2 is satisfied
INFO[0027] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed"
INFO[0027] [hostagent] Not forwarding TCP 127.0.0.53:53
INFO[0027] [hostagent] The optional requirement 2 of 2 is satisfied
INFO[0027] [hostagent] Not forwarding TCP 0.0.0.0:22
INFO[0027] [hostagent] Forwarding TCP from [::]:8080 to 127.0.0.1:8080
INFO[0027] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished"
INFO[0027] [hostagent] Not forwarding TCP [::]:22
INFO[0027] [hostagent] Forwarding TCP from [::]:3306 to 127.0.0.1:3306
INFO[0028] [hostagent] The final requirement 1 of 1 is satisfied
INFO[0028] READY. Run `limactl shell nerdctl` to open the shell.
version: '3.1'
services:
mysql8:
image: mysql
ports:
- 3306:3306
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
limactl shell nerdctl nerdctl compose -f /Users/liam/Downloads/mysql/docker-compose.yml up
➜ mysql limactl shell nerdctl nerdctl compose -f /Users/liam/Downloads/mysql/docker-compose.yml up
WARN[0000] found 1 orphaned containers: [0x40006122a0], you can run this command with the --remove-orphans flag to clean it up
INFO[0000] Ensuring image mysql
INFO[0000] Re-creating container mysql_mysql8_1
INFO[0000] Attaching to logs
mysql8_1 |2023-04-09 23:49:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
mysql8_1 |2023-04-09 23:49:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql8_1 |2023-04-09 23:49:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
mysql8_1 |2023-04-09 23:49:08+00:00 [Note] [Entrypoint]: Initializing database files