Skip to main content
본 가이드에서는 k3s를 통해 Kubernetes 클러스터를 구성하였으며, kubeadm, kubespray 등 다른 방식으로 구성된 클러스터 환경에서도 ale을 사용할 수 있습니다.

k3s 구성 및 agent 설치

1

EC2에 SSH 접속 후 다음의 명령어를 실행하여 k3s를 설치합니다.

curl -sfL https://get.k3s.io | sh -s - server \
  --bind-address=0.0.0.0 \
  --advertise-address=[EC2의 Public IP 주소] \
  --tls-san=[EC2의 Public IP 주소] \
  --node-external-ip=[EC2의 Public IP 주소] \
  --disable=traefik \
  --docker
2

kubectl을 루트 권한이 아닌 사용자로 사용하려는 경우 다음의 명령어를 실행합니다.

mkdir -p ~/.kube && \
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config && \
sudo chown $(whoami):$(whoami) ~/.kube/config && \
chmod 600 ~/.kube/config && \
echo "export KUBECONFIG=~/.kube/config" >> ~/.bashrc && \
exec -l $SHELL
3

다음의 명령어를 입력하여 클러스터가 정상적으로 동작하는지 확인합니다.

kubectl get nodes
# STATUS가 Ready인지 확인
NAME              STATUS   ROLES                  AGE     VERSION
ip-172-31-14-74   Ready    control-plane,master   6d21h   v1.31.3+k3s1
4

다음의 명령어로 ale agent를 설치하세요.

kubectl apply -f https://raw.githubusercontent.com/ale-run/ale/refs/heads/main/k8s/dist/latest/agent.yaml

Kubernetes Metrics Server

가이드에 따라 설치한 K3s에는 Metrics Server가 내장되어 있기 때문에 설치할 필요가 없습니다. 미설치 클러스터인 경우 아래의 명령어를 확인하고 Metrics Server를 설치하세요.
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
다음의 명령어로 Metrics Server를 통해 사용 중인 리소스가 정상적으로 표시되는지 확인하세요.
kubectl top nodes

Nginx Ingress Controller

1

다음의 명령어를 실행하여 Nginx Ingress Controller를 설치하세요.

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx \
  --version 4.11.2 \
  --namespace ingress-nginx --create-namespace \
  --set controller.service.type=LoadBalancer \
  --set controller.allowSnippetAnnotations=true \
  --set controller.admissionWebhooks.enabled=false
2

다음의 명령어를 실행하여 Kubernetes service의 External IP가 실제 EC2에 연결된 Elastic IP와 일치하는지 확인합니다.

kubectl get svc -n ingress-nginx
NAME                       TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                      AGE
ingress-nginx-controller   LoadBalancer   10.43.158.249   [외부 IP]        80:32119/TCP,443:31694/TCP   6d21h

ale 설치 및 실행

1

다음의 명령어를 입력하여 ale-run 패키지를 설치하세요

mkdir ale-run
cd ale-run
npm i @ale-run/runtime@latest
2

다음의 명령어를 입력하여 ale을 운영 모드로 실행합니다.

pm2 start "npx aled run -c [Kubernetes 클러스터명]" --name "ale-run" --watch
Kubernetes 클러스터명을 별도로 지정하지 않은 경우, 일반적으로 default 라는 이름으로 생성되며, kubectl config current-context 명령어로 조회할 수 있습니다.
3

pm2에서 조회한 로그가 다음과 같이 표시되면 실행이 완료된 것입니다.

pm2 log ale-run
...
[INFO] [plugin:loader] searching plugins at /home/ubuntu/ale-run/node_modules/@ale-run/runtime/dist
[INFO] [plugin:loader] 2 plugin detected in /home/ubuntu/ale-run/node_modules/@ale-run/runtime/dist
[INFO] [plugin:loader] plugin @ale-run/plugin-essentials has been added
[INFO] [plugin:loader] plugin @ale-run/plugin-file-store has been added
[INFO] [plugin:loader] searching plugins at /home/ubuntu/ale-run/node_modules
[INFO] [plugin:loader] 1 plugin detected in /home/ubuntu/ale-run/node_modules
[INFO] [plugin:loader] plugin @ale-run/plugin-ai-assistant has been added
[INFO] [plugin:essentials] plugin @ale-run/plugin-essentials is installed {}
[INFO] [plugin:essentials] plugin @ale-run/plugin-essentials is activate {}
[INFO] [plugin:file-store] plugin @ale-run/plugin-file-store is activate {}
[INFO] [plugin:file-store] working dir is /home/ubuntu/.ale
[INFO] [plugin:file-store] storage type is direct
[INFO] [plugin:file-store] upload dir is /home/ubuntu/.ale/files
[INFO] [plugin:file-store] temp dir is /home/ubuntu/.ale/temp
[INFO] [plugin:file-store] endpoint is (none)
[INFO] [plugin:file-store] max file size is 10MB
[INFO] [plugin:ai-assistant] plugin @ale-run/plugin-ai-assistant is activate {}
[WARN] [plugin] [@ale-run/plugin-ai-assistant] activate failed: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).
[INFO] [runtime:init] api server listening on 0.0.0.0:9009
실행 중 데이터베이스 충돌이 발생하거나 설정을 초기화 하려는 경우, 다음의 명령을 입력하여 기존에 생성된 ale 데이터를 삭제 후 재실행하세요.
rm -r ~/.ale 
I