【发布时间】:2022-08-14 11:11:47
【问题描述】:
我正在运行我的minikube 作为 docker 镜像。我正在尝试使用 Nodeport 向外界公开我的服务。
这是我的 yaml 文件。
apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-hello-world
labels:
app: docker-hello-world
spec:
selector:
matchLabels:
app: docker-hello-world
replicas: 3
template:
metadata:
labels:
app: docker-hello-world
spec:
containers:
- name: docker-hello-world
image: scottsbaldwin/docker-hello-world:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: docker-hello-world-svc
spec:
selector:
app: docker-hello-world
ports:
- port: 8088
targetPort: 80
type: NodePort
搜索了很多关于nodePort 我们需要节点 ip 才能访问服务。我可以使用访问我的服务minikube 服务 docker-hello-world-svc --url这给了我访问服务的网址http://127.0.0.1:52526但这里的端口号与 nodePort 不同。
我的服务运行成功。
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
docker-hello-world-svc NodePort 10.109.146.181 <none> 8088:30934/TCP 65m
我想使用 Nodeport 从集群外部访问我的服务,但我的节点没有任何外部 ip
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
minikube Ready control-plane 5h9m v1.24.3 192.168.49.2 <none> Ubuntu 20.04.4 LTS 5.10.104-linuxkit docker://20.10.17
已经读出我需要入口控制器来访问服务,但我想使用它来测试它节点端口.
任何解决方法,因此我只能使用节点端口在作为 docker 镜像运行的 minikube 内运行?
minikube 的状态不显示 kubectl
>>minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
-
看到那篇文章,大多数 cmets 都与获取 minikube 节点 ip 和使用 nodeid:nodeport 相关,但这里我使用的是 minikube docker 映像,所以我正在获取正在运行的节点的外部 ip .. 我用过。 minikube 服务 - - 提供 localhost:someport number 的 url .. minikube 没有向 Mac 平台的外部 ip 提供的 cmets 很少,
-
我在mac和linux之间遇到了一些问题,但我认为从逻辑上讲minikube ip应该将它路由到你的nodeport?你可以使用 cmd 远程登录到 pod 吗?
标签: kubernetes kubernetes-ingress kubectl minikube kubernetes-service