Kubernetes minikube,无法在公共IP范围上公开服务 [英] Kubernetes minikube, cannot expose service on public ip range

查看:295
本文介绍了Kubernetes minikube,无法在公共IP范围上公开服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在玩Minkube.

So I've been playing around with Minkube.

我设法部署了一个简单的python flask容器:

I've managed to deploy a simple python flask container:

PS C:\Users\Will> kubectl run test-flask-deploy --image 
192.168.1.201:5000/test_flask:1 
deployment "test-flask-deploy" created

然后,我还设法将部署作为服务公开:

I've also then managed to expose the deployment as a service:

PS C:\Users\Will> kubectl expose deployment/test-flask-deploy --
type="NodePort" --port 8080
service "test-flask-deploy" exposed

在仪表板中,我可以看到该服务具有群集IP: 10.0.0.132.

In the dashboard I can see that the service has a Cluster IP: 10.0.0.132.

我通过192.168.xxx.xxx地址访问仪表板,因此希望可以在该外部IP上公开该服务.

I access the dashboard on a 192.168.xxx.xxx address, so I'm hoping I can expose the service on that external IP.

你知道我该怎么做吗?

一个单独的但不太重要的问题:我已经将minikube与网络上的docker注册表进行了交谈.如果我部署映像(尚未将映像拉到minikube本地),则部署会失败,但是当我在minikube本地运行docker pull命令时,部署便会成功.因此minikube能够提取docker映像,但是当我部署可通过注册表访问但未在本地提取的映像时,它将失败.有什么想法吗?

A separate and slightly less important question: I've got minikube talking to a docker registry on my network. If i deploy an image (which has not yet been pulled local to the minikube) the deployment fails, yet when I run the docker pull command on minikube locally, the deployment then succeeds. So minikube is able to pull docker images, but when I deploy an image which is accessible via the registry, yet not pulled locally, it fails. Any thoughts?

响应评论的更多细节:

PS C:\Users\Will> kubectl describe pod test-flask-deploy
Name:           test-flask-deploy-1049547027-rgf7d
Namespace:      default
Node:           minikube/192.168.99.100
Start Time:     Sat, 07 Oct 2017 10:19:58 +0100
Labels:         pod-template-hash=1049547027
                run=test-flask-deploy
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"test-flask-deploy-1049547027","uid":"b06a14b8-ab40-11e7-9714-080...
Status:         Running
IP:             172.17.0.4
Created By:     ReplicaSet/test-flask-deploy-1049547027
Controlled By:  ReplicaSet/test-flask-deploy-1049547027
Containers:
  test-flask-deploy:
    Container ID:       docker://577e339ce680bc5dd9388293f1f1ea62be59a6acc25be22889310761222c760f
    Image:              192.168.1.201:5000/test_flask:1
    Image ID:           docker-pullable://192.168.1.201:5000/test_flask@sha256:d303ed635888394f69223cc0a66c5778444fd3636dfcde42295fd512be948898
    Port:               <none>
    State:              Running
      Started:          Sat, 07 Oct 2017 10:19:59 +0100
    Ready:              True
    Restart Count:      0
    Environment:        <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-5rrpm (ro)
Conditions:
  Type          Status
  Initialized   True
  Ready         True
  PodScheduled  True
Volumes:
  default-token-5rrpm:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-5rrpm
    Optional:   false
QoS Class:      BestEffort
Node-Selectors: <none>
Tolerations:    <none>
Events:         <none>

推荐答案

首先,检查分配给您的服务的节点端口:

First, check the nodeport that is assigned to your service:

$ kubectl get svc test-flask-deploy
NAME                CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
test-flask-deploy   10.0.0.76    <nodes>       8080:30341/TCP   4m

现在您应该可以在192.168.xxxx:30341或任何minikubeIP:nodeport上访问它.

Now you should be able to access it on 192.168.xxxx:30341 or whatever your minikubeIP:nodeport is.

这篇关于Kubernetes minikube,无法在公共IP范围上公开服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆