我有一个名称 ==elasticsearch
和 serviceName ==的 Kubernetes PetSet es
。它确实创建了 pod,并且正如预期的那样,它们的名称类似于elasticsearch-0
和elasticsearch-1
。但是,DNS 似乎无法正常工作。elasticsearch-0.es
不解决(也不解决elasticsearch-0.default
,等等)。如果您查看生成的 srv 记录,它们似乎是随机的而不是可预测的:
# nslookup -type=srv elasticsearch
Server: 10.1.0.2
Address: 10.1.0.2#53
elasticsearch.default.svc.cluster.local service = 10 100 0 9627d60e.elasticsearch.default.svc.cluster.local.
有人有想法么?
细节
这是实际的 PetSet 和服务定义:
---
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
labels:
app: elasticsearch
spec:
ports:
- name: rest
port: 9200
- name: native
port: 9300
clusterIP: None
selector:
app: elasticsearch
---
apiVersion: apps/v1alpha1
kind: PetSet
metadata:
name: elasticsearch
spec:
serviceName: "es"
replicas: 2
template:
metadata:
labels:
app: elasticsearch
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
terminationGracePeriodSeconds: 0
containers:
- name: elasticsearch
image: 672129611065.dkr.ecr.us-west-2.amazonaws.com/elasticsearch:v1
ports:
- containerPort: 9200
- containerPort: 9300
volumeMounts:
- name: es-data
mountPath: /usr/share/elasticsearch/data
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: ES_CLUSTER_NAME
value: EsEvents
volumeClaimTemplates:
- metadata:
name: es-data
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Gi