我对 kubernetes 和 tensorflow 都比较陌生,试图从这个链接( https://github.com/learnk8s/distributed-tensorflow-on-k8s)运行基本的 kubeflow 分布式张量流示例。我目前正在运行具有 2 个节点(1 个主节点和 1 个工作节点)的本地裸机 kubernetes 集群。当我在 minikube 中运行它时一切正常(按照文档),训练和服务都成功运行。但是在本地集群上运行作业给了我这个错误!
任何帮助,将不胜感激。
对于此设置,我为作业使用的 nfs-storage 创建了一个 pod。因为本地集群没有启用动态配置,所以我手动创建了持久卷(使用的文件已附加)。
Nfs pod 存储文件:
kind: Service
apiVersion: v1
metadata:
name: nfs-service
spec:
selector:
role: nfs-service
ports:
# Open the ports required by the NFS server
- name: nfs
port: 2049
- name: mountd
port: 20048
- name: rpcbind
port: 111
---
kind: Pod
apiVersion: v1
metadata:
name: nfs-server-pod
labels:
role: nfs-service
spec:
containers:
- name: nfs-server-container
image: cpuguy83/nfs-server
securityContext:
privileged: true
args:
# Pass the paths to share to the Docker image
- /exports
持久卷和 PVC 文件:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs
spec:
storageClassName: "standard"
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
nfs:
server: 10.96.72.11
path: "/"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nfs
spec:
accessModes:
- ReadWriteMany
storageClassName: "standard"
resources:
requests:
storage: 10Gi
TFJob 文件:
apiVersion: kubeflow.org/v1beta1
kind: TFJob
metadata:
name: tfjob1
spec:
replicaSpecs:
- replicas: 1
tfReplicaType: MASTER
template:
spec:
volumes:
- name: nfs-volume
persistentVolumeClaim:
claimName: nfs
containers:
- name: tensorflow
image: learnk8s/mnist:1.0.0
imagePullPolicy: IfNotPresent
args:
- --model_dir
- ./out/vars
- --export_dir
- ./out/models
volumeMounts:
- mountPath: /app/out
name: nfs-volume
restartPolicy: OnFailure
- replicas: 2
tfReplicaType: WORKER
template:
spec:
containers:
- name: tensorflow
image: learnk8s/mnist:1.0.0
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
args:
- --model_dir
- ./out/vars
- --export_dir
- ./out/models
volumeMounts:
- mountPath: /app/out
name: nfs-volume
restartPolicy: OnFailure
- replicas: 2
tfReplicaType: WORKER
template:
spec:
containers:
- name: tensorflow
image: learnk8s/mnist:1.0.0
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
- replicas: 1
tfReplicaType: PS
template:
spec:
volumes:
- name: nfs-volume
persistentVolumeClaim:
claimName: nfs
containers:
- name: tensorflow
image: learnk8s/mnist:1.0.0
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /app/out
name: nfs-volume
restartPolicy: OnFailure
当我运行作业时,它给了我这个错误
error: unable to recognize "kube/tfjob.yaml": no matches for kind "TFJob" in version "kubeflow.org/v1alpha1"
经过一番搜索,有人指出“v1alpha1”可能已经过时了,所以你应该使用“v1beta1”(奇怪的是,这个“v1alpha1”正在与我的 minikube 设置一起使用,所以我很困惑!)。但是,尽管创建了 tfjob,但我没有看到任何新容器启动,而不是 minikube 运行,新 pod 成功启动和完成。当我描述 Tfjob 时,我看到了这个错误
Type Reason Age From Message
---- ------ ---- ---- -------
Warning InvalidTFJobSpec 22s tf-operator Failed to marshal the object to TFJob; the spec is invalid: failed to marshal the object to TFJob"
由于唯一的区别是 nfs-storage,我认为我的手动设置可能有问题。如果我在某个地方搞砸了,请告诉我,因为我没有足够的背景!