업무로 kubeflow를 활용하는 것으로 결정하면서 이에 대한 파악이 필요했고 일단 간단하게 설치해 사용해 보는 것이 필요했다. 일반적으로 kubeflow를 설치하는 것은 복잡하고 쉽지않다. 상용수준의 아키텍쳐를 잡고 구축하는 것은 어려울 수 있으나, 맛보기를 위해 그렇게 복잡한 설치는 필요없으므로 최대한 단순한 설치를 알아보고 이를 통해 kubeflow를 사용해 보도록 하자.
앞에서 밝힌 것처럼 본 페이지에서는 kubeflow의 경험을 위한 간단한 설치 및 사용을 소개한다. 공식 페이지(https://www.kubeflow.org/docs/started/installing-kubeflow/)를 보면 다양한 배포본과 설치방법을 제시하고 있으나 취지에 맞게 가장 간단하게 MicroK8s를 사용한 배포를 진행하겠다.
이 페이지를 따라하기 위해서는 단순하게 vm이든 장비든 최소요구사항을 만족하는 리눅스 서버가 있으면 된다.
MicroK8s 설치
sudo snap install microk8s --classic --channel=1.21/stable
계정에 MicroK8s에 접근할 권한 설정
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
MicroK8s 실행상태 확인
siim@u20-dev:~$ microk8s status --wait-ready
microk8s is running
high-availability: no
datastore master nodes: 127.0.0.1:19001
datastore standby nodes: none
addons:
enabled:
ha-cluster # Configure high availability on the current node
disabled:
ambassador # Ambassador API Gateway and Ingress
cilium # SDN, fast with full network policy
dashboard # The Kubernetes dashboard
dns # CoreDNS
fluentd # Elasticsearch-Fluentd-Kibana logging and monitoring
gpu # Automatic enablement of Nvidia CUDA
helm # Helm 2 - the package manager for Kubernetes
helm3 # Helm 3 - Kubernetes package manager
host-access # Allow Pods connecting to Host services smoothly
ingress # Ingress controller for external access
istio # Core Istio service mesh services
jaeger # Kubernetes Jaeger operator with its simple config
keda # Kubernetes-based Event Driven Autoscaling
knative # The Knative framework on Kubernetes.
kubeflow # Kubeflow for easy ML deployments
linkerd # Linkerd is a service mesh for Kubernetes and other frameworks
metallb # Loadbalancer for your Kubernetes cluster
metrics-server # K8s Metrics Server for API access to service metrics
multus # Multus CNI enables attaching multiple network interfaces to pods
openebs # OpenEBS is the open-source storage solution for Kubernetes
openfaas # openfaas serverless framework
portainer # Portainer UI for your Kubernetes cluster
prometheus # Prometheus operator for monitoring and logging
rbac # Role-Based Access Control for authorisation
registry # Private image registry exposed on localhost:32000
storage # Storage class; allocates storage from host directory
traefik # traefik Ingress controller for external access
(참고) 이 단계에서는 microk8s를 통해 생성된 클러스터에 접근할 수 있다. kubectl 대신 microk8s.kubectl 명령을 사용하자.
siim@u20-dev:~$ microk8s.kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 17h
siim@u20-dev:~$ microk8s.kubectl get all -n kube-system
NAME READY STATUS RESTARTS AGE
pod/hostpath-provisioner-5c65fbdb4f-rsphl 1/1 Running 0 18h
pod/coredns-7f9c69c78c-dc2dq 1/1 Running 0 18h
pod/calico-kube-controllers-f7868dd95-ksrsd 1/1 Running 1 19h
pod/calico-node-hbjmq 1/1 Running 1 19h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kube-dns ClusterIP 10.152.183.10 <none> 53/UDP,53/TCP,9153/TCP 18h
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 19h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/calico-kube-controllers 1/1 1 1 19h
deployment.apps/coredns 1/1 1 1 18h
deployment.apps/hostpath-provisioner 1/1 1 1 18h
NAME DESIRED CURRENT READY AGE
replicaset.apps/calico-kube-controllers-f7868dd95 1 1 1 19h
replicaset.apps/coredns-7f9c69c78c 1 1 1 18h
replicaset.apps/hostpath-provisioner-5c65fbdb4f 1 1 1 18h
kubeflow 배포
siim@u20-dev:~$ date;microk8s enable kubeflow --bundle=cs:kubeflow;date
Wed Jan 12 02:32:49 UTC 2022
Enabling dns...
Enabling storage...
Enabling ingress...
Enabling metallb:10.64.140.43-10.64.140.49...
Waiting for other addons to finish initializing...
Addon setup complete. Checking connectivity...
Bootstrapping...
Bootstrap complete.
Successfully bootstrapped, deploying...
Kubeflow deployed.
Waiting for operator pods to become ready.
Waited 0s for operator pods to come up, 5 remaining.
Waited 15s for operator pods to come up, 6 remaining.
Waited 30s for operator pods to come up, 7 remaining.
Waited 45s for operator pods to come up, 8 remaining.
Waited 60s for operator pods to come up, 6 remaining.
Waited 75s for operator pods to come up, 9 remaining.
Waited 90s for operator pods to come up, 9 remaining.
Waited 105s for operator pods to come up, 9 remaining.
Waited 120s for operator pods to come up, 9 remaining.
Waited 135s for operator pods to come up, 9 remaining.
Waited 150s for operator pods to come up, 9 remaining.
Waited 165s for operator pods to come up, 5 remaining.
Waited 180s for operator pods to come up, 3 remaining.
Waited 195s for operator pods to come up, 3 remaining.
Waited 210s for operator pods to come up, 3 remaining.
Waited 225s for operator pods to come up, 2 remaining.
Waited 240s for operator pods to come up, 2 remaining.
Waited 255s for operator pods to come up, 2 remaining.
Waited 270s for operator pods to come up, 2 remaining.
Waited 285s for operator pods to come up, 2 remaining.
Waited 300s for operator pods to come up, 2 remaining.
Waited 315s for operator pods to come up, 1 remaining.
Waited 330s for operator pods to come up, 1 remaining.
Waited 345s for operator pods to come up, 1 remaining.
Waited 360s for operator pods to come up, 1 remaining.
Waited 375s for operator pods to come up, 1 remaining.
Operator pods ready.
Congratulations, Kubeflow is now available.
The dashboard is available at <http://10.64.140.43.nip.io>
Username: admin
Password: VLI7JSWLZWX8HA0VI7NYORKY4FRJ2B
To see these values again, run:
microk8s juju config dex-auth static-username
microk8s juju config dex-auth static-password
To tear down Kubeflow and associated infrastructure, run:
microk8s disable kubeflow
Wed Jan 12 03:11:30 UTC 2022
microk8s enable gpu
” 명령을 통해 활성화 할수 있다.처음에 노드포트를 통해 접근하면서 문제를 만났었던 경험을 했고 아래 페이지를 통해 내용을 확인할 수 있다.
대시보드 접근은 proxy를 통해 접근하여 해결하였다.
Microk8s를 통해 배포된 kubeflow의 대시보드는 노드(kubernetes를 설치한 리눅스서버)에서 접근가능하였다. 따라서 브라우저로 설치시 고지된 주소(http://10.64.140.43.nip.io)로 접근할수 있도록 해주면 정상동작을 확인할 수 있다. 맥북에서 kubeflow로 접근하기위해 설정했던 방법을 공유하면 다음과 같다.
ssh를 사용해 브라우저가 있는 맥북과 노드간 터널을 뚫는다.
ssh -D9999 [192.168.5.125](<mailto:[email protected]>)
맥북에 proxy를 설정하여 10.64.140.43 (http://10.64.140.43.nip.io 는 dns resolve를 통해 해당 아이피로 변경됨)으로 앞에 설정한 터널을 지나도록 설정
“시스템 환경설정 → 네트워크 → 사용네트워크” 에서 고급설정
proxy에서 “SOCKS 프록시” 활성화하고 proxy로 자신의 9999포트 설정
하단에 bypass에 10.64.140.43을 proxy를 통하도록 설정, (예는 C클래스 네트워크 10.64.140/24 설정함)
이제 dashboard에 접근하면 로그인을 요구하는데 필요한 내용은 구축시 안내되어 있다. 이후 모든 컴포넌트가 잘 연결된 것을 확인할 수 있다. 로그인 이후 아래와 같은 메뉴들이 잘 연결된 것을 확인할 수 있다.