溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何部署Ubuntu20.04 + k8s 1.21.0開發(fā)環(huán)境

發(fā)布時(shí)間:2021-12-18 11:51:35 來源:億速云 閱讀:405 作者:小新 欄目:大數(shù)據(jù)

這篇文章主要為大家展示了“如何部署Ubuntu20.04 + k8s 1.21.0開發(fā)環(huán)境”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“如何部署Ubuntu20.04 + k8s 1.21.0開發(fā)環(huán)境”這篇文章吧。

Kubeflow 部署(使用 kfctl_k8s_istio)

安裝 Kubeflow的一些指南(使用 kfctl_k8s_istio 配置部署到已有的Kubernetes集群中)。該配置清單創(chuàng)建Kubeflow的核心部件部署,但不包括外部依賴,可以根據(jù)您的環(huán)境需要進(jìn)行優(yōu)化。KubeFlow 1.2.0部署到Ubuntu20.04和k8s 1.21.0,其它平臺(tái)可能有些變化。

該Kubeflow deployment要求 StorageClass 支持 dynamic volume provisioner。確認(rèn)缺省的StorageClass的 provisioner 域的設(shè)置。如果換沒有 provisioner, 確保配置了 volume provisioning,按照下面的描述在 Kubernetes cluster 進(jìn)行設(shè)置(參考 below)。

使用 kfctl_k8s_istio.v1.2.0.yaml 配置安裝,需要考慮下面的選項(xiàng):

  • Disabling istio installation - 如果 Kubernetes cluster 已有 Istio 安裝,可以選擇不安裝Istio,通過一移除配置文件kfctl_k8s_istio.v1.0.2.yaml中的 istio-crdsistio-install 參數(shù)。

準(zhǔn)備環(huán)境

下載 kfctl 的 Kubeflow CLI 工具,然后手動(dòng)設(shè)置環(huán)境變量:

  • 下載kfctl v1.2.0 發(fā)布版本,到 Kubeflow releases page。

wget https://github.com/kubeflow/kfctl/releases/download/v1.2.0/kfctl_v1.2.0-0-gbc038f9_linux.tar.gz

tar -vxf kfctl_v1.2.0-0-gbc038f9_linux.tar.gz

sudo cp kfctl /usr/bin/
  • 創(chuàng)建環(huán)境變量,簡(jiǎn)化部署過程:

# The following command is optional. It adds the kfctl binary to your path.# If you don't add kfctl to your path, you must use the full path# each time you run kfctl.# Use only alphanumeric characters or - in the directory name.export PATH=$PATH:"<path-to-kfctl>"##實(shí)際如下:##export PATH=$PATH:"/home/supermap/openthings/kubeflow"# Set KF_NAME to the name of your Kubeflow deployment. You also use this# value as directory name when creating your configuration directory.# For example, your deployment name can be 'my-kubeflow' or 'kf-test'.export KF_NAME=<your choice of name for the Kubeflow deployment>##實(shí)際如下:##export KF_NAME="kubeflow"# Set the path to the base directory where you want to store one or more # Kubeflow deployments. For example, /opt/.# Then set the Kubeflow application directory for this deployment.export BASE_DIR=<path to a base directory>export KF_DIR=${BASE_DIR}/${KF_NAME}##實(shí)際如下:##export BASE_DIR="/home/supermap/openthings/"##export KF_DIR=${BASE_DIR}/${KF_NAME}# Set the configuration file to use when deploying Kubeflow.# The following configuration installs Istio by default. Comment out # the Istio components in the config file to skip Istio installation. # See https://github.com/kubeflow/kubeflow/pull/3663export CONFIG_URI="https://raw.githubusercontent.com/kubeflow/manifests/v1.2-branch/kfdef/kfctl_k8s_istio.v1.2.0.yaml"##實(shí)際如下:##export CONFIG_URI=${BASE_DIR}/${KF_NAME}/kfctl_k8s_istio.v1.2.0.yaml

注意:

  • ${KF_NAME} -  Kubeflow 部署的名稱。如果要定制部署的 deployment name,通過該參數(shù)指定。例如, my-kubeflowkf-test。該 KF_NAME 必須小寫字母或者 ‘-', 開始和結(jié)束必須為字母。該變量不能超過 25 個(gè)字符。只能包含名稱,不能包含目錄路徑。同時(shí)將作為創(chuàng)建目錄的名稱,用于保存 Kubeflow configurations,即Kubeflow application directory。

  • ${KF_DIR} -  Kubeflow application directory的全路徑。

  • ${CONFIG_URI} -該 GitHub address,位于 https://raw.githubusercontent.com/kubeflow/manifests/v1.2-branch/kfdef/kfctl_k8s_istio.v1.2.0.yaml。當(dāng)運(yùn)行kfctl applykfctl build (see the next step), kfctl 創(chuàng)建一個(gè) YAML 文件的本地版本,可以進(jìn)一步定制化。

??注意:

  • 運(yùn)行kfctl build或apply -V -f xxx時(shí),出現(xiàn)manifest下載不成功,可以將其下載下來,然后修改kfctl_k8s_istio.v1.2.0.yaml的下面內(nèi)容,將manifest指向本地路徑。如下:

  repos:
  - name: manifests
    uri: /home/supermap/openthings/kubeflow/v1.2.0.tar.gz
  version: v1.2-branch

設(shè)置和部署 Kubeflow

使用缺省設(shè)置來設(shè)置和部署 Kubeflow using the default settings,運(yùn)行 kfctl apply 如下:

mkdir -p ${KF_DIR}
cd ${KF_DIR}
kfctl apply -V -f ${CONFIG_URI}

檢查 resources deployed in namespace kubeflow:

kubectl -n kubeflow get all

可選,設(shè)置以后部署的配置參數(shù):

在部署 Kubeflow時(shí),如果需要定制安裝參數(shù),可以編輯該配置文件,然后運(yùn)行 Kubeflow的部署命令即可:

  1. 運(yùn)行 kfctl build 命令設(shè)置安裝參數(shù):

    mkdir -p ${KF_DIR}
    cd ${KF_DIR}
    kfctl build -V -f ${CONFIG_URI}


  2. 編輯配置文件,描述如上 customizing your Kubeflow deployment。

  3. 設(shè)置環(huán)境變量指向本地的配置文件:

    export CONFIG_FILE=${KF_DIR}/kfctl_k8s_istio.v1.2.0.yaml


  4. 運(yùn)行 kfctl apply 目錄實(shí)施 Kubeflow 部署:

    kfctl apply -V -f ${CONFIG_FILE}


出現(xiàn)錯(cuò)誤:

2021/04/28 10:24:44 absolute path error in '/home/supermap/openthings/kubeflow/.cache/manifests/namespaces/base' : evalsymlink failure on '/home/supermap/openthings/kubeflow/.cache/manifests/namespaces/base' : lstat /home/supermap/openthings/kubeflow/.cache/manifests/namespaces: no such file or directory
ERRO[0000] Error evaluating kustomization manifest for namespaces: accumulating resources: accumulating resources from '../../.cache/manifests/namespaces/base': open /home/supermap/openthings/kubeflow/.cache/manifests/namespaces/base: no such file or directory  filename="kustomize/kustomize.go:155"
Error: failed to apply:  (kubeflow.error): Code 500 with message: kfApp Apply failed for kustomize:  (kubeflow.error): Code 500 with message: error evaluating kustomization manifest for namespaces: accumulating resources: accumulating resources from '../../.cache/manifests/namespaces/base': open /home/supermap/openthings/kubeflow/.cache/manifests/namespaces/base: no such file or directory
  • 查看.cache目錄,發(fā)現(xiàn)manifest位于 ~/openthings/kubeflow/.cache/manifests/manifests-1.2.0 目錄下,而不是上面的manifests目錄。

  • 將manifests-1.2.0下的所有文件移到上一級(jí)即manifest目錄下,再次運(yùn)行kfctl apply。如下:

cd manifests-1.2.0
mv -r * ../
  • 但是運(yùn)行kfctl apply發(fā)現(xiàn)會(huì)將.cache目錄刪除,導(dǎo)致上面的復(fù)制方法失效。

  • 直接修改配置文件,修改所有自定義資源的路徑,改完后的配置文件如下:

apiVersion: kfdef.apps.kubeflow.org/v1
kind: KfDef
metadata:
  creationTimestamp: null
  namespace: kubeflow
spec:
  applications:
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/namespaces/base
    name: namespaces
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/application/v3
    name: application
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/istio-1-3-1-stack
    name: istio-stack
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/cluster-local-gateway-1-3-1
    name: cluster-local-gateway
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/istio/istio/base
    name: istio
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/cert-manager-crds
    name: cert-manager-crds
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/cert-manager-kube-system-resources
    name: cert-manager-kube-system-resources
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/add-anonymous-user-filter
    name: add-anonymous-user-filter
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/metacontroller/base
    name: metacontroller
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/admission-webhook/bootstrap/overlays/application
    name: bootstrap
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/spark-operator
    name: spark-operator
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes
    name: kubeflow-apps
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/knative/installs/generic
    name: knative
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/kfserving/installs/generic
    name: kfserving
  - kustomizeConfig:
      repoRef:
        name: manifests
        path: manifests-1.2.0/stacks/kubernetes/application/spartakus
    name: spartakus
  repos:
  - name: manifests
    uri: /home/supermap/openthings/kubeflow/v1.2.0.tar.gz
  version: v1.2-branch
status: {}
  • 刪除kustomize目錄,重新運(yùn)行kfctl build和kfctl apply.

KubeFlow的鏡像較多,完全啟動(dòng)需要比較長(zhǎng)的時(shí)間,需要耐心等待。

過段時(shí)間看,有些pod已經(jīng)啟動(dòng)起來了,主界面已經(jīng)可以訪問了。

查看狀態(tài),有些鏡像和服務(wù)有問題,包括鏡像下載、存儲(chǔ)卷設(shè)置等,留待后續(xù)解決。

(base) supermap@xriver02:~$ kubectl get pod -n kubeflow
NAME                                                     READY   STATUS             RESTARTS   AGE
admission-webhook-bootstrap-stateful-set-0               0/1     ImagePullBackOff   0          36h
admission-webhook-deployment-5cd7dc96f5-l9rxl            1/1     Running            0          36h
application-controller-stateful-set-0                    0/1     ImagePullBackOff   0          36h
argo-ui-657cf69ff5-kn966                                 1/1     Running            0          36h
cache-deployer-deployment-5f4979f45-q6psq                1/2     ImagePullBackOff   0          36h
cache-server-7859fd67f5-kx8zm                            0/2     Init:0/1           0          36h
centraldashboard-86744cbb7b-44rbc                        1/1     Running            0          36h
jupyter-web-app-deployment-8486d5ffff-9czzl              1/1     Running            0          36h
katib-controller-7fcc95676b-tsbzx                        1/1     Running            1          36h
katib-db-manager-67867f5498-jzrgh                        0/1     Running            442        36h
katib-mysql-6b5d848bf5-gs95h                             0/1     Pending            0          36h
katib-ui-65dc4cf6f5-pqj5p                                1/1     Running            0          36h
kfserving-controller-manager-0                           1/2     ImagePullBackOff   0          36h
kubeflow-pipelines-profile-controller-797fb44db9-vznlv   1/1     Running            0          36h
metacontroller-0                                         1/1     Running            0          36h
metadata-db-c65f4bc75-m2ggv                              0/1     Pending            0          36h
metadata-envoy-deployment-67bd5954c-jl7pn                1/1     Running            0          36h
metadata-grpc-deployment-577c67c96f-29dwx                0/1     CrashLoopBackOff   433        36h
metadata-writer-756dbdd478-tlrpw                         2/2     Running            325        36h
minio-54d995c97b-jrmqq                                   0/1     Pending            0          36h
ml-pipeline-8d6749d9c-drv2h                              1/2     CrashLoopBackOff   662        36h
ml-pipeline-persistenceagent-d984c9585-mhstn             2/2     Running            0          36h
ml-pipeline-scheduledworkflow-5ccf4c9fcc-wqg4d           2/2     Running            0          36h
ml-pipeline-ui-8ccbf585c-77krb                           2/2     Running            0          36h
ml-pipeline-viewer-crd-56c68f6c85-bssgc                  1/2     ImagePullBackOff   0          36h
ml-pipeline-visualizationserver-7446b96877-ffs7b         2/2     Running            0          36h
mpi-operator-d5bfb8489-75m6b                             1/1     Running            0          36h
mxnet-operator-7576d697d6-jwks8                          1/1     Running            0          36h
mysql-74f8f99bc8-ndzqg                                   0/2     Pending            0          36h
notebook-controller-deployment-dd4c74b47-k9fng           0/1     ImagePullBackOff   0          36h
profiles-deployment-65f54cb5c4-9xtws                     0/2     ImagePullBackOff   0          36h
pytorch-operator-847c8d55d8-x6l4t                        0/1     ImagePullBackOff   0          36h
seldon-controller-manager-6bf8b45656-d7rvf               1/1     Running            0          36h
spark-operatorsparkoperator-fdfbfd99-cst9l               0/1     ImagePullBackOff   0          36h
spartakus-volunteer-558f8bfd47-tcvpn                     1/1     Running            0          36h
tf-job-operator-58477797f8-wr79t                         1/1     Running            0          36h
workflow-controller-64fd7cffc5-m6gkc                     1/1     Running            0          36h

訪問 Kubeflow 用戶界面 (UI)

Kubeflow 部署完成后,Kubeflow Dashboard 的訪問通過服務(wù) istio-ingressgateway 來獲取。loadbalancer在環(huán)境中不可用,NodePort 或 Port forwarding 可以用于訪問 Kubeflow Dashboard,參考 Ingress Gateway guide 或者:

  • 為私有Kubernetes集群創(chuàng)建LoadBalancer服務(wù)

  • Kubernetes dashboard 通過 Ingress 提供HTTPS訪問

  • Kubernetes負(fù)載均衡器-Nginx ingress安裝

刪除 Kubeflow

運(yùn)行下面的命令刪除部署并回收資源:

cd ${KF_DIR}# If you want to delete all the resources, run:kfctl delete -f ${CONFIG_FILE}

理解部署過程

 kfctl 部署過程包含下面幾個(gè)命令:

  • kfctl build - (可選) 創(chuàng)建配置文件,只在需要自行修改配置參數(shù)時(shí)才需要在 kfctl apply之前運(yùn)行 kfctl build。

  • kfctl apply - 創(chuàng)建或更新資源。

  • kfctl delete - 刪除資源。

應(yīng)用的布局

您的 Kubeflow 應(yīng)用目錄 ${KF_DIR} 包含下面的文件和目錄:

  • ${CONFIG_FILE} 是一個(gè) YAML 文件定義了kubeflow部署的參數(shù):

    • 該文件是 GitHub-based configuration YAML 文件的副本,位于: https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_k8s_istio.v1.0.2.yaml,如果不能成功部署,需要先上github將其下載保存,然后修改URI指向到本地文件。

    • 當(dāng)運(yùn)行 kfctl applykfctl build,kfctl 創(chuàng)建配置文件的本地副本 ${CONFIG_FILE}, 然后可以對(duì)其編輯、客制化。

  • kustomize 是一個(gè)目錄,包含 Kubeflow applications應(yīng)用的定制化包。參考: how Kubeflow uses kustomize。

    • 該目錄在運(yùn)行 kfctl buildkfctl apply時(shí)創(chuàng)建出來。

    • 可以通過修改目錄中的manifests來定制 Kubernetes resources ,然后重新運(yùn)行 kfctl apply 進(jìn)行部署和更新。

建議將${KF_DIR} 目錄中的內(nèi)容納入版本管理系統(tǒng)。

Provisioning of Persistent Volumes in Kubernetes

如果已經(jīng)有 dynamic volume provisioner,可以跳過本步驟

問題解決

Persistent Volume Claims 處于 Pending 狀態(tài)

檢查PersistentVolumeClaims 是否 Bound 到 PersistentVolumes,如下:

kubectl -n kubeflow get pvc

如果PersistentVolumeClaims (PVCs) 在 Pending 狀態(tài),部署后沒有bound 到 PersistentVolumes (PVs),就需要手動(dòng)為每一個(gè)PVC創(chuàng)建PV,或者安裝 dynamic volume provisioning 來按需創(chuàng)建PVs ,以及刪除存在的PVCs然后重新部署 Kubeflow。

以上是“如何部署Ubuntu20.04 + k8s 1.21.0開發(fā)環(huán)境”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI