独立部署
旧版本
本页面介绍的是 Kubeflow Pipelines V1,请参阅V2 文档以获取最新信息。
请注意,虽然 V2 后端能够运行 V1 SDK 提交的流水线,我们强烈建议迁移到 V2 SDK。作为参考,V1 SDK 的最终版本是 kfp==1.8.22
,其参考文档在此处提供。
除了将 Kubeflow Pipelines (KFP) 作为Kubeflow 部署的一部分进行部署之外,您还可以选择仅部署 Kubeflow Pipelines。请按照以下说明使用提供的 kustomize 清单独立部署 Kubeflow Pipelines。
您应该熟悉Kubernetes、kubectl 和 kustomize。
Kubeflow Pipelines 独立安装选项
本指南目前描述了如何在 Google Cloud Platform (GCP) 上独立安装 Kubeflow Pipelines。您也可以在其他平台上独立安装 Kubeflow Pipelines。本指南需要更新。请参阅Issue 1253。开始之前
使用 Kubeflow Pipelines Standalone 需要一个 Kubernetes 集群以及安装 kubectl。
下载并安装 kubectl
请遵循 kubectl 安装指南下载并安装 kubectl。
您需要 kubectl 1.14 或更高版本才能原生支持 kustomize。
设置您的集群
如果您已有 Kubernetes 集群,请继续阅读配置 kubectl 连接到您的集群的说明。
请参阅 GKE 关于创建集群的指南(适用于 Google Cloud Platform (GCP))。
使用 gcloud container clusters create 命令创建一个可以运行所有 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。您可以通过参考 Cloud Machine families 中的指南来选择满足您需求的机器类型。
警告:使用 SCOPES="cloud-platform"
会授予集群所有 GCP 权限。要进行更安全的集群设置,请参阅如何对 Pipelines 进行 GCP 认证。
请注意,某些旧版流水线示例可能需要少量代码更改才能在具有 SCOPES="cloud-platform"
的集群上运行,请参阅编写使用默认服务账号的 Pipelines。
参考资料:
配置 kubectl 连接到您的集群
请参阅 Google Kubernetes Engine (GKE) 关于配置 kubectl 集群访问权限的指南。
部署 Kubeflow Pipelines
部署 Kubeflow Pipelines
export PIPELINE_VERSION=2.4.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"
Kubeflow Pipelines 的部署大约需要 3 分钟才能完成。
注意:上述命令适用于 Kubeflow Pipelines 0.4.0 及更高版本。
对于 Kubeflow Pipelines 0.2.0 ~ 0.3.0 版本,请使用
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"
对于 Kubeflow Pipelines < 0.2.0 版本,请使用
export PIPELINE_VERSION=<kfp-version-0.1.x> kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/dev?ref=$PIPELINE_VERSION"
注意:
kubectl apply -k
接受本地路径和格式为 hashicorp/go-getter URL 的路径。虽然上述命令中的路径看起来像 URL,但它们并非有效的 URL。弃用通知
从 KFP 后端 v1.8 开始,Kubeflow Pipelines 会将默认执行器从 Docker 更改为 Emissary,Docker 执行器已在 Kubernetes 1.20+ 上弃用。
对于 v1.8 之前的 Kubeflow Pipelines,请参阅Argo Workflow 执行器以配置使用 Emissary 执行器。
获取 Kubeflow Pipelines UI 的公共 URL 并使用它访问 Kubeflow Pipelines UI
kubectl describe configmap inverse-proxy-config -n kubeflow | grep googleusercontent.com
升级 Kubeflow Pipelines
有关发布通知和重大变更,请参阅升级 Kubeflow Pipelines。
请查看Kubeflow Pipelines GitHub 仓库以获取可用的发布版本。
要升级到 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 集群。
手动删除废弃资源。
根据您要从哪个版本升级以及要升级到哪个版本,某些 Kubeflow Pipelines 资源可能已废弃。
如果您从 Kubeflow Pipelines < 0.4.0 升级到 0.4.0 或更高版本,升级后可以删除以下废弃资源:
metadata-deployment
、metadata-service
。运行以下命令检查这些资源是否存在于您的集群上
kubectl -n <KFP_NAMESPACE> get deployments | grep metadata-deployment kubectl -n <KFP_NAMESPACE> get service | grep metadata-service
如果这些资源存在于您的集群上,运行以下命令删除它们
kubectl -n <KFP_NAMESPACE> delete deployment metadata-deployment kubectl -n <KFP_NAMESPACE> delete service metadata-service
对于其他版本,您无需执行任何操作。
自定义 Kubeflow Pipelines
Kubeflow Pipelines 可以通过 kustomize overlays 进行配置。
首先,克隆 Kubeflow Pipelines GitHub 仓库,并将其用作您的工作目录。
在 GCP 上使用 Cloud SQL 和 Google Cloud Storage 进行部署
注意:建议在生产环境中使用此方法。有关针对 GCP 自定义环境的更多详细信息,请参阅Kubeflow Pipelines GCP 清单。
更改部署命名空间
要在命名空间 <my-namespace>
中独立部署 Kubeflow Pipelines
在 dev/kustomization.yaml 或 gcp/kustomization.yaml 中将
namespace
字段设置为<my-namespace>
。在 cluster-scoped-resources/kustomization.yaml 中将
namespace
字段设置为<my-namespace>
应用更改以更新 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 独立部署会安装一个 inverting proxy agent,用于公开公共 URL。如果您想跳过安装 inverting proxy agent,请完成以下步骤
注释掉基础
kustomization.yaml
中的代理组件。例如,在 manifests/kustomize/env/dev/kustomization.yaml 中注释掉inverse-proxy
。应用更改以更新 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
通过端口转发验证 Kubeflow Pipelines UI 是否可访问
kubectl port-forward -n kubeflow svc/ml-pipeline-ui 8080:80
在
http://localhost:8080/
打开 Kubeflow Pipelines UI。
卸载 Kubeflow Pipelines
要卸载 Kubeflow Pipelines,运行 kubectl delete -k <manifest-file>
。
例如,要使用 GitHub 仓库中的清单卸载 KFP,运行
export PIPELINE_VERSION=2.4.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.4.0
延伸阅读
- 要了解使用现成配置的 kustomize 工作流程,请参阅 kustomize 配置指南。
故障排除
- 如果您的流水线卡在 ContainerCreating 状态,并且有如下 Pod 事件
MountVolume.SetUp failed for volume "gcp-credentials-user-gcp-sa" : secret "user-gcp-sa" not found
您应该移除 use_gcp_secret
的用法,如如何对 Pipelines 进行 GCP 认证中所述。
下一步
- 使用 SDK 连接到 Google Cloud 上的 Kubeflow Pipelines 独立部署
- 如果您想在 Kubeflow Pipelines 中使用 GCP 服务,请参阅如何对 Pipelines 进行 GCP 认证。