Service Account Token Volume Projection 활성화
kubeflow에서는 인증/권한 기능을 위해서 istio 를 사용합니다. 그래서 istio-system 이라는 네임스페이스에 istio 관련 컴포넌트가 설치됩니다. 그 중에 하나인 istio-ingressgateway 포드의 내용을 보면 다음과 같은 부분을 발견할 수 있습니다.
... volumes: - name: istio-token projected: defaultMode: 420 sources: - serviceAccountToken: audience: istio-ca expirationSeconds: 43200 path: istio-token ...
바로 Service Account Token Volume Projection 이라는 것입니다. 이 기능은 쿠버네티스 1.15에서 비활성화 되어 있습니다. 그래서 해당 기능을 사용하기 위해서는 활성화 해줘야 합니다.
기능을 활성화 하기 위해서는, 다음과 같이 kube-apiserver 매니페스트에 몇 가지 플래그를 추가해야합니다. 매니페스트 파일은 /etc/kubernetes/manifests/kube-apiserver.yaml
에 위치합니다.
$ sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml ... - --service-account-signing-key-file=/etc/kubernetes/pki/sa.key - --service-account-issuer=api - --service-account-api-audiences=api,vault
매니페스트 파일을 수정하고, kube-apiserver 포드가 자동으로 다시 시작됩니다.
dynamic volume provisioner 설치
kubeflow를 쉽게 설치하기 위해서는 동적 볼륨 프로비져너(dynamic volume provisioner)가 필요합니다. 이 글에는 로컬 디렉토리를 이용하는 Local Path Provisioner 를 사용하겠습니다.
다음은 Local Path Provisioner 를 설치하는 명령어입니다.
$ kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml namespace/local-path-storage created serviceaccount/local-path-provisioner-service-account created clusterrole.rbac.authorization.k8s.io/local-path-provisioner-role created clusterrolebinding.rbac.authorization.k8s.io/local-path-provisioner-bind created deployment.apps/local-path-provisioner created storageclass.storage.k8s.io/local-path created configmap/local-path-config created
스토리지 클래스(storage class)를 조회해 보겠습니다.
$ kubectl get storageclass NAME PROVISIONER AGE local-path rancher.io/local-path 63s
kubeflow는 기본 스토리지 클래스를 사용하기 때문에, local-path 스토리지 클래스를 기본 클래스로 설정해야합니다..
다음은 기본 스토리지 클래스를 설정하는 명령어입니다.
$ kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' storageclass.storage.k8s.io/local-path patched
다시 스토리지 클래스를 조회해 보면, 기본 클래스가 설정된 것을 확인할 수 있습니다.
$ kubectl get sc NAME PROVISIONER AGE local-path (default) rancher.io/local-path 11m
kubeflow 설치하기
kubeflow를 설치하기 위해서, kftctl
을 릴리즈 페이지에서 다운로드 합니다. 이 글을 쓰는 시점에서는 v1.0버전이 최신이므로, v1.0 버전을 기준으로 설명하겠습니다.
$ mkdir ~/kubeflow $ cd ~/kubeflow $ curl -L -O https://github.com/kubeflow/kfctl/releases/download/v1.0/kfctl_v1.0-0-g94c35cf_linux.tar.gz
다운 받은 tar ball 을 풉니다.
$ tar -xvf kfctl_v1.0-0-g94c35cf_linux.tar.gz
kubflow 배포를 쉽게 하기 위해서, 다음과 같은 환경 변수들을 생성합니다. 환경 변수들의 자세한 내용은 해당 페이지를 확인 하시기 바랍니다.
export PATH=$PATH:"/home/kangwoo/kubeflow" export CONFIG_URI="https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_istio_dex.v1.0.1.yaml" export KF_NAME=kf-test export BASE_DIR=/home/kangwoo/kubeflow export KF_DIR=${BASE_DIR}/${KF_NAME}
kfctl_existing_arrikto.yaml 설정 파일을 가지고, kubeflow를 배포하겠습니다. 해당 파일에는 다중 유저와 권한/인증 기능을 지원하는 부분이 정의 되어 있습니다.
mkdir -p ${KF_DIR} cd ${KF_DIR} # Download the config file and change the default login credentials. wget -O kfctl_istio_dex.yaml $CONFIG_URI export CONFIG_FILE=${KF_DIR}/kfctl_istio_dex.yaml kfctl apply -V -f ${CONFIG_FILE}
kfctl apply
명령어를 실행하면, kubeflow가 설치되기 시작합니다.
다음은 kubeflow 네임스페이스와, istio-system 네임스페이스의 포드를 조회해 본 것입니다.
$ kubectl -n kubeflow get pod NAME READY STATUS RESTARTS AGE admission-webhook-deployment-7b7888fc9b-9dlj9 1/1 Running 0 2d23h application-controller-stateful-set-0 1/1 Running 0 2d23h argo-ui-7ffb9b6577-xqcxc 1/1 Running 0 2d23h centraldashboard-6944c87dd5-sfqc7 1/1 Running 0 2d23h jupyter-web-app-deployment-679d5f5dc4-6278n 1/1 Running 0 2d23h katib-controller-7f58569f7d-62pgx 1/1 Running 1 2d23h katib-db-manager-54b66f9f9d-wsxv5 1/1 Running 5 2d23h katib-mysql-dcf7dcbd5-4fpmj 1/1 Running 0 2d23h katib-ui-6f97756598-dk8fz 1/1 Running 0 2d23h metadata-db-65fb5b695d-b92zm 1/1 Running 0 2d23h metadata-deployment-65ccddfd4c-242t7 1/1 Running 1 2d23h metadata-envoy-deployment-7754f56bff-6vftm 1/1 Running 0 2d23h metadata-grpc-deployment-7557fdc6bb-n7jd7 1/1 Running 7 2d23h metadata-ui-7c85545947-wwkh9 1/1 Running 0 2d23h minio-69b4676bb7-zglc6 1/1 Running 0 2d23h ml-pipeline-5cddb75848-tjbh9 1/1 Running 1 2d23h ml-pipeline-ml-pipeline-visualizationserver-7f6fcb68c8-pw529 1/1 Running 0 2d23h ml-pipeline-persistenceagent-6ff9fb86dc-ghj74 1/1 Running 3 2d23h ml-pipeline-scheduledworkflow-7f84b54646-mztnf 1/1 Running 0 2d23h ml-pipeline-ui-6758f58868-qc72b 1/1 Running 0 2d23h ml-pipeline-viewer-controller-deployment-745dbb444d-2xwdn 1/1 Running 0 2d23h mysql-6bcbfbb6b8-6qb6p 1/1 Running 0 2d23h notebook-controller-deployment-54f455c5c9-rpv8s 1/1 Running 0 2d23h profiles-deployment-6fcb86d54c-9pdrs 2/2 Running 0 2d23h pytorch-operator-cf8c5c497-lntsm 1/1 Running 0 2d23h seldon-controller-manager-6b4b969447-b4gcj 1/1 Running 0 2d23h spark-operatorcrd-cleanup-knfpw 0/2 Completed 0 2d23h spark-operatorsparkoperator-76dd5f5688-2689x 1/1 Running 0 2d23h spartakus-volunteer-5dc96f4447-6ss4g 1/1 Running 0 2d23h tensorboard-5f685f9d79-7d8kp 1/1 Running 0 2d23h tf-job-operator-5fb85c5fb7-vxkgv 1/1 Running 0 2d23h workflow-controller-689d6c8846-lmmdz 1/1 Running 0 2d23h
k -n istio-system get pod NAME READY STATUS RESTARTS AGE authservice-0 1/1 Running 0 2d23h istio-citadel-79b5b568b-kqjw9 1/1 Running 0 3d istio-galley-756f5f45c4-kxkhr 1/1 Running 0 3d istio-ingressgateway-77f74c944c-z5frv 1/1 Running 0 3d istio-nodeagent-478g7 1/1 Running 0 3d istio-nodeagent-rmbc5 1/1 Running 0 3d istio-nodeagent-z49bb 1/1 Running 0 3d istio-pilot-55f7f6f6df-k5mdm 2/2 Running 0 3d istio-policy-76dbd68445-vskkp 2/2 Running 0 3d istio-security-post-install-release-1.3-latest-daily-2j5tr 0/1 Completed 0 3d istio-sidecar-injector-5d9f474dcb-l5qjj 1/1 Running 0 3d istio-telemetry-697c8fd794-9hz9q 2/2 Running 0 3d prometheus-b845cc6fc-d7cq6 1/1 Running 0 3d
kubeflow 접속하기
kubeflow GUI에 접속해 보겠습니다. istio-ingressgateway 를 통해서 접속합니다. 여기서는 편의를 위해서 노드 포트(NodePort)를 사용하겠습니다.
다음은 istio-ingressgateway 서비스를 조회해 본 결과입니다.
$ kubectl -n istio-system get service istio-ingressgateway NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE istio-ingressgateway NodePort 172.30.86.239 <none> 15020:30113/TCP,80:31380/TCP,443:31390/TCP,31400:31400/TCP,15029:31134/TCP,15030:31251/TCP,15031:32398/TCP,15032:30455/TCP,15443:32764/TCP 3d
서비스 타입이 NodePort 이고, 80번 포트가 31380이라는 노드 포트로 열려있습니다. 브라우저를 실행하고, 해당 포트로 접속해보겠습니다.

기본 설정을 바꾸지 않았다면, 사용자 이름은 admin@kubeflow.org 이고, 비밀번호는 12341234 입니다.

로그인이 성공적으로 되면, 다음과 같이 사용할 네임스페이스를 생성하는 화면이 나옵니다. 원하는 이름을 입력하시면 됩니다. 기본값을 admin 으로 되어있습니다.

네임스페이스가 생성되면, kubeflow 대시보드 화면을 볼 수 있습니다.
