搭建说明

最终目的:修改深度学习作业的调度算法

当前要搭建的环境:

(1)能运行kubeflow的tfjob的集群

(2)kubeflow进行gang-scheduler的调度算法 volcano

准备工作

(1) 安装好 k8s集群,安装好kfctl

(2) 确认你是否有一个默认StorageClass且也配置好了动态pv,确认方法如下:

确保集群中有默认的sc

目的:安装kubeflow过程,SC会自动根据PVC创建PV,这样就不会提前创建PV了。

输出:

1
2
3
NAME            PROVISIONER            AGE
nfs (default)   fuseim.pri/ifs         147m
slow            kubernetes.io/gce-pd   5d

default表示这个storageclass是默认的。

修改一个storageclass为默认:

1
 kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

安装 istio 和 kubeflow的一些组件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
export PATH=$PATH:"/usr/bin/kfctl"
export KF_NAME="my-kubeflow"
export BASE_DIR="/opt"
export KF_DIR=${BASE_DIR}/${KF_NAME}
export CONFIG_URI="https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_k8s_istio.v1.0.1.yaml"


kfctl init ${KF_DIR} --config=${CONFIG_URI} -V

cd ${KFAPP}
kfctl generate all -V

到这一步后会生成 app.yaml 和 kustomize文件夹

注意要 提前创建namespace kubeflow-anonymous

1
kubectl create namespace kubeflow-anonymous

然后就可以

1
kfctl apply all -V

但是我直接使用apply的时候seldon-core-operator这个组件装不上,所有我修改了app.yaml并且从kustomize文件夹删除了seldon-core-operator。然后执行apply命令。

安装valcano

见官网

修改valcano的 clustterrole

添加

1
2
3
4
5
6
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
修改tf-operator的cluster role

$ kubectl -n kubeflow edit clusterrole tf-job-operator

1
2
3
4
5
6
7
8
9
$ kubectl -n kubeflow edit clusterrole  tf-job-operator
...
...
- apiGroups:
  - scheduling.incubator.k8s.io
  resources:
  - podgroups
  verbs:
  - '*'
修改tf-operator,让其能使用gang-scheduling
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  Take tf-operator for example, enable gang-scheduling in tf-operator by setting true to --enable-gang-scheduling flag.
  
  $ kubectl -n kubeflow edit deployment tf-job-operator
...
spec:
      containers:
      - command:
        - /opt/kubeflow/tf-operator.v1beta2
        - --alsologtostderr
        - -v=1
        - --enable-gang-scheduling=true
参考网址:

https://www.kubeflow.org/docs/started/k8s/overview/

https://yylin1.github.io/2019/01/22/kubeflow-job-scheduling/

https://www.kubeflow.org/docs/use-cases/job-scheduling/