From fd7e880c0da7a1e85e37dc85eba916d4ccb0d33a Mon Sep 17 00:00:00 2001 From: Irfan Hakim <irfanhakim.as@yahoo.com> Date: Sat, 13 Jul 2024 12:24:41 +0800 Subject: [PATCH 1/4] Add new ingress.customAnnotations setting --- template/chartName/README.md | 1 + template/chartName/values.yaml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/template/chartName/README.md b/template/chartName/README.md index 29fcae8e..0106f33d 100644 --- a/template/chartName/README.md +++ b/template/chartName/README.md @@ -142,6 +142,7 @@ A Helm chart for deploying ChartName. | image.init.tag | string | `""` | The tag that specifies the version of the Init container image used. Default: `"1.36.1"`. | | imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | | ingress.clusterIssuer | string | `""` | The name of the cluster issuer for Ingress. Default: `"letsencrypt-dns-prod"`. | +| ingress.customAnnotations | list | `[]` | Additional configuration annotations to be added to the Ingress resource. | | ingress.enabled | bool | `false` | Specifies whether Ingress should be enabled for hosting ChartName services. | | ingress.www | bool | `false` | Specifies whether the WWW subdomain should be enabled. | | replicaCount | string | `""` | The desired number of running replicas for ChartName. Default: `"1"`. | diff --git a/template/chartName/values.yaml b/template/chartName/values.yaml index 294a29cc..de293e59 100644 --- a/template/chartName/values.yaml +++ b/template/chartName/values.yaml @@ -79,6 +79,23 @@ ingress: # Example: # clusterIssuer: "letsencrypt-http-prod" clusterIssuer: "" + # Additional configuration annotations to be added to the Ingress resource. + # Example: + # customAnnotations: + # # The prefix of the annotation. + # # Default: "nginx.ingress.kubernetes.io" + # # Example: + # # - prefix: "nginx.org" + # - prefix: "" + # # The name of the annotation. + # # Example: + # # name: "proxy-connect-timeout" + # name: "" + # # The value of the annotation. + # # Example: + # # value: "120" + # value: "" + customAnnotations: [] # Specifies whether the WWW subdomain should be enabled. # Example: # www: true From a778f0f834a7d4eac94140112f09831f581e8f56 Mon Sep 17 00:00:00 2001 From: Irfan Hakim <irfanhakim.as@yahoo.com> Date: Sat, 13 Jul 2024 12:24:59 +0800 Subject: [PATCH 2/4] Include any custom ingress annotation --- template/chartName/templates/ingress.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/chartName/templates/ingress.yaml b/template/chartName/templates/ingress.yaml index 8527d50e..945267d7 100644 --- a/template/chartName/templates/ingress.yaml +++ b/template/chartName/templates/ingress.yaml @@ -1,6 +1,7 @@ {{- $ingress := .Values.ingress.enabled }} {{- $www := .Values.ingress.www }} {{- $clusterIssuer := .Values.ingress.clusterIssuer | default "letsencrypt-dns-prod" | toString | quote }} +{{- $customAnnotations := .Values.ingress.customAnnotations }} {{- $domain := .Values.chartName.domain | toString }} {{- $wwwDomain := printf "www.%s" $domain | toString | quote }} {{- if and $ingress $domain }} @@ -21,6 +22,9 @@ metadata: nginx.ingress.kubernetes.io/session-cookie-max-age: "172800" nginx.ingress.kubernetes.io/session-cookie-name: "route" nginx.org/client-max-body-size: "100m" + {{- range $customAnnotations }} + {{ printf "%s/%s" (.prefix | default "nginx.ingress.kubernetes.io") .name }}: {{ .value | quote }} + {{- end }} spec: ingressClassName: "nginx" rules: From cb09f93cbed388227a92f7b0bc5c151c2e80f1bf Mon Sep 17 00:00:00 2001 From: Irfan Hakim <irfanhakim.as@yahoo.com> Date: Sat, 13 Jul 2024 12:37:08 +0800 Subject: [PATCH 3/4] Add service.nodePort setting --- template/chartName/README.md | 1 + template/chartName/values.yaml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/template/chartName/README.md b/template/chartName/README.md index 0106f33d..318e3346 100644 --- a/template/chartName/README.md +++ b/template/chartName/README.md @@ -147,6 +147,7 @@ A Helm chart for deploying ChartName. | ingress.www | bool | `false` | Specifies whether the WWW subdomain should be enabled. | | replicaCount | string | `""` | The desired number of running replicas for ChartName. Default: `"1"`. | | resources.chartName | object | `{}` | ChartName container resources. | +| service.nodePort | string | `""` | The optional node port to expose when the service type is NodePort. | | service.port | string | `""` | The port on which the ChartName server should listen. Default: `"80"`. | | service.type | string | `""` | The type of service used for ChartName services. Default: `"ClusterIP"`. | | storage.data.accessMode | string | `""` | The access mode defining how the data storage can be mounted. Default: `"ReadWriteMany"`. | diff --git a/template/chartName/values.yaml b/template/chartName/values.yaml index de293e59..6c2bc63b 100644 --- a/template/chartName/values.yaml +++ b/template/chartName/values.yaml @@ -103,6 +103,10 @@ ingress: # Service configurations. service: + # The optional node port to expose when the service type is NodePort. + # Example: + # nodePort: "32000" + nodePort: "" # The port on which the ChartName server should listen. # Default: "80" # Example: From 430b0f14fda30d99f04aca6c9f1e4975ce91cf8c Mon Sep 17 00:00:00 2001 From: Irfan Hakim <irfanhakim.as@yahoo.com> Date: Sat, 13 Jul 2024 12:37:18 +0800 Subject: [PATCH 4/4] Explicitly set nodePort if specified --- template/chartName/templates/service.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/chartName/templates/service.yaml b/template/chartName/templates/service.yaml index d5cb4e27..4a57796d 100644 --- a/template/chartName/templates/service.yaml +++ b/template/chartName/templates/service.yaml @@ -1,3 +1,4 @@ +{{- $nodePort := .Values.service.nodePort | toString }} {{- $port := .Values.service.port | default "80" | toString }} {{- $type := .Values.service.type | default "ClusterIP" | toString }} --- @@ -12,6 +13,9 @@ spec: ports: - port: {{ int $port }} targetPort: chartName + {{- if and (eq $type "NodePort") $nodePort }} + nodePort: {{ int $nodePort }} + {{- end }} protocol: TCP name: chartName selector: