Kubeflow 실습 환경 구성

 

Kubeflow 실습 환경 구성 (Window)


Docker Desktop 설정

Docker Desktop 설치

  • 다운 받아서 설치
  • 리소스 설정 (사용자 home에 .wslconfig 파일에 다음 내용을 추가)
[wsl2] memory=16GB processors=8 swap=4GB networkingMode=mirrored

작업용 ubuntu wsl 설치

  • Kubeflow 설치 및 클러스터 관리를 위한 리눅스 환경을 별도로 생성
wsl --install -d Ubuntu
  • 설치 후 사용자와 패스워드를 등록

점검

  • wsl -d Ubuntu로 접속하여 설정한 자원의 크기대로 이미지가 생성 되었는지 확인
# 메모리 확인 free -h # CPU 확인 nproc

wsl integration 설정

  • Docker Desktop에서 신규로 생성한 Ubuntu wsl을 활성화
  • Ubuntu를 체크하고 apply and restart
notion image
 

필수 도구 설치

  • Kubeflow 설치와 구성을 위한 필수 SW를 설치
  • 모든 작업은 Ubuntu wsl 환경에 접속해서 수행

kubectl 설치

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl rm -rf ./kubectl kubectl version

kind 설치

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 chmod +x ./kind sudo mv ./kind /usr/local/bin/kind kind --version

kustomize 설치

curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash sudo mv kustomize /usr/local/bin/kustomize kustomize version
 

k8s 클러스터 생성

  • kind 명령을 이용해서 k8s 클러스터를 생성

클러스터 설정 파일 생성

  • 1개의 control-plane과 2개의 worker로 구성(생성 후에 worker 노드 증가가 가능할지는 테스트 필요)
  • kind-config.yaml 파일에 아래와 같이 입력
kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane image: kindest/node:v1.32.11 - role: worker image: kindest/node:v1.32.11 - role: worker image: kindest/node:v1.32.11 - role: worker image: kindest/node:v1.32.11

클러스터 생성

kind create cluster --name kubeflow --config kind-config.yaml

Context 변경

  • kube-config에 다른 클러스터의 인증정보가 있었다면 다음 절차를 통해 신규로 구성된 kubeflow 클러스터로 context를 변경
kubectl config get-contexts kubectl config use-context kind-kubeflow kubectl get nodes
 

Kubeflow 설치

Kubeflow manifests clone

  • 기존 디렉토리가 있으면 삭제 후 manifests를 clone
  • branch를 1.10 버전으로 변경
rm -rf manifests git clone https://github.com/kubeflow/manifests.git cd manifests git checkout v1.10-branch

설치

  • 다음 명령으로 반복 수행, server-side 옵션 필수
while ! kustomize build example | kubectl apply --server-side --force-conflicts -f -; do sleep 30 done
  • 설치를 시작한 후 다른 wsl 창에서 모든 pod가 Running 상태가 되는지 확인
watch "kubectl get pods -A | grep -v 'Running'"

접속확인

  • 포트 포워딩 설정
kubectl port-forward svc/istio-ingressgateway -n istio-system 8080:80
  • 로그인 정보: user-example-com / 12341234
❗ 접속할 때 크롬의 시크릿 모드를 이용해서 인증정보가 중복되지 않도록 한다.
 

프로파일 및 namespace 생성

  • 다음 명령을 통해 사용자 프로파일과 네임스페이스를 생성
cat <<EOF > user-profile.yaml apiVersion: kubeflow.org/v1 kind: Profile metadata: name: user-example-com spec: owner: kind: User name: user@example.com EOF kubectl apply -f user-profile.yaml
  • 다음 명령을 통해 정상 반영되었는지 확인
# 1. 프로필 리소스 상태 확인 kubectl get profiles # 2. 자동으로 생성된 네임스페이스 확인 (user-example-com 이라는 이름으로 생성됨) kubectl get namespaces | grep user-example-com
  • 브라우저를 리로드 하여 profile 선택
 

기능 점검

노트북 생성

  • 우측 메뉴의 Notebook 선택 → notebook 이름을 my-first-notebook으로 입력하고 launch 버튼 클릭
  • kubectl get pod -A | grep my-first-notebook으로 검색하여 pod가 정상적으로 실행되는 지 점검
  • pod가 Running 상태가 되면 화면의 상태도 running으로 바뀌고 접속 가능한 상태가 됨

파일 생성 및 저장

  • test1.ipynb 파일을 생성하여 실행하고 저장
import numpy as np import time # 대규모 행렬 연산 테스트 (메모리 및 CPU 부하 확인) print("Starting matrix multiplication test...") start_time = time.time() size = 2000 a = np.random.rand(size, size) b = np.random.rand(size, size) c = np.dot(a, b) end_time = time.time() print(f"Matrix size: {size}x{size}") print(f"Elapsed time: {end_time - start_time:.4f} seconds")
  • terminal에서 txt 파일 생성
echo "Kubeflow Persistence Test - $(date)" > storage_test.txt ls -l storage_test.txt

Pod 재시작 후 파일 유지 여부 확인

  • Pod를 종료하고 다시 시작하여 생성한 파일이 존재하는지 확인

Pipeline 실행