为什么我无法访问此头盔图表定义的应用程序? 在Minikube中

问题描述

我使用helm create helloworld-chart使用我创建的本地docker映像创建应用程序。我认为问题是我的端口全部搞砸了。

DOCKER零件
--------------------------

Docker File

FROM busybox
ADD index.html /www/index.html
EXPOSE 8008
CMD httpd -p 8008 -h /www; tail -f /dev/null

(我的index.html所在的目录中也有一个Dockerfile文件)

创建Docker映像(并在本地发布)

docker build -t hello-world .

然后我用docker run -p 8080:8008 hello-world运行了此文件,并验证了我 am 能够从localhost:8080到达它。 (然后我停止了该docker容器)

我还使用docker image ls验证了该映像在本地docker中并获得了输出:

REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
hello-world                            latest              8640a285e98e        20 minutes ago      1.23MB

头盔件
--------------------------

通过helm create helloworld-chart创建了头盔图表。

编辑文件:

values.yaml

# ...elided because left the same as default...

image:
  repository: hello-world
  tag: latest
  pullPolicy: IfNotPresent

# ...elided because left the same as default...

service:
  name: hello-world
  type: NodePort # Chose this because MiniKube doesn't have LoadBalancer installed
  externalPort: 30007
  internalPort: 8008
  port: 80

service.yaml

# ...elided because left the same as default...

spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort:  {{ .Values.service.internalPort }}
      nodePort:  {{ .Values.service.externalPort }}

deployment.yaml

# ...elided because left the same as default...

spec:

  # ...elided because left the same as default...

  containers:
    ports:
      - name: http
        containerPort:  {{ .Values.service.internalPort }}
        protocol:  TCP

我用helm lint helloworld-charthelm template ./helloworld-chart验证了这个“看似”正确

HELM AND MINIKUBE命令
--------------------------

# Packaging my helm
helm package helloworld-chart

# Installing into Kuberneters (Minikube)
helm install helloworld helloworld-chart-0.1.0.tgz

# Getting an external IP
minikube service helloworld-helloworld-chart

当我这样做时,它会给我一个像http://172.23.13.145:30007这样的外部ip,并在浏览器中打开,但只是说无法访问该站点。我错了什么?

更新/更多信息 ---------------------------------------

当我检查豆荚时,它处于CrashLoopBackOff状态。但是,我在日志中什么也没看到:

kubectl logs -f helloworld-helloworld-chart-6c886d885b-grfbc

日志:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message,Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client,which sent it
    to your terminal.

To try something more ambitious,you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images,automate workflows,and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas,visit:
 https://docs.docker.com/get-started/

我不确定为什么会退出。

解决方法

问题是,Minikube实际上正在公共Docker映像存储库中查找并找到也称为hello-world的东西。找不到我的docker镜像,因为minikube的“本地”对主机计算机的docker是 not 本地。 Minikube在内部运行自己的docker。

  1. 您必须将图像添加到minikube的本地仓库:minikube cache add hello-world:latest
  2. 您需要更改拉出策略:imagePullPolicy: Never

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...