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

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

commit 580d22a3cef9ce01567010cccb3da54a7362f4e9
Author: Nctllnty <[email protected]>
AuthorDate: Mon Mar 4 14:53:02 2024 +0800

    Improve ingress support for helm charts (#1606)
---
 hertzbeat/README.md                             |  4 ++--
 hertzbeat/templates/NOTES.txt                   |  8 ++-----
 hertzbeat/templates/manager/ingress.yaml        | 28 +++++++++++++++++++++++++
 hertzbeat/templates/manager/service-expose.yaml |  7 +++++--
 hertzbeat/values.yaml                           | 25 ++++++++--------------
 5 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/hertzbeat/README.md b/hertzbeat/README.md
index 475fa21..3c6e3e9 100644
--- a/hertzbeat/README.md
+++ b/hertzbeat/README.md
@@ -59,7 +59,7 @@ The external URL for HertzBeat core service is used to:
 
 Format: `protocol://domain[:port]`. Usually:
 
-- if service exposed via `Ingress`, the `domain` should be the value of 
`expose.ingress.hosts.core`
+- if service exposed via `Ingress`, the `domain` should be the value of 
`expose.ingress.hosts`
 - if service exposed via `ClusterIP`, the `domain` should be the value of 
`expose.clusterIP.name`
 - if service exposed via `NodePort`, the `domain` should be the IP address of 
one Kubernetes node
 - if service exposed via `LoadBalancer`, set the `domain` as your own domain 
name and add a CNAME record to map the domain name to the one you got from the 
cloud provider
@@ -94,7 +94,7 @@ The following table lists the configurable parameters of the 
HertzBeat chart and
 | Parameter                             | Description                          
                                                                                
                                                                                
           | Default         |
 
|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
 | **Expose**                            |                                      
                                                                                
                                                                                
           |                 |
-| `expose.type`                         | How to expose the service: 
`ingress`, `clusterIP`, `nodePort` or `loadBalancer`, other values will be 
ignored and the creation of service will be skipped.                            
                          | `ingress`       |
+| `expose.type`                         | How to expose the service: 
`Ingress`, `ClusterIP`, `NodePort` or `LoadBalancer`, other values will be 
ignored and the creation of service will be skipped.                            
                          | `Ingress`       |
 | `expose.clusterIP.name`               | The name of ClusterIP service        
                                                                                
                                                                                
           | `hertzbeat`     |
 | `expose.clusterIP.annotations`        | The annotations attached to the 
ClusterIP service                                                               
                                                                                
                | {}              |
 | `expose.clusterIP.ports.port`         | The service port HertzBeat listens 
on when serving HTTP                                                            
                                                                                
             | `80`            |
diff --git a/hertzbeat/templates/NOTES.txt b/hertzbeat/templates/NOTES.txt
index da6b52a..376794e 100644
--- a/hertzbeat/templates/NOTES.txt
+++ b/hertzbeat/templates/NOTES.txt
@@ -1,10 +1,6 @@
 1. Get the application URL by running these commands:
-{{- if (eq .Values.expose.type "ingress")}}
-{{- range $host := .Values.expose.ingress.hosts }}
-  {{- range .paths }}
-  http{{ if $.Values.expose.ingress.tls }}s{{ end }}://{{ $host.host }}{{ 
.path }}
-  {{- end }}
-{{- end }}
+{{- if (eq .Values.expose.type "Ingress")}}
+http{{ if $.Values.expose.ingress.tls.enable }}s{{ end }}://{{ 
.Values.expose.ingress.host }}
 
 {{- else if contains "NodePort" .Values.expose.type }}
   export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o 
jsonpath="{.spec.ports[0].nodePort}" services {{ include "hertzbeat.fullname" . 
}}-http)
diff --git a/hertzbeat/templates/manager/ingress.yaml 
b/hertzbeat/templates/manager/ingress.yaml
new file mode 100644
index 0000000..3d886f5
--- /dev/null
+++ b/hertzbeat/templates/manager/ingress.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.expose.ingress.enabled }}
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: "{{ include "hertzbeat.manager" . }}-ingress"
+  annotations:
+    {{- toYaml .Values.expose.ingress.annotations | nindent 4 }}
+  labels:
+    {{- include "hertzbeat.labels" . | nindent 4 }}
+spec:
+  rules:
+    - host: {{ .Values.expose.ingress.host }}
+      http:
+        paths:
+          - path: /
+            pathType: Prefix
+            backend:
+              service:
+                name: "{{ include "hertzbeat.manager" . }}-http"
+                port:
+                  number: 1157
+  tls:
+    {{- if .Values.expose.ingress.tls.enabled }}
+    - secretName: {{ .Values.expose.ingress.tls.secretName }}
+      hosts:
+        - {{ .Values.expose.ingress.host }}
+    {{- end }}
+{{- end }}
diff --git a/hertzbeat/templates/manager/service-expose.yaml 
b/hertzbeat/templates/manager/service-expose.yaml
index c890f1e..f99160a 100644
--- a/hertzbeat/templates/manager/service-expose.yaml
+++ b/hertzbeat/templates/manager/service-expose.yaml
@@ -1,17 +1,20 @@
-{{- if or (eq .Values.expose.type "ClusterIP") (eq .Values.expose.type 
"NodePort") (eq .Values.expose.type "LoadBalancer") }}
+{{- if or (eq .Values.expose.type "ClusterIP") (eq .Values.expose.type 
"NodePort") (eq .Values.expose.type "LoadBalancer") (eq .Values.expose.type 
"Ingress") }}
 apiVersion: v1
 kind: Service
 metadata:
   name: "{{ include "hertzbeat.manager" . }}-http"
   labels:
     {{- include "hertzbeat.labels" . | nindent 4 }}
-{{- if eq .Values.expose.type "ClusterIP" }}
+{{- if or (eq .Values.expose.type "ClusterIP") (eq .Values.expose.type 
"Ingress") }} 
 spec:
   type: ClusterIP
   ports:
     - name: http
       port: {{ .Values.expose.clusterIP.ports.port }}
       targetPort: 1157
+  selector:
+    {{- include "hertzbeat.selectorLabels" . | nindent 4 }}
+    component: manager
 {{- else if eq .Values.expose.type "NodePort" }}
 spec:
   type: NodePort
diff --git a/hertzbeat/values.yaml b/hertzbeat/values.yaml
index 9f10f59..ab6e467 100644
--- a/hertzbeat/values.yaml
+++ b/hertzbeat/values.yaml
@@ -96,9 +96,9 @@ tsdb:
 
 # Expose Network
 expose:
-  # Set how to expose the service. Set the type as "ingress", "clusterIP", 
"nodePort" or "loadBalancer"
+  # Set how to expose the service. Set the type as 
"ClusterIP","NodePort","LoadBalancer" or "Ingress"
   # and fill the information in the corresponding section
-  type: NodePort
+  type: Ingress
   clusterIP:
     ports:
       # The service port Harbor listens on when serving HTTP
@@ -117,17 +117,10 @@ expose:
       port: 1157
     sourceRanges: [ ]
   ingress:
-    className: ""
-    annotations: { }
-    # kubernetes.io/ingress.class: nginx
-    # kubernetes.io/tls-acme: "true"
-    hosts:
-      - host: hertzbeat.domain
-        paths:
-          - path: /
-            pathType: ImplementationSpecific
-    tls: [ ]
-    #  - secretName: chart-example-tls
-    #    hosts:
-    #      - chart-example.local
-            
+    enabled: true
+    host: "hertzbeat.domain"
+    annotations: {}    
+    tls:
+      enabled: false
+      tls:
+        - secretName: your-tls-secret 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to