无法连接到192.168.99.101中的服务

时间:2019-01-07 17:44:06

标签: kubernetes

我是kubernetes的新手,需要您的帮助。 我按照page上的安装说明进行操作,一切正常。以下是安装后的一些信息:

~ > kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T19:44:10Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.4", GitCommit:"f49fa022dbe63faafd0da106ef7e05a29721d3f1", GitTreeState:"clean", BuildDate:"2018-12-14T06:59:37Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}

~ > kubectl cluster-info
Kubernetes master is running at https://192.168.99.101:8443

~ > minikube ip
192.168.99.101

然后,我尝试运行一个简单的hello world服务:

~ > minikube start
~ > kubectl get nodes
NAME       STATUS   ROLES    AGE   VERSION
minikube   Ready    <none>   18h   v1.12.4

~ > kubectl run hw --image=karthequian/helloworld --port=80
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/hw created

~ > kubectl get deployments
NAME   DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
hw     1         1         1            1           21s

~ > kubectl get rs
NAME           DESIRED   CURRENT   READY   AGE
hw-854c64787   1         1         1       71s

~ > kubectl get pods
NAME                 READY   STATUS    RESTARTS   AGE
hw-854c64787-8xhw6   1/1     Running   0          59s

~ > kubectl expose deployment hw --type=NodePort
service/hw exposed

~> kubectl get services
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
hw           NodePort    10.106.4.194   <none>        80:31269/TCP   6m23s
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        20h 

~ > minikube service hw
Opening kubernetes service default/hw in default browser...

最后一行之后,我得到以下输出: enter image description here

我做错了吗?有什么我没有配置好的吗?谢谢。

1 个答案:

答案 0 :(得分:1)

这是我解决此问题的方法。首先,我进入Docker-> Preferences-> Kubernetes并勾选“启用Kubernetes”。安装大约需要5分钟。

enter image description here

然后,我用minikube delete删除当前的迷你立方体并重复整个过程(minikube startkubectl run hw --image=karthequian/helloworld --port=80kubectl expose deployment hw --type=NodePortminikube service hw ),并且可以::。