独立部署

关于Kubeflow Pipelines的独立部署的信息

作为将Kubeflow Pipelines (KFP) 部署为Kubeflow部署的一种替代方案,您也可以选择仅部署Kubeflow Pipelines。请按照以下说明使用提供的kustomize清单独立部署Kubeflow Pipelines。

您应该熟悉 Kubernetes, kubectlkustomize

在开始之前

使用Kubeflow Pipelines Standalone需要一个Kubernetes集群以及安装kubectl。

下载并安装 kubectl

按照kubectl 安装指南下载并安装kubectl。

您需要 kubectl 版本 1.14 或更高版本以原生支持 kustomize。

设置您的集群

如果你有一个现有的Kubernetes集群,请继续执行配置kubectl与您的集群进行通信的说明。

请参阅 GKE 指南,以了解在 Google Cloud Platform (GCP) 上 创建集群 的信息。

使用gcloud container clusters create command命令创建一个可以运行所有Kubeflow Pipelines示例的集群:

# The following parameters can be customized based on your needs.

CLUSTER_NAME="kubeflow-pipelines-standalone"
ZONE="us-central1-a"
MACHINE_TYPE="e2-standard-2" # A machine with 2 CPUs and 8GB memory.
SCOPES="cloud-platform" # This scope is needed for running some pipeline samples. Read the warning below for its security implication

gcloud container clusters create $CLUSTER_NAME \
     --zone $ZONE \
     --machine-type $MACHINE_TYPE \
     --scopes $SCOPES

注意: e2-standard-2 不支持 GPU。您可以通过参考 云机器系列 中的指南来选择满足您需求的机器类型。

警告:使用 SCOPES="cloud-platform" 会将所有 GCP 权限授予集群。要获得更安全的集群设置,请参考 将管道认证为 GCP

注意,一些旧版管道示例可能需要对代码进行小的更改才能在带有 SCOPES="cloud-platform" 的集群上运行,参考 编写管道以使用默认服务账户

参考文献:

配置kubectl与您的集群进行通信

请参阅 Google Kubernetes Engine (GKE) 指南,了解 为 kubectl 配置集群访问

部署 Kubeflow Pipelines

  1. Deploy the Kubeflow Pipelines:

    export PIPELINE_VERSION=2.3.0
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/cluster-scoped-resources?ref=$PIPELINE_VERSION"
    kubectl wait --for condition=established --timeout=60s crd/applications.app.k8s.io
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=$PIPELINE_VERSION"
    

    The Kubeflow Pipelines deployment requires approximately 3 minutes to complete.

    Note: The above commands apply to Kubeflow Pipelines version 0.4.0 and higher.

    For Kubeflow Pipelines version 0.2.0 ~ 0.3.0, use:

    export PIPELINE_VERSION=<kfp-version-between-0.2.0-and-0.3.0>
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/base/crds?ref=$PIPELINE_VERSION"
    kubectl wait --for condition=established --timeout=60s crd/applications.app.k8s.io
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=$PIPELINE_VERSION"
    

    For Kubeflow Pipelines version < 0.2.0, use:

    export PIPELINE_VERSION=<kfp-version-0.1.x>
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=$PIPELINE_VERSION"
    

    Note: kubectl apply -k accepts local paths and paths that are formatted as hashicorp/go-getter URLs. While the paths in the preceding commands look like URLs, the paths are not valid URLs.

  2. 获取Kubeflow Pipelines UI的公共网址并使用它访问Kubeflow Pipelines UI:

    kubectl describe configmap inverse-proxy-config -n kubeflow | grep googleusercontent.com
    

升级 Kubeflow Pipelines

  1. 有关版本通知和重大更改,请参阅 升级 Kubeflow Pipelines

  2. 查看Kubeflow Pipelines GitHub 仓库以获取可用的版本。

  3. 要升级到 Kubeflow Pipelines 0.4.0 及更高版本,请使用以下命令:

    export PIPELINE_VERSION=<version-you-want-to-upgrade-to>
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/cluster-scoped-resources?ref=$PIPELINE_VERSION"
    kubectl wait --for condition=established --timeout=60s crd/applications.app.k8s.io
    kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=$PIPELINE_VERSION"
    

    要升级到 Kubeflow Pipelines 0.3.0 及更低版本,请使用 部署说明 来升级您的 Kubeflow Pipelines 集群。

  4. 手动删除过时的资源。

    根据您正在升级的版本和您要升级到的版本,一些 Kubeflow Pipelines 资源可能已变得过时。

    如果您是从 Kubeflow Pipelines < 0.4.0 升级到 0.4.0 或更高版本,您可以在升级后删除以下过时的资源:

    metadata-deploymentmetadata-service

    运行以下命令检查这些资源是否在您的集群中存在:

    kubectl -n  get deployments | grep metadata-deployment
    kubectl -n  get service | grep metadata-service
    

    如果这些资源在您的集群中存在,请运行以下命令将其删除:

    kubectl -n  delete deployment metadata-deployment
    kubectl -n  delete service metadata-service
    

    对于其他版本,您不需要做任何事情。

自定义 Kubeflow Pipelines

Kubeflow Pipelines 可以通过 kustomize 覆盖进行配置。

首先,克隆Kubeflow Pipelines GitHub 仓库,并将其用作你的工作目录。

在 GCP 上使用 Cloud SQL 和 Google Cloud Storage 部署

注意: 这推荐用于生产环境。有关如何为 GCP 自定义环境的更多细节,请参见 Kubeflow Pipelines GCP manifests

更改部署命名空间

要在命名空间 中独立部署 Kubeflow Pipelines:

  1. dev/kustomization.yamlgcp/kustomization.yaml 中设置 namespace 字段为

  2. cluster-scoped-resources/kustomization.yaml 中将 namespace 字段设置为

  3. 应用更改以更新 Kubeflow Pipelines 部署:

    kubectl apply -k manifests/kustomize/cluster-scoped-resources
    kubectl apply -k manifests/kustomize/env/dev
    

    注意:如果使用 GCP Cloud SQL 和 Google Cloud Storage,请在 manifests/kustomize/env/gcp/params.env 中设置正确的值,然后使用此命令应用:

    kubectl apply -k manifests/kustomize/cluster-scoped-resources
    kubectl apply -k manifests/kustomize/env/gcp
    

禁用公共端点

默认情况下,KFP 独立部署会安装一个 反向代理代理,以公开 URL。如果您想跳过反向代理代理的安装,请完成以下操作:

  1. 在基础 kustomization.yaml 中注释掉代理组件。例如在 manifests/kustomize/env/dev/kustomization.yaml 中注释掉 inverse-proxy

  2. 应用更改以更新 Kubeflow Pipelines 部署:

    kubectl apply -k manifests/kustomize/env/dev
    

    注意:如果使用 GCP Cloud SQL 和 Google Cloud Storage,请在 manifests/kustomize/env/gcp/params.env 中设置适当的值,然后使用此命令应用:

    kubectl apply -k manifests/kustomize/env/gcp
    
  3. 验证 Kubeflow Pipelines UI 可通过端口转发访问:

    kubectl port-forward -n kubeflow svc/ml-pipeline-ui 8080:80
    
  4. http://localhost:8080/ 打开 Kubeflow Pipelines 用户界面。

卸载 Kubeflow Pipelines

要卸载 Kubeflow Pipelines,请运行 kubectl delete -k

例如,要使用来自 GitHub 存储库的清单卸载 KFP,请运行:

export PIPELINE_VERSION=2.3.0
kubectl delete -k "github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=$PIPELINE_VERSION"
kubectl delete -k "github.com/kubeflow/pipelines/manifests/kustomize/cluster-scoped-resources?ref=$PIPELINE_VERSION"

要使用来自您的本地仓库或文件系统的清单卸载 KFP,请运行:

kubectl delete -k manifests/kustomize/env/dev
kubectl delete -k manifests/kustomize/cluster-scoped-resources

注意: 如果您正在使用 GCP Cloud SQL 和 Google Cloud Storage,请运行:

kubectl delete -k manifests/kustomize/env/gcp
kubectl delete -k manifests/kustomize/cluster-scoped-resources

维护清单的最佳实践

与源代码类似,配置文件也属于源控制。 一个仓库管理着您的清单文件的更改,并确保您可以重复部署、升级和卸载您的组件。

在源代码管理中维护您的清单

在创建或自定义您的部署清单后,将您的清单保存到本地或远程源代码控制库中。
例如,保存以下 kustomization.yaml:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# Edit the following to change the deployment to your custom namespace.
namespace: kubeflow
# You can add other customizations here using kustomize.
# Edit ref in the following link to deploy a different version of Kubeflow Pipelines.
bases:
- github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=2.3.0

进一步阅读

故障排除

  • 如果你的管道卡在ContainerCreating状态,并且有如下的pod事件
MountVolume.SetUp failed for volume "gcp-credentials-user-gcp-sa" : secret "user-gcp-sa" not found

您应该删除 use_gcp_secret 的使用,具体请参见 认证管道到 GCP

接下来做什么

反馈

此页面有帮助吗?