KubeFlow 1.02部署

原创
2020/06/16 12:24
阅读数 4.8K

Kubeflow 部署(使用 kfctl_k8s_istio)

安装 Kubeflow的一些指南(使用 kfctl_k8s_istio 配置部署到已有的Kubernetes集群中)。该配置清单创建Kubeflow的核心部件部署,但不包括外部依赖,可以根据您的环境需要进行优化。

前期工作

该Kubeflow deployment要求 StorageClass 支持 dynamic volume provisioner。确认缺省的StorageClass的 provisioner 域的设置。如果换没有 provisioner, 确保配置了 volume provisioning,按照下面的描述在 Kubernetes cluster 进行设置(参考 below)。

Kubeflow依赖Istio的安装,参考:

使用 kfctl_k8s_istio.v1.0.2.yaml 配置安装,需要考虑下面的选项:

  • Disabling istio installation - 如果 Kubernetes cluster 已有 Istio 安装,可以选择不安装Istio,通过一移除配置文件kfctl_k8s_istio.v1.0.2.yaml中的 istio-crdsistio-install 参数。

准备环境

下载 kfctl 的 Kubeflow CLI 工具,然后手动设置环境变量:

  1. 下载kfctl v1.0.2 发布版本,到 Kubeflow releases page

  2. 解压缩 tar ball:

    tar -xvf kfctl_v1.0.2_<platform>.tar.gz
    
  3. 创建环境变量,简化部署过程:

    # The following command is optional. It adds the kfctl binary to your path.
    # If you don't add kfctl to your path, you must use the full path
    # each time you run kfctl.
    # Use only alphanumeric characters or - in the directory name.
    export PATH=$PATH:"<path-to-kfctl>"
    
    ##实际如下:
    ##export PATH=$PATH:"/home/supermap/openthings/kubeflow"
    
    # Set KF_NAME to the name of your Kubeflow deployment. You also use this
    # value as directory name when creating your configuration directory.
    # For example, your deployment name can be 'my-kubeflow' or 'kf-test'.
    export KF_NAME=<your choice of name for the Kubeflow deployment>
    
    ##实际如下:
    ##export KF_NAME="kubeflow"
    
    # Set the path to the base directory where you want to store one or more 
    # Kubeflow deployments. For example, /opt/.
    # Then set the Kubeflow application directory for this deployment.
    export BASE_DIR=<path to a base directory>
    export KF_DIR=${BASE_DIR}/${KF_NAME}
    
    ##实际如下:
    ##export BASE_DIR="/home/supermap/openthings/"
    ##export KF_DIR=${BASE_DIR}/${KF_NAME}
    
    # Set the configuration file to use when deploying Kubeflow.
    # The following configuration installs Istio by default. Comment out 
    # the Istio components in the config file to skip Istio installation. 
    # See https://github.com/kubeflow/kubeflow/pull/3663
    export CONFIG_URI="https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_k8s_istio.v1.0.2.yaml"
    
    ##实际如下:
    ##export CONFIG_URI=${BASE_DIR}/${KF_NAME}/kfctl_k8s_istio.v1.0.2.yaml
    

注意:

  • ${KF_NAME} -  Kubeflow 部署的名称。如果要定制部署的 deployment name,通过该参数指定。例如, my-kubeflowkf-test。该 KF_NAME 必须小写字母或者 ‘-', 开始和结束必须为字母。该变量不能超过 25 个字符。只能包含名称,不能包含目录路径。同时将作为创建目录的名称,用于保存 Kubeflow configurations,即Kubeflow application directory。

  • ${KF_DIR} -  Kubeflow application directory的全路径。

  • ${CONFIG_URI} -该 GitHub address,位于 https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_k8s_istio.v1.0.2.yaml。当运行kfctl applykfctl build (see the next step), kfctl 创建一个 YAML 文件的本地版本,可以进一步定制化。

设置和部署 Kubeflow

使用缺省设置来设置和部署 Kubeflow using the default settings,运行 kfctl apply 如下:

mkdir -p ${KF_DIR}
cd ${KF_DIR}
kfctl apply -V -f ${CONFIG_URI}

检查 resources deployed in namespace kubeflow:

kubectl -n kubeflow get all

可选,设置以后部署的配置参数:

在部署 Kubeflow时,如果需要定制安装参数,可以编辑该配置文件,然后运行 Kubeflow的部署命令即可:

  1. 运行 kfctl build 命令设置安装参数:

    mkdir -p ${KF_DIR}
    cd ${KF_DIR}
    kfctl build -V -f ${CONFIG_URI}
    
  2. 编辑配置文件,描述如上 customizing your Kubeflow deployment

  3. 设置环境变量指向本地的配置文件:

    export CONFIG_FILE=${KF_DIR}/kfctl_k8s_istio.v1.0.2.yaml
    
  4. 运行 kfctl apply 目录实施 Kubeflow 部署:

    kfctl apply -V -f ${CONFIG_FILE}
    

访问 Kubeflow 用户界面 (UI)

Kubeflow 部署完成后,Kubeflow Dashboard 的访问通过服务 istio-ingressgateway 来获取。loadbalancer在环境中不可用,NodePort 或 Port forwarding 可以用于访问 Kubeflow Dashboard,参考 Ingress Gateway guide 或者:

删除 Kubeflow

运行下面的命令删除部署并回收资源:

cd ${KF_DIR}
# If you want to delete all the resources, run:
kfctl delete -f ${CONFIG_FILE}

理解部署过程

 kfctl 部署过程包含下面几个命令:

  • kfctl build - (可选) 创建配置文件,只在需要自行修改配置参数时才需要在 kfctl apply之前运行 kfctl build
  • kfctl apply - 创建或更新资源。
  • kfctl delete - 删除资源。

应用的布局

您的 Kubeflow 应用目录 ${KF_DIR} 包含下面的文件和目录:

  • ${CONFIG_FILE} 是一个 YAML 文件定义了kubeflow部署的参数:

  • kustomize 是一个目录,包含 Kubeflow applications应用的定制化包。参考: how Kubeflow uses kustomize

    • 该目录在运行 kfctl buildkfctl apply时创建出来。
    • 可以通过修改目录中的manifests来定制 Kubernetes resources ,然后重新运行 kfctl apply 进行部署和更新。

建议将${KF_DIR} 目录中的内容纳入版本管理系统。

Provisioning of Persistent Volumes in Kubernetes

如果已经有 dynamic volume provisioner,可以跳过本步骤:

如果没有,参考:

  • 在部署Kubeflow后手动创建 PVs 。
  • 安装dynamic volume provisioner,如 Local Path Provisioner。确保provisioner使用的 StorageClass为缺省的 StorageClass。

问题解决

Persistent Volume Claims 处于 Pending 状态

检查PersistentVolumeClaims 是否 Bound 到 PersistentVolumes,如下:

kubectl -n kubeflow get pvc

如果PersistentVolumeClaims (PVCs) 在 Pending 状态,部署后没有bound 到 PersistentVolumes (PVs),就需要手动为每一个PVC创建PV,或者安装 dynamic volume provisioning 来按需创建PVs ,以及删除存在的PVCs然后重新部署 Kubeflow。

下一步

更多参考

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部