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

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


The following commit(s) were added to refs/heads/master by this push:
     new 87e0131  doc: add etcd comment for k8s readme. add service-monitor 
yaml for prometh… (#1808)
87e0131 is described below

commit 87e0131a59d5b34be6701fe0413d4639c777b781
Author: houshunwei <houshun...@gmail.com>
AuthorDate: Fri Jul 10 21:51:26 2020 +0800

    doc: add etcd comment for k8s readme. add service-monitor yaml for prometh… 
(#1808)
---
 kubernetes/README.md                               | 21 ++++++++++++
 ...ce.yaml => service-monitor-for-prometheus.yaml} | 40 ++++++++++------------
 kubernetes/service.yaml                            |  2 ++
 3 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/kubernetes/README.md b/kubernetes/README.md
index 30f299d..c6bd9ab 100644
--- a/kubernetes/README.md
+++ b/kubernetes/README.md
@@ -23,6 +23,27 @@ There are some yaml files for deploying apisix in Kubernetes.
 ### Prerequisites
 - Install etcd
 
+#### when using etcd-operator
+when using etcd-operator, you need to change apisix-gw-config-cm.yaml:
+
+* add CoreDNS IP into dns_resolver
+
+```
+dns_resolver:
+  - 10.233.0.3      # default coreDNS cluster ip
+
+```
+* change etcd host
+
+Following {your-namespace} should be changed to your namespace, for example 
`default`.
+> Mention: must use `Full Qualified Domain Name`. Short name 
`etcd-cluster-client` is not work.
+
+```
+etcd:
+  host:
+    - "http://etcd-cluster-client.{your-namespace}.svc.cluster.local:2379";     
# multiple etcd address
+```
+
 ### Usage
 
 #### Create configmap for apache incubator-apisix
diff --git a/kubernetes/service.yaml 
b/kubernetes/service-monitor-for-prometheus.yaml
similarity index 65%
copy from kubernetes/service.yaml
copy to kubernetes/service-monitor-for-prometheus.yaml
index c207660..41a62f8 100644
--- a/kubernetes/service.yaml
+++ b/kubernetes/service-monitor-for-prometheus.yaml
@@ -15,27 +15,25 @@
 # limitations under the License.
 #
 
-apiVersion: v1
-kind: Service
+# when using prometheus-operator, you can apply this into k8s.
+# Mention: ServiceMonitor should be the same namespace with 
prometheus-operator.
+---
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
 metadata:
-  name: apisix-gw-lb
-  # namespace: default
+  name: apisix-gw
+  labels:
+    app: apisix-gw
 spec:
-  ports:
-  - name: http
-    port: 9080
-    protocol: TCP
-    targetPort: 9080
-  - name: https
-    port: 9443
-    protocol: TCP
-    targetPort: 9443
-  # - name: admin-port
-  #   port: 9180
-  #   protocol: TCP
-  #   targetPort: 9180
+  endpoints:
+    - interval: 10s
+      honorLabels: true
+      port: http
+      path: /apisix/prometheus/metrics
+      scheme: http
   selector:
-    app: apisix-gw
-  type: NodePort
-  externalTrafficPolicy: Local
-  # sessionAffinity: None
+    matchLabels:
+      app: apisix-gw
+  namespaceSelector:
+    any: true
+
diff --git a/kubernetes/service.yaml b/kubernetes/service.yaml
index c207660..1de6e7d 100644
--- a/kubernetes/service.yaml
+++ b/kubernetes/service.yaml
@@ -20,6 +20,8 @@ kind: Service
 metadata:
   name: apisix-gw-lb
   # namespace: default
+  labels:
+    app: apisix-gw   # useful for service discovery, for example, 
prometheus-operator.
 spec:
   ports:
   - name: http

Reply via email to