From eb37043d0062f8a4e98c88358ce4f75a87e82b00 Mon Sep 17 00:00:00 2001 From: David Lehuby Date: Thu, 5 Sep 2024 12:58:12 +1000 Subject: [PATCH] PM-1952 - Openmina Node - Add Ingress + Service --- openmina-node/README.md | 8 +++- openmina-node/templates/deployment.yaml | 2 +- openmina-node/templates/ingress.yaml | 61 +++++++++++++++++++++++++ openmina-node/templates/service.yaml | 15 ++++++ openmina-node/values.yaml | 29 +++++++++++- 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 openmina-node/templates/ingress.yaml create mode 100644 openmina-node/templates/service.yaml diff --git a/openmina-node/README.md b/openmina-node/README.md index a2ea5358..1c63bc68 100644 --- a/openmina-node/README.md +++ b/openmina-node/README.md @@ -48,13 +48,17 @@ helmfile status | image.repository | string | `"openmina/openmina"` | The image repository | | image.tag | string | `"v0.8.1"` | Overrides the image tag whose default is the chart appVersion. | | imagePullSecrets | list | `[]` | The secrets used to pull the image | +| ingress.annotations | object | `{}` | The Ingress Annotations | +| ingress.className | string | `""` | The Ingress Class Name to use | +| ingress.enabled | bool | `false` | Whether to create an Ingress | +| ingress.hosts | list | `[{"host":"chart-example.local","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | The Ingress Hosts | +| ingress.tls | list | `[]` | The TLS configuration | | livenessProbe | string | `nil` | Liveness check configuration | | nameOverride | string | `""` | The release name override | | node.args | list | `[]` | The arguments to pass at runtime | | node.envVars | object | `{}` | The environment variables to set | | node.libp2p.privateKey | string | `""` | The libp2p private key | | node.libp2p.publicKey | string | `""` | The libp2p public key | -| node.port | int | `3000` | The port the openmina container listens on | | node.wallet.privateKey | string | `""` | The wallet private key | | node.wallet.publicKey | string | `""` | The wallet public key | | nodeSelector | object | `{}` | Node selector labels | @@ -65,6 +69,8 @@ helmfile status | replicaCount | int | `1` | The number of replicas | | resources | object | `{}` | Resource limitations for the pods | | securityContext | object | `{}` | The Security Context | +| service.port | int | `3000` | The service port | +| service.type | string | `"ClusterIP"` | The service type | | serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | diff --git a/openmina-node/templates/deployment.yaml b/openmina-node/templates/deployment.yaml index aeb2f189..6c52d4fb 100644 --- a/openmina-node/templates/deployment.yaml +++ b/openmina-node/templates/deployment.yaml @@ -45,7 +45,7 @@ spec: {{- end }} ports: - name: http - containerPort: {{ .Values.node.port }} + containerPort: {{ .Values.service.port }} protocol: TCP env: {{- if .Values.node.envVars }} diff --git a/openmina-node/templates/ingress.yaml b/openmina-node/templates/ingress.yaml new file mode 100644 index 00000000..27a26c2e --- /dev/null +++ b/openmina-node/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openmina-node.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openmina-node.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- 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 }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/openmina-node/templates/service.yaml b/openmina-node/templates/service.yaml new file mode 100644 index 00000000..cb5dba99 --- /dev/null +++ b/openmina-node/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openmina-node.fullname" . }} + labels: + {{- include "openmina-node.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openmina-node.selectorLabels" . | nindent 4 }} diff --git a/openmina-node/values.yaml b/openmina-node/values.yaml index 9faeac71..403d383e 100644 --- a/openmina-node/values.yaml +++ b/openmina-node/values.yaml @@ -51,9 +51,34 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 -node: - # -- The port the openmina container listens on +service: + # -- The service type + type: ClusterIP + # -- The service port port: 3000 + +ingress: + # -- Whether to create an Ingress + enabled: false + # -- The Ingress Class Name to use + className: "" + # -- The Ingress Annotations + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- The Ingress Hosts + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + # -- The TLS configuration + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +node: wallet: # -- The wallet private key privateKey: ""