我在Kubernetes集群(ubuntu 16.04)上创建了一个服务(grpc-service),但找不到它的dns主机名
作为辅助节点,我的pod也不会显示在nslookup上(它与busybox一起使用)
kubectl exec -ti server-pod -- nslookup kubernetes.default
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"nslookup\": executable file not found in $PATH": unknown
期望类似以下内容的东西
grpc-service.<namespace>.svc.<cluster-domain> which is usually
grpc-service.default.svc.cluster.local
但找不到它,也无法ping /卷曲 (curl -I grpc-service)
答案 0 :(得分:0)
@Tanmay Shrivastava
clusterIP: None
However, you can use headless service, use statefulset
apiVersion: v1
kind: Service
metadata:
name: httpd-service
labels:
app: httpd
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: httpd
检查此链接:https://supergiant.io/blog/creating-stateful-apps-with-kubernetes-statefulsets/
答案 1 :(得分:0)
以下面为例。确保使用正确的标签/选择器。 并使用busybox版本<= busybox:1.28.4进行测试。使用较新版本的dns无法正常工作。
$client->request('GET', 'http://localhost:8001/api/tests')
检查:
apiVersion: v1
kind: Pod
metadata:
name: busybox-pod
labels:
app: busybox
spec:
containers:
- image: busybox:1.28.4
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: busybox
restartPolicy: Always
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
spec:
hostNetwork: true
containers:
- name: client-pod
image: nginx
---
apiVersion: v1
kind: Service
metadata:
name: server
labels:
app: nginx
spec:
clusterIP: None
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
app: nginx
---