Как синхронизировать обслуживание K8s с Консульским кластером, который находится за пределами K8s? - PullRequest
1 голос
/ 27 мая 2019

Из документа cons-k8s Серверный кластер Consul может работать как внутри, так и вне кластера Kubernetes.Кластер серверов Consul не обязательно должен работать на той же машине или на той же платформе, что и процесс синхронизации.Процесс синхронизации должен быть сконфигурирован с адресом кластера Consul, а также любой дополнительной информацией доступа, такой как токены ACL.

Консольный кластер, который я пытаюсь синхронизировать, вне k8sкластер , основываясь на этом документе, я должен передать адрес в консольный кластер для процесса синхронизации. Однако диаграмма управления для установки процесса синхронизации не содержит никакого значения для настройки IP-адреса кластера консула.

syncCatalog: 

  # True if you want to enable the catalog sync. "-" for default. 

  enabled: false 

  image: null 

  default: true # true will sync by default, otherwise requires annotation 



  # toConsul and toK8S control whether syncing is enabled to Consul or K8S 

  # as a destination. If both of these are disabled, the sync will do nothing. 

  toConsul: true 

  toK8S: true 



  # k8sPrefix is the service prefix to prepend to services before registering 

  # with Kubernetes. For example "consul-" will register all services 

  # prepended with "consul-". (Consul -> Kubernetes sync) 

  k8sPrefix: null 



  # consulPrefix is the service prefix which preprends itself 

  # to Kubernetes services registered within Consul 

  # For example, "k8s-" will register all services peprended with "k8s-". 

  # (Kubernetes -> Consul sync) 

  consulPrefix: null 



  # k8sTag is an optional tag that is applied to all of the Kubernetes services 

  # that are synced into Consul. If nothing is set, defaults to "k8s". 

  # (Kubernetes -> Consul sync) 

  k8sTag: null 



  # syncClusterIPServices syncs services of the ClusterIP type, which may 

  # or may not be broadly accessible depending on your Kubernetes cluster. 

  # Set this to false to skip syncing ClusterIP services. 

  syncClusterIPServices: true 



  # nodePortSyncType configures the type of syncing that happens for NodePort 

  # services. The valid options are: ExternalOnly, InternalOnly, ExternalFirst. 

  # - ExternalOnly will only use a node's ExternalIP address for the sync 

  # - InternalOnly use's the node's InternalIP address 

  # - ExternalFirst will preferentially use the node's ExternalIP address, but 

  #   if it doesn't exist, it will use the node's InternalIP address instead. 

  nodePortSyncType: ExternalFirst 



  # aclSyncToken refers to a Kubernetes secret that you have created that contains 

  # an ACL token for your Consul cluster which allows the sync process the correct 

  # permissions. This is only needed if ACLs are enabled on the Consul cluster. 

  aclSyncToken: 

    secretName: null 

    secretKey: null 



  # nodeSelector labels for syncCatalog pod assignment, formatted as a muli-line string. 

  # ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector 

  # Example: 

  # nodeSelector: | 

  #   beta.kubernetes.io/arch: amd64 

  nodeSelector: null

Итак, как я могу установить IP-адрес консула консула для процесса синхронизации?

1 Ответ

1 голос
/ 27 мая 2019

Похоже, что служба синхронизации работает через консул агента на хосте k8s.

          env:
            - name: HOST_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
          command: 
            - consul-k8s sync-catalog \
                  -http-addr=${HOST_IP}:8500

Это не может быть настроено напрямую, но helm может настроить агента / клиента через client.join ( yaml src ):

Если это значение равно null (по умолчанию), клиенты будут пытаться автоматически присоединиться к кластеру серверов, работающему в Kubernetes. Это означает, что если для server.enabled задано значение true, клиенты автоматически присоединятся к этому кластеру. Если server.enabled не имеет значения true, необходимо указать значение, чтобы клиенты могли присоединиться к допустимому кластеру.

Это значение передается консулу в качестве опции --retry-join.

client:
  enabled: true
  join:
  - consul1
  - consul2
  - consul3
syncCatalog:
  enabled: true
...