从零到一:基于 K3s 快速搭建本地化 kubeflow AI 机器学习平台

背景

Kubeflow 是一种开源的 Kubernetes 原生框架,可用于开发、管理和运行机器学习工作负载,支持诸如 PyTorch、TensorFlow 等众多优秀的机器学习框架,本文介绍如何在 Mac 上搭建本地化的 kubeflow 机器学习平台。
在这里插入图片描述

注意:本文以 deyloyKF 发行版作为主要安装对象,本地环境仅适用于开发测试使用,不可用于生产环境!

更多 kubeflow 发行版参考官网介绍:https://www.kubeflow.org/docs/started/installing-kubeflow/

基本环境:

OS:macos 13.1 (amd64)
DockerDesktop:v4.15.0

尽管 K3s 自身需要的资源不多,但是 kubeflow 套件组件众多,需要设置 Docker 的资源分配,避免安装过程中发生 Pod Pending.
Docker 资源建议设置:CPU 8 核,Memory 10G,磁盘 40G
在这里插入图片描述

安装部署步骤

1. 安装依赖的 CLI

brew install bash argocd jq k3d kubectl kustomize

2. 创建 Kubernetes 集群

为了尽可能降低资源消耗,这里使用 K3s 运行本地集群:

k3d cluster create "kubeflow" --image "rancher/k3s:v1.27.10-k3s2"

通过如下命令检查集群是否就绪:

kubectl get -A pods

正常的输出结果类似如下这样:

NAMESPACE     NAME                                     READY   STATUS      RESTARTS   AGE
kube-system   local-path-provisioner-957fdf8bc-cj9l5   1/1     Running     0          2m30s
kube-system   coredns-77ccd57875-xzzz4                 1/1     Running     0          2m30s
kube-system   metrics-server-648b5df564-gwnhq          1/1     Running     0          2m30s
kube-system   helm-install-traefik-crd-49l4k           0/1     Completed   0          2m31s
kube-system   helm-install-traefik-xrjtd               0/1     Completed   2          2m31s
kube-system   svclb-traefik-a79cf0ef-lj4td             2/2     Running     0          89s
kube-system   traefik-768bdcdcdd-mr8z8                 1/1     Running     0          89s

3. 部署 ArgoCD

ArgoCD 是工作流编排工具,可以帮助我们实现 Kubeflow 的自动化部署

git clone -b main https://github.com/deployKF/deployKF.git
cd deployKF/argocd-plugin
chmod +x ./install_argocd.sh
bash ./install_argocd.sh

通过如下命令检查 ArgoCD 是否就绪:

kubectl get pod -n argocd

正常的输出结果类似如下这样:

NAME                                                READY   STATUS    RESTARTS   AGE
argocd-redis-69f8795dbd-7v4nn                       1/1     Running   0          106s
argocd-applicationset-controller-7b9c4dfb77-7gsf2   1/1     Running   0          106s
argocd-notifications-controller-756764ddd5-jw92c    1/1     Running   0          106s
argocd-server-86f64667bc-7nt7d                      1/1     Running   0          105s
argocd-application-controller-0                     1/1     Running   0          105s
argocd-dex-server-9b5c6dccd-2p779                   1/1     Running   0          106s
argocd-repo-server-5b55578f7c-sfzf4                 2/2     Running   0          105s

4. 安装 kubeflow 套件

准备如下文件:deploykf-app-of-apps.yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:name: deploykf-app-of-appsnamespace: argocdlabels:app.kubernetes.io/name: deploykf-app-of-appsapp.kubernetes.io/part-of: deploykf
spec:project: "default"source:## source git repo configuration##  - we use the 'deploykf/deploykf' repo so we can read its 'sample-values.yaml'##    file, but you may use any repo (even one with no files)##repoURL: "https://github.com/deployKF/deployKF.git"targetRevision: "v0.1.4"path: "."## plugin configuration##plugin:name: "deploykf"parameters:## the deployKF generator version##  - available versions: https://github.com/deployKF/deployKF/releases##- name: "source_version"string: "0.1.4"## paths to values files within the `repoURL` repository##  - the values in these files are merged, with later files taking precedence##  - we strongly recommend using 'sample-values.yaml' as the base of your values##    so you can easily upgrade to newer versions of deployKF##- name: "values_files"array:- "./sample-values.yaml"## a string containing the contents of a values file##  - this parameter allows defining values without needing to create a file in the repo##  - these values are merged with higher precedence than those defined in `values_files`##- name: "values"string: |#### This demonstrates how you might structure overrides for the 'sample-values.yaml' file.## For a more comprehensive example, see the 'sample-values-overrides.yaml' in the main repo.#### Notes:##  - YAML maps are RECURSIVELY merged across values files##  - YAML lists are REPLACED in their entirety across values files##  - Do NOT include empty/null sections, as this will remove ALL values from that section.##    To include a section without overriding any values, set it to an empty map: `{}`#### --------------------------------------------------------------------------------##                                      argocd## --------------------------------------------------------------------------------argocd:namespace: argocdproject: default## --------------------------------------------------------------------------------##                                    kubernetes## --------------------------------------------------------------------------------kubernetes:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------------------------------------------------##                              deploykf-dependencies## --------------------------------------------------------------------------------deploykf_dependencies:## --------------------------------------##             cert-manager## --------------------------------------cert_manager:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##                 istio## --------------------------------------istio:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##                kyverno## --------------------------------------kyverno:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------------------------------------------------##                                  deploykf-core## --------------------------------------------------------------------------------deploykf_core:## --------------------------------------##             deploykf-auth## --------------------------------------deploykf_auth:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##        deploykf-istio-gateway## --------------------------------------deploykf_istio_gateway:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##      deploykf-profiles-generator## --------------------------------------deploykf_profiles_generator:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------------------------------------------------##                                   deploykf-opt## --------------------------------------------------------------------------------deploykf_opt:## --------------------------------------##            deploykf-minio## --------------------------------------deploykf_minio:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##            deploykf-mysql## --------------------------------------deploykf_mysql:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------------------------------------------------##                                  kubeflow-tools## --------------------------------------------------------------------------------kubeflow_tools:## --------------------------------------##                 katib## --------------------------------------katib:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##               notebooks## --------------------------------------notebooks:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!## --------------------------------------##               pipelines## --------------------------------------pipelines:{} # <-- REMOVE THIS, IF YOU INCLUDE VALUES UNDER THIS SECTION!destination:server: "https://kubernetes.default.svc"namespace: "argocd"

执行如下命令,部署工作流:

kubectl apply -f ./deploykf-app-of-apps.yaml

通过 UI 界面查看 ArgoCD 状态:

kubectl port-forward --namespace "argocd" svc/argocd-server 8090:https

浏览器打开 https://localhost:8090/,用户名:admin,密码可通过如下命令获取:

echo $(kubectl -n argocd get secret/argocd-initial-admin-secret \-o jsonpath="{.data.password}" | base64 -d)

在这里插入图片描述
由于程序间存在依赖关系,可以通过如下脚本按序执行 Sync 操作:

git clone -b main https://github.com/deployKF/deployKF.git
cd deployKF/scripts
chmod +x ./sync_argocd_apps.sh
bash ./sync_argocd_apps.sh

该脚本是幂等的,失败后可反复执行直到部署成功,成功部署后的运行中 Pod 列表类似如下这样:

NAMESPACE                 NAME                                                 READY   STATUS    RESTARTS       AGE
argocd                    argocd-redis-69f8795dbd-x5wtv                        1/1     Running   5 (17m ago)    105m
argocd                    argocd-server-86f64667bc-zfm7m                       1/1     Running   4 (17m ago)    73m
argocd                    argocd-repo-server-5b55578f7c-x26zz                  2/2     Running   10 (17m ago)   91m
argocd                    argocd-notifications-controller-756764ddd5-2fqbr     1/1     Running   5 (17m ago)    89m
argocd                    argocd-dex-server-9b5c6dccd-bl86m                    1/1     Running   5 (17m ago)    91m
argocd                    argocd-application-controller-0                      1/1     Running   5 (17m ago)    91m
argocd                    argocd-applicationset-controller-7b9c4dfb77-hph2r    1/1     Running   5 (17m ago)    105m
cert-manager              cert-manager-c688c56f-w4jts                          1/1     Running   5 (17m ago)    109m
cert-manager              trust-manager-78766fd9bd-zd5zf                       1/1     Running   5 (17m ago)    90m
cert-manager              cert-manager-webhook-d45447457-q6cf8                 1/1     Running   6 (17m ago)    109m
cert-manager              cert-manager-cainjector-59d694bcc7-mrcvg             1/1     Running   6 (17m ago)    109m
deploykf-auth             oauth2-proxy-5fd9888b79-tpnrt                        2/2     Running   11 (16m ago)   73m
deploykf-auth             dex-68c8bf56b9-78d5g                                 2/2     Running   8 (17m ago)    73m
deploykf-dashboard        profile-controller-5575767c76-vshp2                  2/2     Running   8 (17m ago)    73m
deploykf-dashboard        kfam-api-75b64c9645-sjfcq                            2/2     Running   10 (17m ago)   98m
deploykf-dashboard        central-dashboard-6b5d9574dc-fmlt4                   2/2     Running   10 (17m ago)   98m
deploykf-istio-gateway    deploykf-gateway-6ddf8947cc-qz55g                    1/1     Running   5 (17m ago)    98m
deploykf-minio            deploykf-minio-568b877668-w2wct                      2/2     Running   5 (17m ago)    52m
deploykf-mysql            deploykf-mysql-0                                     1/1     Running   5 (17m ago)    109m
istio-system              istiod-7b9b6df595-jbztw                              1/1     Running   5 (17m ago)    91m
kube-system               svclb-deploykf-gateway-7f7cba3a-kkskn                3/3     Running   15 (17m ago)   100m
kube-system               metrics-server-648b5df564-gwnhq                      1/1     Running   9 (17m ago)    5h43m
kube-system               local-path-provisioner-957fdf8bc-cj9l5               1/1     Running   7 (17m ago)    5h43m
kube-system               coredns-77ccd57875-xzzz4                             1/1     Running   7 (17m ago)    5h43m
kube-system               traefik-768bdcdcdd-mr8z8                             1/1     Running   7 (17m ago)    5h42m
kube-system               svclb-traefik-a79cf0ef-6ksjm                         2/2     Running   10 (17m ago)   100m
kubeflow                  katib-controller-75858c4ddf-hwvkx                    1/1     Running   8 (17m ago)    95m
kubeflow                  ml-pipeline-ui-68b7f6586d-qtjp5                      2/2     Running   15 (17m ago)   94m
kubeflow                  ml-pipeline-persistenceagent-68bbd65f98-tsnqn        2/2     Running   10 (17m ago)   94m
kubeflow                  katib-ui-d4df8bdb6-2x75p                             2/2     Running   10 (17m ago)   95m
kubeflow                  ml-pipeline-6445d9fb77-dxgv4                         2/2     Running   24 (16m ago)   94m
kubeflow                  admission-webhook-deployment-789dc56fbf-z7cj8        1/1     Running   5 (17m ago)    94m
kubeflow                  metadata-writer-6f95b9588c-fmx4s                     2/2     Running   8 (17m ago)    73m
kubeflow                  notebook-controller-deployment-649cf9b976-vnvwd      2/2     Running   10 (17m ago)   95m
kubeflow                  training-operator-7cf5c66858-jf5sr                   1/1     Running   3 (17m ago)    43m
kubeflow                  tensorboards-web-app-deployment-778466f5f6-dmrks     2/2     Running   2 (17m ago)    43m
kubeflow                  tensorboard-controller-deployment-644f57dd7c-zlxnw   3/3     Running   24 (17m ago)   92m
kubeflow                  ml-pipeline-scheduledworkflow-578475988-kwz27        2/2     Running   10 (17m ago)   94m
kubeflow                  volumes-web-app-deployment-588d46bb75-95g6b          2/2     Running   2 (17m ago)    42m
kubeflow                  ml-pipeline-viewer-crd-6857ccc85c-zl895              2/2     Running   10 (17m ago)   94m
kubeflow                  metadata-grpc-deployment-566d54d578-wwj9n            2/2     Running   23 (16m ago)   94m
kubeflow                  ml-pipeline-visualizationserver-7b45b7fd56-s4pxh     2/2     Running   15 (17m ago)   94m
kubeflow                  cache-server-66d7586749-prmkq                        2/2     Running   10 (17m ago)   94m
kubeflow                  jupyter-web-app-deployment-9c8c779c-hcqvr            2/2     Running   15 (17m ago)   91m
kubeflow                  katib-db-manager-6998f5bdd8-lrs77                    1/1     Running   5 (17m ago)    95m
kubeflow                  metadata-envoy-deployment-b48db5966-542nh            1/1     Running   5 (17m ago)    94m
kubeflow-argo-workflows   argo-workflow-controller-79fc5c6895-2g26t            2/2     Running   10 (17m ago)   98m
kubeflow-argo-workflows   argo-server-6d97fb7649-lsfdw                         2/2     Running   5 (16m ago)    73m
kyverno                   kyverno-cleanup-controller-6cb4d5848-hh8nm           1/1     Running   5 (17m ago)    109m
kyverno                   kyverno-admission-controller-964c74c7d-frknb         1/1     Running   5 (17m ago)    109m
kyverno                   kyverno-background-controller-796f77c79f-nwhrs       1/1     Running   5 (17m ago)    109m
kyverno                   kyverno-reports-controller-6d6d98fc96-z7qjv          1/1     Running   5 (17m ago)    109m
kyverno                   kyverno-admission-controller-964c74c7d-hgtc2         1/1     Running   4 (17m ago)    109m
kyverno                   kyverno-admission-controller-964c74c7d-x744h         1/1     Running   5 (17m ago)    109m
team-1                    ml-pipeline-visualizationserver-677c86b748-nbrr5     2/2     Running   2 (17m ago)    73m
team-1                    ml-pipeline-ui-artifact-7749b4f5f6-ld7kl             2/2     Running   10 (17m ago)   94m
team-1-prod               ml-pipeline-visualizationserver-677c86b748-hqwsh     2/2     Running   2 (17m ago)    73m
team-1-prod               ml-pipeline-ui-artifact-7749b4f5f6-hl6gk             2/2     Running   10 (17m ago)   94m

同步完成后的 ArgoCD 界面(完成 20 个应用同步):
在这里插入图片描述

5. 访问控制台

执行端口转发:

kubectl port-forward \--namespace "deploykf-istio-gateway" \svc/deploykf-gateway 8080:http 8443:https

由于 Istio Gateway 基于 Host Header 区分访问的目标服务,因此需要配置本地 /etc/hosts 文件,追加如下内容:

127.0.0.1 deploykf.example.com
127.0.0.1 argo-server.deploykf.example.com
127.0.0.1 minio-api.deploykf.example.com
127.0.0.1 minio-console.deploykf.example.com

浏览器访问 https://deploykf.example.com:8443/

管理员:用户名 admin@example.com 密码 admin
用户 1: 用户名 user1@example.com 密码 user1
用户 2: 用户名 user2@example.com 密码 user2

在这里插入图片描述

6. 运行 Jupyter

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

更多功能持续探索中…

本文引用

https://www.deploykf.org/guides/local-quickstart/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/588608.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

常见滤波算法(PythonC版本)

简介 受限于MCU自身的ADC外设缺陷&#xff0c;精度和稳定性通常较差&#xff0c;很多场景下需要用滤波算法进行补偿。滤波的主要目的是减少噪声与干扰对数据的影响&#xff0c;让数据更加接近真实值。 一阶低通滤波算 一阶低通滤波是一种信号处理技术&#xff0c;用于去除信号…

this.$route.back()时的组件缓存

1.this.$route.back()回到上一个路径会重新加载 跳转时,前一个路由的内容会被销毁,当回来时,重新创建树,组件内有保存了距离,没有一开始是0. 2.keep-alive写在router-view上面,这个地方所代表的路由会被保存,因此可以写在上面,保存,当返回时,如果是这个路由,里面的内容是一样…

基于Scala开发Spark ML的ALS推荐模型实战

推荐系统&#xff0c;广泛应用到电商&#xff0c;营销行业。本文通过Scala&#xff0c;开发Spark ML的ALS算法训练推荐模型&#xff0c;用于电影评分预测推荐。 算法简介 ALS算法是Spark ML中实现协同过滤的矩阵分解方法。 ALS&#xff0c;即交替最小二乘法&#xff08;Alte…

了解与生成火焰图

目录 一、如何看懂火焰图 1、基本特征 2、基本分类 二、如何生成火焰图 1、捕获调用栈 2、折叠栈 3、转换为 svg 格式 4、展示 svg 一、如何看懂火焰图 1、基本特征 &#xff08;1&#xff09;纵轴&#xff1a;即每一列代表一个调用栈&#xff0c;每一个格子代表一个函…

云计算对象存储服务

对象存储服务&#xff08;OSS&#xff09;中的存储桶(Bucket)叫做‘OBS桶 存储桶&#xff08;Bucket&#xff09;&#xff1a;存储桶式对象存储服务中用于存储对象的基本容器&#xff0c;类似于文件系统中的文件夹。每个存储桶具有唯一的名称&#xff0c;并且可以在桶中存储任…

15.Python访问数据库

如果数据量较少&#xff0c;则我们可以将数据保存到文件中&#xff1b;如果数据量较 大&#xff0c;则我们可以将数据保存到数据库中。 1 SQLite数据库 SQLite是嵌入式系统使用的关系数据库&#xff0c;目前的主流版本是SQLite 3。SQLite是开源的&#xff0c;采用C语言编写而…

新版Pubmed初识

PubMed基本检索操作指南。 PubMed和MEDLINE MEDLINE是美国国立医学图书馆&#xff08;The National Library of Medicine&#xff0c;NLM&#xff09;开发的国际性综合生物医学信息书目数据库&#xff0c;是当前国际上最权威的生物医学文献数据库。内容包括美国医学索引&…

c#仿ppt案例

画曲线 namespace ppt2024 {public partial class Form1 : Form{public Form1(){InitializeComponent();}//存放所有点的位置信息List<Point> lstPosition new List<Point>();//控制开始画的时机bool isDrawing false;//鼠标点击开始画private void Form1_MouseD…

两数之和-考察哈希表的运用

题目 给定一个整数数组 n u m s nums nums和一个整数目标值 t a r g e t target target&#xff0c;请你在该数组中找出和为目标值 t a r g e t target target的那 两个整数&#xff0c;并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是&#xff0c;数组中同…

04-03 周三 使用印象笔记API批量更新笔记标题

04-03 周三 使用印象笔记API批量更新笔记标题 时间版本修改人描述2024年4月3日11:13:50V0.1宋全恒新建文档 简介 安利印象笔记 在阅读这篇博客之前&#xff0c;首先给大家案例一下印象笔记这个应用&#xff0c;楼主之前使用onenote来记录自己的生活的&#xff0c;也记录了许多…

Android 自定义View 测量控件宽高、自定义viewgroup测量

1、View生命周期以及View层级 1.1、View生命周期 View的主要生命周期如下所示&#xff0c; 包括创建、测量&#xff08;onMeasure&#xff09;、布局&#xff08;onLayout&#xff09;、绘制&#xff08;onDraw&#xff09;以及销毁等流程。 自定义View主要涉及到onMeasure、…

揭秘糖尿病患者稳定控制血糖的关键!

患者在就诊之前一直使用的二甲双胍和达格列净这两种降糖药物&#xff0c;这两种药对于控制血糖是有一定效果的。北京崇文门医院朱学敏主任的建议是继续服用&#xff0c;然后患者空腹血糖在7-8mmol/L左右&#xff0c;餐后血糖稍高&#xff0c;达到9-10mmol/L&#xff0c;但总体上…