独立部署
旧版本
本页面是关于 Kubeflow Pipelines V1,有关最新信息,请参见 V2 documentation。
注意,虽然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 独立安装选项
This guide currently describes how to install Kubeflow Pipelines standalone on Google Cloud Platform (GCP). You can also install Kubeflow Pipelines standalone on other platforms. This guide needs updating. See 问题 1253.在开始之前
使用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
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 -kaccepts 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.Deprecation Notice
Kubeflow Pipelines will change default executor from Docker to Emissary starting KFP backend v1.8, docker executor has been deprecated on Kubernetes 1.20+.
For Kubeflow Pipelines before v1.8, configure to use Emissary executor by referring to Argo Workflow Executors.
获取Kubeflow Pipelines UI的公共网址并使用它访问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 -nget deployments | grep metadata-deployment kubectl -nget service | grep metadata-service 如果这些资源在您的集群中存在,请运行以下命令将其删除:
kubectl -ndelete deployment metadata-deployment kubectl -ndelete service metadata-service 对于其他版本,您不需要做任何事情。
自定义 Kubeflow Pipelines
Kubeflow Pipelines 可以通过 kustomize 覆盖进行配置。
首先,克隆Kubeflow Pipelines GitHub 仓库,并将其用作你的工作目录。
在 GCP 上使用 Cloud SQL 和 Google Cloud Storage 部署
注意: 这推荐用于生产环境。有关如何为 GCP 自定义环境的更多细节,请参见 Kubeflow Pipelines GCP manifests。
更改部署命名空间
要在命名空间 中独立部署 Kubeflow Pipelines:
在
dev/kustomization.yaml或gcp/kustomization.yaml中设置namespace字段为。在 cluster-scoped-resources/kustomization.yaml 中将
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 独立部署会安装一个 反向代理代理,以公开 URL。如果您想跳过反向代理代理的安装,请完成以下操作:
在基础
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 用户界面。
卸载 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
进一步阅读
- 要了解关于现成配置的kustomize工作流程,请参阅 kustomize配置指南。
故障排除
- 如果你的管道卡在ContainerCreating状态,并且有如下的pod事件
MountVolume.SetUp failed for volume "gcp-credentials-user-gcp-sa" : secret "user-gcp-sa" not found
您应该删除 use_gcp_secret 的使用,具体请参见 认证管道到 GCP。
接下来做什么
- 使用SDK连接到Google Cloud上的Kubeflow Pipelines独立版本
- 将管道认证为GCP 如果您想在Kubeflow管道中使用GCP服务。