我有 statefulset pod。当我进入其中一个 pod 并尝试 ping 它的主机名时。有用。但是,如果我尝试从当前容器 ping 其他 pod 的主机名,那么这些主机名不会得到解析。我也有无头服务。有人可以告诉我在集群级别或在服务或 statefulset 的 yaml 中需要做什么以使通信发生。一个工作示例或一些工作图表链接来尝试,会很有帮助。我可以通过那个。
服务:
apiVersion: v1
kind: Service
metadata:
name: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}"
labels:
app: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}"
{{ include "metadata.labels.standard" . | indent 4 }}
spec:
clusterIP: None
selector:
tier: backend
有状态集:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}-myapp1"
labels:
app: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}-myapp1"
tier: backend
spec:
replicas: 2
selector:
matchLabels:
app: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}-myapp1"
serviceName: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}"
template:
metadata:
labels:
app: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}-myapp1"
tier: backend
volumes:
- name: configmap-r
configMap:
name: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}-configmap"
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
containers:
- name: "{{ .Chart.Name }}-{{ .Chart.AppVersion | replace "." "" }}-myapp1"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: configmap-r
mountPath: /home/xyz/
豆荚:
pod/calico-kube-controllers-59fc8847c-vv9bt 1/1 Running 0 3h27m
pod/calico-node-4gktj 1/1 Running 0 3h27m
pod/coredns-5c98db65d4-tctgk 1/1 Running 13 63d
pod/coredns-5c98db65d4-v8gtv 1/1 Running 13 63d
pod/etcd-minikube 1/1 Running 2 63d
pod/kube-addon-manager-minikube 1/1 Running 2 63d
pod/kube-apiserver-minikube 1/1 Running 0 15d
pod/kube-controller-manager-minikube 1/1 Running 6 63d
pod/kube-proxy-qc9nx 1/1 Running 1 63d
pod/kube-scheduler-minikube 1/1 Running 6 63d
pod/storage-provisioner 1/1 Running 3 63d
pod/tiller-deploy-6b9c575bfc-z7dgs 1/1 Running 1 62d
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kube-dns ClusterIP xx.xx.xx.xx <none> 53/UDP,53/TCP,9153/TCP 63d
service/tiller-deploy ClusterIP xx.xx.xx.xx <none> 44134/TCP 62d
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/calico-node 1 1 1 1 1 beta.kubernetes.io/os=linux 3h27m
daemonset.apps/kube-proxy 1 1 1 1 1 beta.kubernetes.io/os=linux 63d
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/calico-kube-controllers 1/1 1 1 3h27m
deployment.apps/coredns 2/2 2 2 63d
deployment.apps/tiller-deploy 1/1 1 1 62d
NAME DESIRED CURRENT READY AGE
replicaset.apps/calico-kube-controllers-59fc8847c 1 1 1 3h27m
replicaset.apps/coredns-5c98db65d4 2 2 2 63d
replicaset.apps/tiller-deploy-6b9c575bfc 1 1 1 62d
`