Kubernetes pod错误:创建多个服务



我是Kubernetse的新手,所以很抱歉我的问题看起来很模糊。我尽量详细说明。我通过Kubernetse在谷歌云上有一个pod,里面有一个GPU。这个GPU负责处理一组任务,比如说对图像进行分类。为了做到这一点,我用kubernetes创建了一个服务。我的yaml文件的服务部分如下所示。此外,该服务的url将为http://model-server-service.default.svc.cluster.local,因为该服务的名称为moderl-server-service

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: model-server
name: model-server
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: model-server
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: model-server
spec:
containers:
- args:
- -t
- "120"
- -b
- "0.0.0.0"
- app:flask_app
command:
- gunicorn
env:
- name: ENV
value: staging
- name: GCP
value: "2"
image: gcr.io/my-production/my-model-server: myGitHash
imagePullPolicy: Always
name: model-server
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
resources:
limits:
nvidia.com/gpu: 1
ports:
- containerPort: 8000
protocol: TCP
volumeMounts:
- name: model-files
mountPath: /model-server/models
# These containers are run during pod initialization
initContainers:
- name: model-download
image: gcr.io/my-production/my-model-server: myGitHash
command:
- gsutil
- cp
- -r
- gs://my-staging-models/*
- /model-files/
volumeMounts:
- name: model-files
mountPath: "/model-files"
volumes:
- name: model-files
emptyDir: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
runAsUser: 0
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
labels:
app: model-server
name: model-server-service
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8000
selector:
app: model-server
sessionAffinity: None
type: ClusterIP

我的问题开始了。我正在创建一组新任务。对于这组新任务,我需要大量内存,所以我不想使用以前的服务。我想把它作为一项单独的新服务的一部分。具有以下urlhttp://model-server-heavy-service.default.svc.cluster.local的内容。我尝试创建一个新的yaml文件model-server-heavy.yaml。在这个新的yaml文件中,我将服务的名称从model-server-service更改为model-server-heavy-service。此外,我还将应用程序的名称和名称从model-server更改为model-sever-heavy。所以最后的yaml文件看起来就像我在这篇文章末尾放的一样。不幸的是,新的模型服务器不起作用,我在kubernetes上收到了关于新模型服务器的以下消息。

model-server-asdhjs-asd            1/1     Running            0          21m
model-server-heavy-xnshk   0/1     **CrashLoopBackOff**   8          21m

有人能告诉我我做错了什么吗?我的想法有什么替代方案?为什么我会收到第二个型号服务器的消息CrashLoopBackOff?我对第二个模型服务器做得不正确的地方是什么。

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: model-server-heavy
name: model-server-heavy
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: model-server-heavy
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: model-server-heavy
spec:
containers:
- args:
- -t
- "120"
- -b
- "0.0.0.0"
- app:flask_app
command:
- gunicorn
env:
- name: ENV
value: staging
- name: GCP
value: "2"
image: gcr.io/my-production/my-model-server:mgGitHash
imagePullPolicy: Always
name: model-server-heavy
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
resources:
limits:
nvidia.com/gpu: 1
ports:
- containerPort: 8000
protocol: TCP
volumeMounts:
- name: model-files
mountPath: /model-server-heavy/models
# These containers are run during pod initialization
initContainers:
- name: model-download
image: gcr.io/my-production/my-model-server:myGitHash
command:
- gsutil
- cp
- -r
- gs://my-staging-models/*
- /model-files/
volumeMounts:
- name: model-files
mountPath: "/model-files"
volumes:
- name: model-files
emptyDir: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
runAsUser: 0
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
labels:
app: model-server-heavy
name: model-server-heavy-service
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8000
selector:
app: model-server-heavy
sessionAffinity: None
type: ClusterIP

多亏了@dawid-kruk和@patrick-w,我不得不在model-sever-heavy.yaml中进行两次修改才能使其工作。

  1. 将装载路径从/model-server-heavy/models更改为/model-server/models

  2. model-sever-heavy.yaml文件的第38行中,我应该将名称从model-server-heavy更改为model-sever

我第一次尝试通过应用项目1来解决问题,但没有成功。然后我也试了第二个项目,它解决了。我需要同时设置1和2,以便服务器正常工作。我理解为什么我必须对第一项进行更改,但对第二项不确定。

相关内容

  • 没有找到相关文章

最新更新