如何使用 minikube 的 DNS?
How do I use minikube's DNS?
如何使用 minikube(集群)的 DNS?我想接收与所选无头服务的所有 pods 关联的所有 IP 地址?我不想把它暴露在集群之外。我目前正在创建后端层。
如以下答案所述:
„代替 return 单个 DNS A 记录,DNS 服务器将为该服务 return 多个 A 记录,每个记录指向单个 pod 的 IP在那一刻支持服务。”
这样后端层的pods就可以互相通信了
我无法使用挖掘命令。它没有安装在 minikube 中。最终我该如何安装它?没有可用的apt。
我希望这能更准确地解释我想要实现的目标。
如图kubernetes/minikube
issue 4397
Containers don't have an IP address by default.
You'll want to use minikube service
or minikube tunnel
to get endpoint information.
参见“hello-minikube/ Create a service”:
By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster.
To make the hello-node
Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.
Expose the Pod to the public internet using the kubectl expose
command:
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
The --type=LoadBalancer
flag indicates that you want to expose your Service outside of the cluster.
View the Service you just created:
kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-node LoadBalancer 10.108.144.78 <pending> 8080:30369/TCP 21s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP
On Minikube, the LoadBalancer type makes the Service accessible through the minikube service
command.
Run the following command:
minikube service hello-node
您提到您想要接收与所选服务名称的 pods 关联的 IP 地址,以测试无头服务如何工作。
仅出于测试目的,您可以使用端口转发。您可以将流量从本地机器转发到集群中的 dns pod。为此,您需要 运行:
kubectl port-forward svc/kube-dns -n kube-system 5353:53
它会在您的主机上公开 kubs-dns 服务。那么你所需要的就是使用 dig
命令(或替代)来查询 dns 服务器。
dig @127.0.0.1 -p 5353 +tcp +short <service>.<namespace>.svc.cluster.local
您还可以从集群内部测试您的 dns,例如通过 运行使用交互式 shell:
创建一个广告连播
kubectl run --image tutum/dnsutils dns -it --rm -- bash
root@dns:/# dig +search <service>
让我知道它有帮助。
如何使用 minikube(集群)的 DNS?我想接收与所选无头服务的所有 pods 关联的所有 IP 地址?我不想把它暴露在集群之外。我目前正在创建后端层。
如以下答案所述:
„代替 return 单个 DNS A 记录,DNS 服务器将为该服务 return 多个 A 记录,每个记录指向单个 pod 的 IP在那一刻支持服务。”
这样后端层的pods就可以互相通信了
我无法使用挖掘命令。它没有安装在 minikube 中。最终我该如何安装它?没有可用的apt。
我希望这能更准确地解释我想要实现的目标。
如图kubernetes/minikube
issue 4397
Containers don't have an IP address by default.
You'll want to useminikube service
orminikube tunnel
to get endpoint information.
参见“hello-minikube/ Create a service”:
By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster.
To make the
hello-node
Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.Expose the Pod to the public internet using the
kubectl expose
command:kubectl expose deployment hello-node --type=LoadBalancer --port=8080
The
--type=LoadBalancer
flag indicates that you want to expose your Service outside of the cluster.View the Service you just created:
kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-node LoadBalancer 10.108.144.78 <pending> 8080:30369/TCP 21s kubernetes ClusterIP 10.96.0.1 <none> 443/TCP
On Minikube, the LoadBalancer type makes the Service accessible through the
minikube service
command.Run the following command:
minikube service hello-node
您提到您想要接收与所选服务名称的 pods 关联的 IP 地址,以测试无头服务如何工作。
仅出于测试目的,您可以使用端口转发。您可以将流量从本地机器转发到集群中的 dns pod。为此,您需要 运行:
kubectl port-forward svc/kube-dns -n kube-system 5353:53
它会在您的主机上公开 kubs-dns 服务。那么你所需要的就是使用 dig
命令(或替代)来查询 dns 服务器。
dig @127.0.0.1 -p 5353 +tcp +short <service>.<namespace>.svc.cluster.local
您还可以从集群内部测试您的 dns,例如通过 运行使用交互式 shell:
创建一个广告连播kubectl run --image tutum/dnsutils dns -it --rm -- bash
root@dns:/# dig +search <service>
让我知道它有帮助。