From 2599548558d278d568bf305bd8396f9d7d945f78 Mon Sep 17 00:00:00 2001
From: Tancho Mihov <tancho.mihov@cleverpine.com>
Date: Tue, 14 Jun 2022 16:46:54 +0300
Subject: [PATCH] Ingress added

---
 Chart.yaml             |  2 +-
 README.md              | 12 ++++++++++--
 templates/ingress.yaml | 29 +++++++++++++++++++++++++++++
 values.yaml            | 14 +++++++++++++-
 4 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 templates/ingress.yaml

diff --git a/Chart.yaml b/Chart.yaml
index 2518d95..cb52984 100644
--- a/Chart.yaml
+++ b/Chart.yaml
@@ -2,5 +2,5 @@ apiVersion: v1
 appVersion: 0.0.2
 description: cache deployment
 name: cache
-version: 0.0.2
+version: 0.0.3
 icon: "https://www.vereign.com/wp-content/themes/vereign2020/images/vereign-logo.svg"
diff --git a/README.md b/README.md
index 98632dc..e007a30 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # cache
 
-![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) ![AppVersion: 0.0.2](https://img.shields.io/badge/AppVersion-0.0.2-informational?style=flat-square)
+![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![AppVersion: 0.0.2](https://img.shields.io/badge/AppVersion-0.0.2-informational?style=flat-square)
 
 cache deployment
 
@@ -24,6 +24,14 @@ cache deployment
 | image.repository | string | `"eu.gcr.io/vrgn-infra-prj"` |  |
 | image.sha | string | `""` | Image sha, usually generated by the CI Uses image.tag if empty |
 | image.tag | string | `""` | Image tag Uses .Chart.AppVersion if empty |
+| ingress.annotations."cert-manager.io/cluster-issuer" | string | `"letsencrypt-production-http"` |  |
+| ingress.annotations."kubernetes.io/ingress.class" | string | `"nginx"` |  |
+| ingress.annotations."kubernetes.io/ingress.global-static-ip-name" | string | `"dev-light-public"` |  |
+| ingress.annotations."nginx.ingress.kubernetes.io/rewrite-target" | string | `"/$2"` |  |
+| ingress.enabled | bool | `true` |  |
+| ingress.frontendDomain | string | `"gaiax.vereign.com"` |  |
+| ingress.frontendTlsSecretName | string | `"cert-manager-tls"` |  |
+| ingress.tlsEnabled | bool | `true` |  |
 | log.encoding | string | `"json"` |  |
 | log.level | string | `"debug"` |  |
 | metrics.enabled | bool | `true` | Enable prometheus metrics |
@@ -44,7 +52,7 @@ cache deployment
 | security.runAsGid | int | `0` | Group used by the apps |
 | security.runAsNonRoot | bool | `false` | by default, apps run as non-root |
 | security.runAsUid | int | `0` | User used by the apps |
-| service.port | int | `8083` |  |
+| service.port | int | `8080` |  |
 
 ----------------------------------------------
 Autogenerated from chart metadata using [helm-docs v1.10.0](https://github.com/norwoodj/helm-docs/releases/v1.10.0)
diff --git a/templates/ingress.yaml b/templates/ingress.yaml
new file mode 100644
index 0000000..d757af5
--- /dev/null
+++ b/templates/ingress.yaml
@@ -0,0 +1,29 @@
+{{- if .Values.ingress.enabled }}
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: {{ template "app.name" . }}
+  namespace: {{ .Release.Namespace }}
+  annotations:
+{{ toYaml .Values.ingress.annotations | indent 4 }}
+  labels:
+    {{- include "app.labels" . | nindent 4 }}
+spec:
+{{- if .Values.ingress.tlsEnabled }}
+  tls:
+    - hosts:
+        - {{ .Values.ingress.frontendDomain }}
+      secretName: {{ .Values.ingress.frontendTlsSecretName }}
+{{- end }}
+  rules:
+    - host: {{ .Values.ingress.frontendDomain }}
+      http:
+        paths:
+          - path: /{{ .Release.Namespace }}/{{ template "app.name" . }}(/|$)(.*)
+            pathType: Prefix
+            backend:
+              service:
+                name: {{ template "app.name" . }}
+                port:
+                  number: {{ .Values.service.port }}
+{{- end }}
\ No newline at end of file
diff --git a/values.yaml b/values.yaml
index 9603383..2b83b2b 100644
--- a/values.yaml
+++ b/values.yaml
@@ -84,7 +84,7 @@ security:
 ##
 ##
 service:
-  port: 8083
+  port: 8080
 
 cache:
   http:
@@ -101,3 +101,15 @@ redis:
   pass: ""
   db: 0
   expiration: 1h
+
+ingress:
+  enabled: true
+  annotations:
+    cert-manager.io/cluster-issuer: letsencrypt-production-http
+    kubernetes.io/ingress.class: nginx
+    kubernetes.io/ingress.global-static-ip-name: dev-light-public
+    nginx.ingress.kubernetes.io/rewrite-target: /$2
+  tlsEnabled: true
+  frontendDomain: gaiax.vereign.com
+  frontendTlsSecretName: cert-manager-tls
+
-- 
GitLab