kubernetes 没有为 elasticsearch 分配端点

问题描述 投票:0回答:1

我有一个带有关联服务的Elasticsearch部署。我的Web应用程序也在集群中运行,我希望它能够连接到Elastic。我的 Web 应用程序有一个端点,但我的弹性服务没有分配一个端点。弹性 Pod 正在运行并准备就绪。这是配置

apiVersion: v1
kind: Service
metadata:
  labels:
    io.kompose.service: elasticweb
  name: elasticweb
spec:
  ports:
    - name: "9200"
      port: 9200
      targetPort: 9200
  selector:
    io.kompose.service: elasticweb
  type: ClusterIP
status:
  loadBalancer: {}

apiVersion: apps/v1
kind: Deployment
metadata:
  name: elasticweb
  labels:
     app: elasticweb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: elasticweb
  template:
    metadata:
      labels:
        app: elasticweb
    spec:
      containers:
        - env:
            - name: ELASTIC_PASSWORD
              value: mybuttstinks4u!
            - name: ES_JAVA_OPTS
              value: -Xms6144m -Xmx6144m
            - name: bootstrap.memory_lock
              value: "false"
            - name: cluster.initial_master_nodes
              value: elasticweb
            - name: cluster.name
              value: docker-cluster
            - name: discovery.seed_hosts
              value: elasticweb
            - name: node.name
              value: elasticweb
          name: elasticweb
          image: "docker.elastic.co/elasticsearch/elasticsearch:7.17.9"
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9200
          resources:
            {}
          volumeMounts:
            - mountPath: /usr/share/elasticsearch/data
              name: elastic-pvc
      initContainers:
       - name: elastic-init
         image: busybox:1.35.0
         securityContext:
           privileged: true
           runAsUser: 0
         command: ["sh", "-c", "sysctl -w  vm.max_map_count=262500 net.ipv4.tcp_keepalive_time=300"]
      volumes:
        - name: elastic-pvc
          persistentVolumeClaim:
            claimName: elastic-pvc%

这里是弹性部署

Name:             elasticweb-d76798c9d-j4n7r
Namespace:        default
Priority:         0
Service Account:  default
Node:             docker-desktop/192.168.65.3
Start Time:       Fri, 05 Apr 2024 10:52:59 -0400
Labels:           app=elasticweb
                  pod-template-hash=d76798c9d
Annotations:      <none>
Status:           Running
IP:               10.1.0.209
IPs:
  IP:           10.1.0.209
Controlled By:  ReplicaSet/elasticweb-d76798c9d
Init Containers:
  elastic-init:
    Container ID:  docker://f3d49b71d201c231d537cbe61f67929bd46b37ac40a7e08c1e51fda11c1c0d06
    Image:         busybox:1.35.0
    Image ID:      docker-pullable://busybox@sha256:6792c0efc319952344d1847cce8e221a011466e63b6024333b9e39dd84b31a13
    Port:          <none>
    Host Port:     <none>
    Command:
      sh
      -c
      sysctl -w  vm.max_map_count=262500 net.ipv4.tcp_keepalive_time=300
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Fri, 05 Apr 2024 10:53:00 -0400
      Finished:     Fri, 05 Apr 2024 10:53:00 -0400
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-cjgnj (ro)
Containers:
  elasticweb:
    Container ID:   docker://60621a35050d1d81ecf8183181d329826b68074d6d6f03c9b843e59cdf49af8a
    Image:          docker.elastic.co/elasticsearch/elasticsearch:7.17.9
    Image ID:       docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:59b37f77bd8b015d5b60f75bebb22d06028f7f15036f9d3559d2b7c16ece74db
    Port:           9200/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 05 Apr 2024 10:53:01 -0400
    Ready:          True
    Restart Count:  0
    Environment:
      ELASTIC_PASSWORD:              mybuttstinks4u!
      ES_JAVA_OPTS:                  -Xms6144m -Xmx6144m
      bootstrap.memory_lock:         false
      cluster.initial_master_nodes:  elasticweb
      cluster.name:                  docker-cluster
      discovery.seed_hosts:          elasticweb
      node.name:                     elasticweb
    Mounts:
      /usr/share/elasticsearch/data from elastic-pvc (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-cjgnj (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True
  Initialized                 True
  Ready                       True
  ContainersReady             True
  PodScheduled                True
Volumes:
  elastic-pvc:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  elastic-pvc
    ReadOnly:   false
  kube-api-access-cjgnj:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  10m   default-scheduler  Successfully assigned default/elasticweb-d76798c9d-j4n7r to docker-desktop
  Normal  Pulled     10m   kubelet            Container image "busybox:1.35.0" already present on machine
  Normal  Created    10m   kubelet            Created container elastic-init
  Normal  Started    10m   kubelet            Started container elastic-init
  Normal  Pulled     10m   kubelet            Container image "docker.elastic.co/elasticsearch/elasticsearch:7.17.9" already present on machine
  Normal  Created    10m   kubelet            Created container elasticweb
  Normal  Started    10m   kubelet            Started container elasticweb

这里是服务

Name:              elasticweb
Namespace:         default
Labels:            io.kompose.service=elasticweb
Annotations:       <none>
Selector:          io.kompose.service=elasticweb
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.105.148.32
IPs:               10.105.148.32
Port:              9200  9200/TCP
TargetPort:        9200/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>

我不知道配置中缺少什么..

elasticsearch kubernetes
1个回答
0
投票

我发现我使用了错误的属性“app”。应该是“名称”切换为名称解决了问题

© www.soinside.com 2019 - 2024. All rights reserved.