From 7701a1fbe6bc19a27b719e61e9ebcb1b2689a8f2 Mon Sep 17 00:00:00 2001 From: Rahul Patil Date: Mon, 16 Dec 2024 12:37:33 +0100 Subject: [PATCH] chore(storcon): Set enable flag on NLB based service (#118) * chore(storcon): Set enable flag on NLB based service This will be temporary set "serviceNLB" to keep existing Service with Type LoadBalancer after migration we can set this to false to remove NLB. This is no-op change to avoid any conflict with new service object * feat(storcon): Add new service object for internal use * feat(storcon): Add ingress object * chore(storcon): Bump chart version to 1.3.0 * docs(storcon): Update values with new flags --- charts/neon-storage-controller/Chart.yaml | 2 +- charts/neon-storage-controller/README.md | 10 ++++- .../templates/_helpers.tpl | 8 ++++ .../templates/ingress.yaml | 44 +++++++++++++++++++ .../templates/service.yaml | 18 ++++++++ charts/neon-storage-controller/values.yaml | 19 ++++++++ 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 charts/neon-storage-controller/templates/ingress.yaml diff --git a/charts/neon-storage-controller/Chart.yaml b/charts/neon-storage-controller/Chart.yaml index d4cb2e8..b2dabe1 100644 --- a/charts/neon-storage-controller/Chart.yaml +++ b/charts/neon-storage-controller/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: neon-storage-controller description: Neon storage controller type: application -version: 1.2.1 +version: 1.3.0 appVersion: "0.1.0" kubeVersion: "^1.18.x-x" home: https://neon.tech diff --git a/charts/neon-storage-controller/README.md b/charts/neon-storage-controller/README.md index fff4f0a..2c22db2 100644 --- a/charts/neon-storage-controller/README.md +++ b/charts/neon-storage-controller/README.md @@ -1,6 +1,6 @@ # neon-storage-controller -![Version: 1.2.1](https://img.shields.io/badge/Version-1.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) [![Lint and Test Charts](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml/badge.svg)](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml) +![Version: 1.3.0](https://img.shields.io/badge/Version-1.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) [![Lint and Test Charts](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml/badge.svg)](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml) Neon storage controller @@ -34,6 +34,13 @@ Kubernetes: `^1.18.x-x` | image.repository | string | `"neondatabase/neon"` | Neondatabase image repository | | image.tag | string | `"latest"` | Overrides the image tag whose default is the chart appVersion. | | imagePullSecrets | list | `[]` | Specify docker-registry secret names as an array | +| ingress.annotations | object | `{}` | Additional annotations for Ingress resource. | +| ingress.className | string | `""` | Ingress class for controller | +| ingress.enabled | bool | `false` | Enable ingress controller resource. | +| ingress.hosts[0].host | string | `"chart-example.local"` | | +| ingress.hosts[0].paths[0].path | string | `"/"` | | +| ingress.hosts[0].paths[0].pathType | string | `"Prefix"` | | +| ingress.hosts[0].paths[0].protocol | string | `"TCP"` | | | metrics.enabled | bool | `false` | Enable prometheus metrcis autodiscovery | | metrics.serviceMonitor.enabled | bool | `false` | Create ServiceMonitor resource | | metrics.serviceMonitor.interval | string | `"10s"` | Interval in which prometheus scrapes | @@ -62,6 +69,7 @@ Kubernetes: `^1.18.x-x` | serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.create | bool | `true` | | | serviceAccount.name | string | `""` | | +| serviceNLB | bool | `true` | | | settings.chaosInterval | string | `""` | Chaos testing interval | | settings.computeHookUrl | string | `""` | | | settings.controlPlaneJwtToken | string | `""` | | diff --git a/charts/neon-storage-controller/templates/_helpers.tpl b/charts/neon-storage-controller/templates/_helpers.tpl index 9d511dc..7fc762a 100644 --- a/charts/neon-storage-controller/templates/_helpers.tpl +++ b/charts/neon-storage-controller/templates/_helpers.tpl @@ -60,3 +60,11 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Returns service name +This will be use only for internal purpose e.g. ingress connecting to service +*/}} +{{- define "neon-storage-controller.serviceName" -}} +{{- printf "%s-svc" (include "neon-storage-controller.fullname" .) | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} diff --git a/charts/neon-storage-controller/templates/ingress.yaml b/charts/neon-storage-controller/templates/ingress.yaml new file mode 100644 index 0000000..bff8a43 --- /dev/null +++ b/charts/neon-storage-controller/templates/ingress.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "neon-storage-controller.fullname" . }} + labels: + {{- include "neon-storage-controller.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "neon-storage-controller.serviceName" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} + diff --git a/charts/neon-storage-controller/templates/service.yaml b/charts/neon-storage-controller/templates/service.yaml index 108eb58..92d644c 100644 --- a/charts/neon-storage-controller/templates/service.yaml +++ b/charts/neon-storage-controller/templates/service.yaml @@ -1,3 +1,5 @@ +{{- if .Values.serviceNLB -}} +--- apiVersion: v1 kind: Service metadata: @@ -17,3 +19,19 @@ spec: name: controller selector: {{- include "neon-storage-controller.selectorLabels" . | nindent 4 }} +{{- end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "neon-storage-controller.serviceName" . }} + labels: + {{- include "neon-storage-controller.labels" . | nindent 4 }} +spec: + ports: + - port: {{ .Values.service.port }} + targetPort: controller + protocol: TCP + name: controller + selector: + {{- include "neon-storage-controller.selectorLabels" . | nindent 4 }} diff --git a/charts/neon-storage-controller/values.yaml b/charts/neon-storage-controller/values.yaml index b7fd143..6d708b4 100644 --- a/charts/neon-storage-controller/values.yaml +++ b/charts/neon-storage-controller/values.yaml @@ -103,6 +103,25 @@ service: # service.port -- controller listen port port: 50051 +# Temporary set "serviceNLB" to keep existing Service with Type LoadBalancer +# After migration we can set this to false to remove NLB +serviceNLB: true + +ingress: + # ingress.enabled -- Enable ingress controller resource. + enabled: false + # ingress.className -- Ingress class for controller + className: "" + # ingress.annotations -- Additional annotations for Ingress resource. + annotations: {} + # external-dns.alpha.kubernetes.io/hostname: chart-example.local + hosts: + - host: chart-example.local + paths: + - path: / + # https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types + pathType: Prefix + protocol: TCP resources: limits: memory: 4Gi