我使用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-chart
和helm 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/
我不确定为什么会退出。
答案 0 :(得分:1)
问题是,Minikube实际上正在公共Docker映像存储库中查找并找到也称为hello-world
的东西。找不到我的docker镜像,因为minikube的“本地”对主机计算机的docker是 not 本地。 Minikube在内部运行自己的docker。
minikube cache add hello-world:latest
。imagePullPolicy: Never