Kubernates 分配多个端点

Kubernates 分配多个端点

我在 kubernates 上有以下配置:

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ include "e-lucene-eva.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "e-lucene-eva.name" . }}
    helm.sh/chart: {{ include "e-lucene-eva.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "e-lucene-eva.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "e-lucene-eva.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: evaptr
              containerPort: 8089
          resources:
            resources:
            limits:
              cpu: 150m
              memory: 1528Mi
            requests:
              cpu: 100m
              memory: 664Mi


apiVersion: v1
kind: Service
metadata:
  name: st-evabot-adm-backend-service
  namespace: st-evabot
spec:
  ports:
    - targetPort: bck-port
      port: 80
      protocol: TCP
  selector:
    app: evabot
    tier: backend

但是当我运行 kubectl get endpoints 时:

NAME                                       ENDPOINTS                                                    AGE
evabot-db-service                          191.255.54.169:27017                                         19h
evabot-lucene-service                      191.255.48.148:8089,191.255.54.169:8089,191.255.55.35:8089   13h

为什么我有 3 个 IP?而其他的只有 1 个?另一个问题是……这些 IP 用于与其他 pod 的连接吗?

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: null
  generation: 1
  labels:
    app.kubernetes.io/instance: st-evabot-evabot-lucene
    app.kubernetes.io/managed-by: Tiller
    app.kubernetes.io/name: e-lucene-eva
    helm.sh/chart: e-lucene-eva-0.1.1
  name: st-evabot-evabot-lucene-e-lucene-eva
  selfLink: /apis/extensions/v1beta1/namespaces/st-evabot/deployments/st-evabot-evabot-lucene-e-lucene-eva
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/instance: st-evabot-evabot-lucene
      app.kubernetes.io/name: e-lucene-eva
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/instance: st-evabot-evabot-lucene
        app.kubernetes.io/name: e-lucene-eva
    spec:
      containers:
      - image: registry-dgt.eni.com/eni/evabot-lucene:1.0.4
        imagePullPolicy: IfNotPresent
        name: e-lucene-eva
        ports:
        - containerPort: 8089
          name: evaptr
          protocol: TCP
        resources:
          limits:
            cpu: 150m
            memory: 1528Mi
          requests:
            cpu: 100m
            memory: 664Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status: {}



evabot-adm-ui-service                      ClusterIP   191.255.46.131   <none>        3031/TCP       21h       app=evabot,tier=frontend
evabot-lucene-service                      ClusterIP   191.255.46.28    <none>        8089/TCP       2h        app=evabot
st-evabot-adm-backend-service              NodePort    191.255.45.200   <none>        80:31971/TCP   8m        app=evabot,tier=backend
st-evabot-db-service                       ClusterIP   191.255.47.200   <none>        27017/TCP      31m       app=mongo-proxy
st-evabot-evabot-db-mongodb-replicaset     ClusterIP   None             <none>        27017/TCP      3d        app=mongodb-replicaset,release=st-evabot-evabot-db
st-evabot-fe-evabot-web-apache-webserver   ClusterIP   191.255.45.37    <none>        80/TCP         1d        app=apache-webserver,release=st-evabot-fe-evabot-web
tiller-deploy                              ClusterIP   191.255.44.63    <none>        44134/TCP      6d        app=helm,name=tiller

答案1

我无法通过提供的部署清单文件找到app=evabot标签tier=frontend,因此服务evabot-db-serviceevabot-lucene-service公开了不同的部署(Pod)。

但是,您可以轻松地从集群中检索与标签相关的所有组件的信息app=evabottier=frontend

kubectl get all -l app=evabot

kubectl get all -l tier=frontend

一般来说,Endpoint你的请求的最后一个要点是服务当与 Pod IP 地址建立连接时,将路由网络流量。它们可以由 Kubernetes 使用选择器自动发现或手动管理。

我假设evabot-lucene-service你示例中的服务可能已经创建了三个 Pod副本集,最终由其端点处理请求:

evabot-lucene 服务
191.255.48.148:8089,191.255.54.169:8089,191.255.55.35:8089

对于evabot-db-service服务来说,只有一个 Pod 代表 Endpoint。

evabot-db-服务 191.255.54.169:27017

如果有任何疑问或问题,请在此答案下方发表评论。

相关内容