Узлы не находят друг друга в кластере OrientDB Kubernetes - PullRequest
0 голосов
/ 18 октября 2018

Я пытаюсь построить кластер OrientDB, который состоит из 3 узлов с Kubernetes (в Minikube).Я использую StatefulSet со всеми конфигурациями кластера, смонтированными как тома.Проблема в том, что, когда я проверяю все журналы модулей, создается впечатление, что каждый модуль создает свой собственный кластер, а не объединяет один кластер.Что может быть причиной этого?

Конфигурация Hazelcast.xml выглядит следующим образом:

<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.3.xsd"
           xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <properties>
    <property name="hazelcast.discovery.enabled">true</property>
  </properties>
  <network>
    <join>
      <!-- deactivate normal discovery -->
      <multicast enabled="false"/>
      <tcp-ip enabled="false"/>
      <!-- activate the Kubernetes plugin -->
      <discovery-strategies>
        <discovery-strategy enabled="true"
                            class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
          <properties>
            <property name="service-dns">orientdbservice.default.svc.cluster.local</property>
            <property name="service-dns-timeout">10</property>
          </properties>
        </discovery-strategy>
      </discovery-strategies>
    </join>
  </network>
</hazelcast> 

Я использую имя DNS службы в качестве одного из подходов к использованию плагина Hazelcast с Kubernetes.

файл default-distrib-db-config.json:

{
    "autoDeploy": true,
    "hotAlignment": false, 
    "executionMode": "undefined",
    "readQuorum": 1,
    "writeQuorum": "majority",
    "readYourWrites": true,
    "newNodeStrategy": "static",
    "servers": {
        "*": "master"
    },
    "clusters":{
        "internal": {
        },
        "index": {
    },
        "*": { 
      "servers" : [ "<NEW_NODE" ] 
    } 
    }
}   

Часть слушателей из orientdb-server-config.xml:

<listeners>
    <listener protocol="binary" socket="default" port-range="2424-2430" ip-address="0.0.0.0"/>
    <listener protocol="http" socket="default" port-range="2480-2490" ip-address="0.0.0.0">
        <commands>
            <command implementation="com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent" pattern="GET|www GET|studio/ GET| GET|*.htm GET|*.html GET|*.xml GET|*.jpeg GET|*.jpg GET|*.png GET|*.gif GET|*.js GET|*.css GET|*.swf GET|*.ico GET|*.txt GET|*.otf GET|*.pjs GET|*.svg GET|*.json GET|*.woff GET|*.woff2 GET|*.ttf GET|*.svgz" stateful="false">
                <parameters>
                    <entry value="Cache-Control: no-cache, no-store, max-age=0, must-revalidate\r\nPragma: no-cache" name="http.cache:*.htm *.html"/>
                    <entry value="Cache-Control: max-age=120" name="http.cache:default"/>
                </parameters>
            </command>
        </commands>
        <parameters>
            <parameter value="utf-8" name="network.http.charset"/>
            <parameter value="true" name="network.http.jsonResponseError"/>
            <parameter value="Access-Control-Allow-Origin:*;Access-Control-Allow-Credentials: true" name="network.http.additionalResponseHeaders"/>
        </parameters>
    </listener>
</listeners>

StatefulSet Я определил:

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: orientdbservice
spec:
  serviceName: orientdbservice
  replicas: 3
  selector:
    matchLabels:
      service: orientdb
      type: container-deployment
  template:
    metadata:
      labels:
        service: orientdb
        type: container-deployment
    spec:
      containers:
      - name: orientdbservice
        image: orientdb:2.2.36
        command: ["/bin/sh","-c", "cp /configs/* /orientdb/config/ ; /orientdb/bin/server.sh -Ddistributed=true" ]
        env:
        - name: ORIENTDB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: orientdb-password
              key: password.txt
        ports:
        - containerPort: 2424
          name: port-binary
        - containerPort: 2480
          name: port-http
        - containerPort: 5701
          name: hazelcast
        volumeMounts:
        - name: config
          mountPath: /orientdb/config
        - name: orientdb-config-backups
          mountPath: /configs/backups.json
          subPath: backups.json
        - name: orientdb-config-events
          mountPath: /configs/events.json
          subPath: events.json
        - name: orientdb-config-distributed
          mountPath: /configs/default-distributed-db-config.json
          subPath: default-distributed-db-config.json
        - name: orientdb-config-hazelcast
          mountPath: /configs/hazelcast.xml
          subPath: hazelcast.xml
        - name: orientdb-config-server
          mountPath: /configs/orientdb-server-config.xml
          subPath: orientdb-server-config.xml
        - name: orientdb-config-client-logs
          mountPath: /configs/orientdb-client-log.properties
          subPath: orientdb-client-log.properties
        - name: orientdb-config-server-logs
          mountPath: /configs/orientdb-server-log.properties
          subPath: orientdb-server-log.properties
        - name: orientdb-config-plugin
          mountPath: /configs/pom.xml
          subPath: pom.xml
        - name: orientdb-databases
          mountPath: /orientdb/databases
        - name: orientdb-backup
          mountPath: /orientdb/backup
        - name: orientdb-data
          mountPath: /orientdb/bin/data
      volumes:
      - name: config
        emptyDir: {}
      - name: orientdb-config-backups
        configMap:
          name: orientdb-configmap-backups
      - name: orientdb-config-events
        configMap:
          name: orientdb-configmap-events
      - name: orientdb-config-distributed
        configMap:
          name: orientdb-configmap-distributed
      - name: orientdb-config-hazelcast
        configMap:
          name: orientdb-configmap-hazelcast
      - name: orientdb-config-server
        configMap:
          name: orientdb-configmap-server
      - name: orientdb-config-client-logs
        configMap:
          name: orientdb-configmap-client-logs
      - name: orientdb-config-server-logs
        configMap:
          name: orientdb-configmap-server-logs
      - name: orientdb-config-plugin
        configMap:
          name: orientdb-configmap-plugin
      - name: orientdb-data
        hostPath:
          path: /import_data
          type: Directory
  volumeClaimTemplates:
  - metadata:
      name: orientdb-databases
      labels:
        service: orientdb
        type: pv-claim
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 20Gi
  - metadata:
      name: orientdb-backup
      labels:
        service: orientdb
        type: pv-claim
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi

Сервис Headkess выглядит следующим образом:

kind: Service
apiVersion: v1
metadata:
  name: orientdbservice
  labels:
    service: orientdb
    type: headless-service
spec:
  type: ClusterIP
  clusterIP: None
  selector:
    service: orientdb
    type: container-deployment
  ports:
  - port: 2424
    name: port-binary
  - port: 2480
    name: port-http
  - name: hazelcast
    port: 5701

1 Ответ

0 голосов
/ 22 октября 2018

Чтобы участники Hazelcast могли открыть себя, вам также необходимо:

  • указать containerPort для Hazelcast (порт 5701)
  • создать службу Kubernetes для Hazelcast (порт)5701, в случае использования DNS Lookup Discovery, служба должна быть type: ClusterIP и clusterIP: None)

Более подробную информацию о конфигурации можно найти в следующих источниках:

...