This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git


The following commit(s) were added to refs/heads/master by this push:
     new d730498  feat: add service discovery (#187)
d730498 is described below

commit d73049876c4567668538ce590c8715ae880c9b91
Author: Gallardot <ttt...@163.com>
AuthorDate: Tue Dec 7 14:57:51 2021 +0800

    feat: add service discovery (#187)
---
 charts/apisix/README.md                | 27 +++++++++++++++++++++++++++
 charts/apisix/templates/_helpers.tpl   | 13 +++++++++++++
 charts/apisix/templates/configmap.yaml |  8 ++++++++
 charts/apisix/values.yaml              | 23 +++++++++++++++++++++++
 4 files changed, 71 insertions(+)

diff --git a/charts/apisix/README.md b/charts/apisix/README.md
index 817336d..427bfc0 100644
--- a/charts/apisix/README.md
+++ b/charts/apisix/README.md
@@ -150,6 +150,33 @@ If etcd.enabled is true, set more values of bitnami/etcd 
helm chart use etcd as
 
 Default enabled plugins. See [configmap 
template](https://github.com/apache/apisix-helm-chart/blob/master/charts/apisix/templates/configmap.yaml)
 for details.
 
+### discovery parameters
+
+| Parameter                       | Description                                
                                                                                
                                                         | Default    |
+|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
+| `discovery.enabled`                  | Enable or disable Apache APISIX 
integration service discovery | `false` |
+| `discovery.registry`                  | Registry is the same to the one in 
APISIX 
[config-default.yaml](https://github.com/apache/apisix/blob/master/conf/config-default.yaml#L281),
 and refer to such file for more setting details. also refer to [this 
documentation for integration service 
discovery](https://apisix.apache.org/docs/apisix/discovery) | nil |
+
+If you have enabled this feature,  here is an example:
+
+```yaml
+discovery:
+  enabled: true
+  registry:
+    eureka:
+      host:
+        - "http://${username}:${password}@${eureka_host1}:${eureka_port1}";
+        - "http://${username}:${password}@${eureka_host2}:${eureka_port2}";
+      prefix: "/eureka/"
+      fetch_interval: 30
+      weight: 100
+      timeout:
+        connect: 2000
+        send: 2000
+        read: 5000
+```
+
+
 ### dashboard parameters
 
 Configurations for apisix-dashboard sub chart.
diff --git a/charts/apisix/templates/_helpers.tpl 
b/charts/apisix/templates/_helpers.tpl
index 27252c0..a20eb72 100644
--- a/charts/apisix/templates/_helpers.tpl
+++ b/charts/apisix/templates/_helpers.tpl
@@ -61,3 +61,16 @@ Create the name of the service account to use
 {{- default "default" .Values.serviceAccount.name }}
 {{- end }}
 {{- end }}
+
+{{/*
+Renders a value that contains template.
+Usage:
+{{ include "apisix.tplvalues.render" ( dict "value" .Values.path.to.the.Value 
"context" $) }}
+*/}}
+{{- define "apisix.tplvalues.render" -}}
+    {{- if typeIs "string" .value }}
+        {{- tpl .value .context }}
+    {{- else }}
+        {{- tpl (.value | toYaml) .context }}
+    {{- end }}
+{{- end -}}
diff --git a/charts/apisix/templates/configmap.yaml 
b/charts/apisix/templates/configmap.yaml
index 9cbb634..2c5657a 100644
--- a/charts/apisix/templates/configmap.yaml
+++ b/charts/apisix/templates/configmap.yaml
@@ -209,6 +209,14 @@ data:
         sni: "{{ .Values.etcd.auth.tls.sni }}"
       {{- end }}
 
+    {{- if .Values.discovery.enabled }}
+    discovery:
+      {{- range $key, $value := .Values.discovery.registry }}
+      {{ $key }}:
+        {{- include "apisix.tplvalues.render" (dict "value" $value "context" 
$) | nindent 8 }}
+      {{- end }}
+    {{- end }}
+
     {{- if .Values.plugins }}
     plugins:                          # plugin list
     {{- range $plugin := .Values.plugins }}
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index 9da5cde..d150b17 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -213,6 +213,29 @@ customPlugins:
           - key: ""
             path: ""
 
+discovery:
+  enabled: false
+  registry:
+      # Integration service discovery registry. E.g eureka\dns\nacos\consul_kv
+      # reference:
+      # 
https://apisix.apache.org/docs/apisix/discovery#configuration-for-eureka
+      # 
https://apisix.apache.org/docs/apisix/discovery/dns#service-discovery-via-dns
+      # 
https://apisix.apache.org/docs/apisix/discovery/consul_kv#configuration-for-consul-kv
+      # 
https://apisix.apache.org/docs/apisix/discovery/nacos#configuration-for-nacos
+      #
+      # an eureka example:
+      # eureka:
+      #   host:
+      #     - "http://${username}:${password}@${eureka_host1}:${eureka_port1}";
+      #     - "http://${username}:${password}@${eureka_host2}:${eureka_port2}";
+      #   prefix: "/eureka/"
+      #   fetch_interval: 30
+      #   weight: 100
+      #   timeout:
+      #     connect: 2000
+      #     send: 2000
+      #     read: 5000
+
 dns:
   resolvers:
     - 127.0.0.1

Reply via email to