无法访问Kubernetes中的绑定dns
我正在尝试使用microK8S在本地Kubernetes群集内安装DNS服务器,但无法访问DNS 此处显示部署脚本:无法访问Kubernetes中的绑定dns,kubernetes,dns,bind,microk8s,Kubernetes,Dns,Bind,Microk8s,我正在尝试使用microK8S在本地Kubernetes群集内安装DNS服务器,但无法访问DNS 此处显示部署脚本: --- kind: Deployment apiVersion: apps/v1 metadata: name: bind labels: app: bind spec: replicas: 1 selector: matchLabels: app: bind template: metadata: labels
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: bind
labels:
app: bind
spec:
replicas: 1
selector:
matchLabels:
app: bind
template:
metadata:
labels:
app: bind
spec:
containers:
- name: bind
image: sameersbn/bind
env:
- name: ROOT_PASSWORD
value: "toto"
volumeMounts:
- mountPath: /data
name: data
ports:
- containerPort: 53
protocol: UDP
- containerPort: 53
protocol: TCP
- containerPort: 10000
volumes:
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: bind-dns
labels:
name: bind-dns
spec:
type: ClusterIP
ports:
- name: dns
port: 53
targetPort: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
targetPort: 53
selector:
name: bind
使用ip公开服务
bind-dns LoadBalancer 10.152.183.144 <pending> 53/UDP,53/TCP 11m
但在容器外部它并没有
host www.google.com 10.152.183.144
;; connection timed out; no servers could be reached
怎么了?为什么无法访问服务器?服务资源规范选择器需要指定pod规范元数据标签。
因此,我认为您需要更改yaml文件的服务资源
apiVersion: v1
kind: Service
metadata:
name: bind-dns
labels:
name: bind-dns
spec:
type: ClusterIP
ports:
- name: dns
port: 53
targetPort: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
targetPort: 53
selector:
app: bind # changed
apiVersion: v1
kind: Service
metadata:
name: bind-dns
labels:
name: bind-dns
spec:
type: ClusterIP
ports:
- name: dns
port: 53
targetPort: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
targetPort: 53
selector:
app: bind # changed