我的镜像没有被Kubernetes部署。

huangapple go评论76阅读模式
英文:

My image isn't being deployed by kubernetes

问题

我已经通过构建其Dockerfile创建了一个FastAPI程序的最小镜像。镜像名称是 "task1"。我正在尝试在本地使用Minikube和kubectl部署它,通过指定一个名为 "task1-deployment.yaml" 的文件,其结构如下:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: task1-deployment
  5. spec:
  6. replicas: 1
  7. selector:
  8. matchLabels:
  9. app: task1
  10. template:
  11. metadata:
  12. labels:
  13. app: task1
  14. spec:
  15. containers:
  16. - name: task1
  17. image: task1:latest
  18. imagePullPolicy: Never
  19. ports:
  20. - containerPort: 8080

每当我运行 "kubectl -f apply task1-deployment.yaml" 时,它显示一个成功的消息,但是当运行 "kubectl get deployment" 时,task1 不准备好,无法在 localhost:8080 访问。

其他官方拉取的镜像正常工作,我做错了什么?

注意:"imagePullPolicy" 不会改变任何内容。

英文:

I have made a minimal image of a fast-api program by building its Dockerfile. The imagename is task1. I'm trying to deploy it locally with minikube, kubectl by specifying a file named task1-deployment.yaml with the following structure:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: task1-deployment
  5. spec:
  6. replicas: 1
  7. selector:
  8. matchLabels:
  9. app: task1
  10. template:
  11. metadata:
  12. labels:
  13. app: task1
  14. spec:
  15. containers:
  16. - name: task1
  17. image: task1:latest
  18. imagePullPolicy: Never
  19. ports:
  20. - containerPort: 8080

Whenever I run kubectl -f apply task1-deployment.yaml it shows a successful message, yet when running kubectl get deployment, task1 isn't ready and can't be accessed at localhost:8080. <br>
The other official-pulled images work, what am I doing wrong?<br><br>

Note: "imagePullPolicy" doesn't change anything

答案1

得分: 2

将此作为答案发布而不是评论:

Minikube无法从您的计算机的Docker获取图像 - 您需要通过运行以下命令将其加载到Minikube集群中:

  1. $ minikube image load <image_name>
英文:

Posting this as an answer instead of a comment:

Minikube can't get images from your machine's docker - you need to load it into the minikube cluster by running the following command:

  1. $ minikube image load &lt;image_name&gt;

huangapple
  • 本文由 发表于 2023年5月26日 12:37:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76337708.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定