前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于 kubesphere 搭建一站式云原生机器学习平台

基于 kubesphere 搭建一站式云原生机器学习平台

作者头像
operator开发工程师
发布2023-11-16 20:02:27
7460
发布2023-11-16 20:02:27
举报
文章被收录于专栏:云原生民工云原生民工

搭建 kubesphere

注意:机器最低规格为:8C16G ;kubectl 版本要1.24 ;之前安装过 KS 要提前清理下环境。

下载 KubeKey

1 2

export KKZONE=cn curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.2 sh -

如果机器上之前安装过 KubeSphere 或者 KubeSphere 版本太高 , 先卸载 KubeSphere,k8s 版本太高有问题,会导致部分 CRD 不能安装

1

./kk delete cluster

清理 kubeconfig,不然会导致其他 node 节点 无法使用 kubectl

1

rm -rf /root/.kube/config

安装 1.22 版本的 k8s

1

./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.3.1

详细安装步骤可以参考 KubeSphere 官方文档

部署 cube-studio

下载 cube-studio 源码

1

git clone https://github.com/tencentmusic/cube-studio.git

安装

将k8s集群的 kubeconfig 文件复制到 install/kubernetes/config 文件中,然后执行如下命令,其中xx.xx.xx.xx为机器内网的ip

1 2 3 4

cp $HOME/.kube/config install/kubernetes/config # 在k8s worker机器上执行 sh start.sh xx.xx.xx.xx

部署注意事项

注意 kubectl 版本是否是最新的

Kubectl 版本太低可能会导致部署 CRD 会报错,导致 istio-system 下面的 svc 创建不成功

1 2 3

customresourcedefinition.apiextensions.k8s.io/applications.app.k8s.io condition met error: json: cannot unmarshal object into Go struct field Kustomization.patchesStrategicMerge of type patch.StrategicMerge error: rawResources failed to read Resources: Load from path ../../base failed: '../../base' must be a file (got d='/home/zjlab/zyg/cube-studio-master/install/kubernetes/kubeflow/train-operator/manifests/base')

Kubesphere 的 kubectl 默认在 /usr/local/bin/kubectl 目录下面,cube-studio 的 kubectl 默认在 /usr/bin 下面

1

cp /usr/bin/kubectl /usr/local/bin/

mysql 遇到的坑
  • 标签未打成功

查看node标签

1

kubectl get nodes --show-labels

发现如果没有 mysql=true 标签,重新执行打标签命令

1

kubectl label node $node train=true cpu=true notebook=true service=true org=public istio=true knative=true kubeflow=true kubeflow-dashboard=true mysql=true redis=true monitoring=true logging=true --overwrite

  • 手动拉取 busybox

如果 mysql 报错:

1

Warning Failed 34s kubelet Failed to pull image "busybox": rpc error: code = Unknown desc = Error response from daemon: Head "https://registry-1.docker.io/v2/library/busybox/manifests/latest": unauthorized: incorrect username or password

需要 docker login ,然后docker pull busybox 手动拉取

  • PV 雨 PVC 未绑定

kubectl get pv infra-mysql-pv 查看PV状态,如果未绑定添加 storageClassName: local等字段

kubectl edit pv infra-mysql-pv

1 2 3 4 5 6

claimRef: apiVersion: v1 kind: PersistentVolumeClaim name: infra-mysql-pvc namespace: infra storageClassName: local

https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220908194945477.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220908194945477.png
  • 重启 mysql

kubectl edit deploy -n infra mysql 设置 replicas=0

然后清理 /data/k8s/infra/mysql 残余数据(慎用!!!)

最后 replicas=1 坐等 infra 命名空间下面的 pod 都 running

notebook 遇到的坑
  • notebook 无法运行,需要清空 kubeconfig

kubectl edit configmap kubernetes-config -n infra

kubectl edit configmap kubernetes-config -n pipelinekubectl edit configmap kubernetes-config -n katib

使用 cube-studio

快速使用

  • 添加项目分组,不要把用户都放在 public 项目组里面,会有问题。
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220824154753135.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220824154753135.png
  • 添加模版分类
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145320312.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145320312.png
  • 添加仓库
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145421237.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145421237.png
  • 如果是拉取 docker hub 上面的镜像的话,训练—仓库—hubsecret,修改你的 dockerhub 的用户名和密码
  • 如果是拉取 Harbor 镜像,新建一个仓库,填写 Harbor 服务器域名或者 IP 和用户名密码

1 2 3 4 5 6 7 8

名称: harbor 域名: http://10.100.29.41:30080/ 用户名: admin k8s hubsecret: zjflab

其中 k8s hubsecret 的创建的命令为

1 2 3 4 5 6

kubectl create secret docker-registry zjflab \ --docker-server=10.100.29.41:30080 \ --docker-username=admin \ --docker-password=Harbor12345 \ --docker-email=zhuyaguang1368@163.com \ --namespace="pipeline"

  • 镜像管理,创建你的 任务 镜像
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145533135.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145533135.png

设置镜像的仓库,完全名称并带上版本号。

你的镜像可以在开发环境上打好,然后上传到 Harbor 上。

  • 添加 任务模版
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145645393.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145645393.png

填写镜像,任务名称,启动命令

  • 创建任务流
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145918835.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903145918835.png
  • 部署服务上线
    1. 提前构建一个 web app 的镜像,可以对外暴露 http rest 接口
    2. 使用 官方的 模型服务化-deploy-service 模版
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903150604506.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903150604506.png
  1. 填写 服务类型为 serving ,镜像和暴露的端口号。
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903151221785.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903151221785.png
  1. 运行任务流,部署生产,部署生产,平台会生成一个 EXTERNAL-IP 对外暴露服务,即可通过 IP 栏地址进行访问服务。
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903151636034.png
https://zhuyaguang-1308110266.cos.ap-shanghai.myqcloud.com/img/image-20220903151636034.png

使用 GPU

打标签

1

kubectl label node worker-1 gpu=true gpu-type=V100 --overwrite

安装 Harbor 并配置证书

Harbor在线安装:3分钟体验Harbor!

How to install and use VMware Harbor private registry with Kubernetes

Pull an Image from a Private Registry

在 部署好的 Harbor 中添加 HTTPS 证书配置

harbor镜像仓库-https访问的证书配置

x509: cannot validate certificate for 10.30.0.163 because it doesn’t contain any IP SANs

最后 Docker login $harborIP,就可以 docker pull 拉取服务。

使用 BentoMl 快速发布一个 web 镜像

构建分布式存储

遗留问题

监控冲突

使用 kubesphere 监控

卸载 cube-studio

1 2 3 4 5

kubectl delete configmap grafana-config all-grafana-dashboards --namespace=monitoring kubectl delete -f ./grafana/grafana-dp.yml kubectl delete -f ./prometheus/prometheus-main.yml kubectl delete -f ./operator/operator-crd.yml

  1. 删掉 kubesphere 和 cube 其中之一的 node-exporter 的 ds
  2. 将 kubesphere 和 cube 其中之一的 prometheus-operator deploy replicas 设置为 0

参考文档

本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-07-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 搭建 kubesphere
  • 部署 cube-studio
    • 部署注意事项
      • 注意 kubectl 版本是否是最新的
      • mysql 遇到的坑
      • notebook 遇到的坑
  • 使用 cube-studio
    • 快速使用
      • 使用 GPU
        • 安装 Harbor 并配置证书
          • 使用 BentoMl 快速发布一个 web 镜像
            • 构建分布式存储
            • 遗留问题
              • 监控冲突
              • 参考文档
              相关产品与服务
              容器服务
              腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
              http://www.vxiaotou.com