From 8678282f409513b3ba1910b1d0cc4a94b7196ee5 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 8 Aug 2024 15:10:36 +0200 Subject: [PATCH 1/5] fix: assertoor double ingress --- charts/assertoor/Chart.yaml | 2 +- charts/assertoor/README.md | 4 +++- charts/assertoor/templates/ingress.yaml | 29 ++++++++++++++++++++++--- charts/assertoor/values.yaml | 4 ++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/charts/assertoor/Chart.yaml b/charts/assertoor/Chart.yaml index 7e91249d..203ebb39 100644 --- a/charts/assertoor/Chart.yaml +++ b/charts/assertoor/Chart.yaml @@ -6,7 +6,7 @@ home: https://github.com/ethpandaops/assertoor sources: - https://github.com/ethpandaops/assertoor type: application -version: 0.0.2 +version: 0.0.3 appVersion: "1.0.0" maintainers: - name: pk910 diff --git a/charts/assertoor/README.md b/charts/assertoor/README.md index 891ffed5..f71860b8 100644 --- a/charts/assertoor/README.md +++ b/charts/assertoor/README.md @@ -1,7 +1,7 @@ # assertoor -![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) +![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) Testing tool that is capable of doing actions and checking conditions on ethereum pos networks. @@ -77,6 +77,8 @@ assertoorTests: | ingress.enabled | bool | `false` | Ingress resource for the HTTP API | | ingress.hosts[0].host | string | `"chart-example.local"` | | | ingress.hosts[0].paths | list | `[]` | | +| ingress.hosts[1].host | string | `"chart-example-admin.local"` | | +| ingress.hosts[1].paths | list | `[]` | | | ingress.tls | list | `[]` | Ingress TLS | | initContainers | list | `[]` | Additional init containers | | nameOverride | string | `""` | Overrides the chart's name | diff --git a/charts/assertoor/templates/ingress.yaml b/charts/assertoor/templates/ingress.yaml index be5aa9c0..7fa73ebe 100644 --- a/charts/assertoor/templates/ingress.yaml +++ b/charts/assertoor/templates/ingress.yaml @@ -1,6 +1,7 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "assertoor.fullname" . -}} -{{- $svcPort := include "assertoor.httpPort" . -}} +{{- $svcPortAdmin := include "assertoor.httpPort" . -}} +{{- $svcPortPublic := include "assertoor.publicHttpPort" . -}} {{- 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}} @@ -38,6 +39,7 @@ spec: {{- end }} rules: {{- range .Values.ingress.hosts }} + {{- if and (contains "admin" .host) (semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion) }} - host: {{ .host | quote }} http: paths: @@ -51,11 +53,32 @@ spec: service: name: {{ $fullName }} port: - number: {{ $svcPort }} + number: {{ $svcPortAdmin }} {{- else }} serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} + servicePort: {{ $svcPortAdmin }} {{- end }} {{- end }} + {{- else }} + - 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: {{ $svcPortPublic }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPortPublic }} + {{- end }} + {{- end }} + {{- end }} {{- end }} {{- end }} diff --git a/charts/assertoor/values.yaml b/charts/assertoor/values.yaml index f05d5e64..09077b08 100644 --- a/charts/assertoor/values.yaml +++ b/charts/assertoor/values.yaml @@ -27,9 +27,13 @@ ingress: # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" # -- Ingress host + # -- if you set "admin" in the hostname it will use the admin service (8080) + # -- if you do not set admin in the hostname it will use the public service (8082) hosts: - host: chart-example.local paths: [] + - host: chart-example-admin.local + paths: [] # -- Ingress TLS tls: [] # - secretName: chart-example-tls From 0f624b025077f90cb5efbfd94ba32c7687f2357d Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 8 Aug 2024 15:55:18 +0200 Subject: [PATCH 2/5] fix, create two ingresses --- charts/assertoor/README.md | 11 ++-- charts/assertoor/templates/_helpers.tpl | 6 +-- charts/assertoor/templates/deployment.yaml | 4 +- charts/assertoor/templates/ingress.yaml | 59 ++++++++++++++++++---- charts/assertoor/templates/service.yaml | 6 +-- charts/assertoor/values.yaml | 31 +++++++++--- 6 files changed, 87 insertions(+), 30 deletions(-) diff --git a/charts/assertoor/README.md b/charts/assertoor/README.md index f71860b8..77e3be7f 100644 --- a/charts/assertoor/README.md +++ b/charts/assertoor/README.md @@ -69,7 +69,8 @@ assertoorTests: | extraVolumes | list | `[]` | Additional volumes | | fullnameOverride | string | `""` | Overrides the chart's computed fullname | | globalVariables | object | `{"walletPrivkey":"feedbeef12340000feedbeef12340000feedbeef12340000feedbeef12340000"}` | global assertoor variables -- global variables are passed to all tests. | -| httpPort | int | `8080` | HTTP port for assertoor interface | +| httpPort | int | `8082` | HTTP port for assertoor interface | +| httpPortAdmin | int | `8080` | HTTP port for assertoor admin interface | | image.pullPolicy | string | `"IfNotPresent"` | assertoor container pull policy | | image.repository | string | `"ethpandaops/assertoor"` | assertoor container image repository | | image.tag | string | `"latest"` | assertoor container image tag | @@ -77,9 +78,12 @@ assertoorTests: | ingress.enabled | bool | `false` | Ingress resource for the HTTP API | | ingress.hosts[0].host | string | `"chart-example.local"` | | | ingress.hosts[0].paths | list | `[]` | | -| ingress.hosts[1].host | string | `"chart-example-admin.local"` | | -| ingress.hosts[1].paths | list | `[]` | | | ingress.tls | list | `[]` | Ingress TLS | +| ingressAdmin.annotations | object | `{}` | Annotations for Ingress | +| ingressAdmin.enabled | bool | `false` | Ingress resource for the HTTP API -- This is the admin interface -- Please ensure you put this behind authorization | +| ingressAdmin.hosts[0].host | string | `"chart-example-admin.local"` | | +| ingressAdmin.hosts[0].paths | list | `[]` | | +| ingressAdmin.tls | list | `[]` | Ingress TLS | | initContainers | list | `[]` | Additional init containers | | nameOverride | string | `""` | Overrides the chart's name | | nodeSelector | object | `{}` | Node selector for pods | @@ -87,7 +91,6 @@ assertoorTests: | podDisruptionBudget | object | `{}` | Define the PodDisruptionBudget spec If not set then a PodDisruptionBudget will not be created | | podLabels | object | `{}` | Pod labels | | priorityClassName | string | `nil` | Pod priority class | -| publicHttpPort | int | `8082` | HTTP port for assertoor public interface | | resources | object | `{}` | Resource requests and limits | | securityContext | object | See `values.yaml` | The security context for pods | | service.type | string | `"ClusterIP"` | Service type | diff --git a/charts/assertoor/templates/_helpers.tpl b/charts/assertoor/templates/_helpers.tpl index 5982a775..a903000d 100644 --- a/charts/assertoor/templates/_helpers.tpl +++ b/charts/assertoor/templates/_helpers.tpl @@ -62,9 +62,9 @@ Create the name of the service account to use {{- end }} {{- define "assertoor.httpPort" -}} -{{- printf "8080" -}} +{{- printf "8082" -}} {{- end -}} -{{- define "assertoor.publicHttpPort" -}} -{{- printf "8082" -}} +{{- define "assertoor.httpPortAdmin" -}} +{{- printf "8080" -}} {{- end -}} diff --git a/charts/assertoor/templates/deployment.yaml b/charts/assertoor/templates/deployment.yaml index 4069329c..fe0c6f7f 100644 --- a/charts/assertoor/templates/deployment.yaml +++ b/charts/assertoor/templates/deployment.yaml @@ -64,8 +64,8 @@ spec: - name: http containerPort: {{ include "assertoor.httpPort" . }} protocol: TCP - - name: public-http - containerPort: {{ include "assertoor.publicHttpPort" . }} + - name: http-admin + containerPort: {{ include "assertoor.httpPortAdmin" . }} protocol: TCP resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/assertoor/templates/ingress.yaml b/charts/assertoor/templates/ingress.yaml index 7fa73ebe..cf165e42 100644 --- a/charts/assertoor/templates/ingress.yaml +++ b/charts/assertoor/templates/ingress.yaml @@ -1,7 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "assertoor.fullname" . -}} -{{- $svcPortAdmin := include "assertoor.httpPort" . -}} -{{- $svcPortPublic := include "assertoor.publicHttpPort" . -}} +{{- $svcPortPublic := include "assertoor.httpPort" . -}} {{- 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}} @@ -39,7 +38,6 @@ spec: {{- end }} rules: {{- range .Values.ingress.hosts }} - {{- if and (contains "admin" .host) (semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion) }} - host: {{ .host | quote }} http: paths: @@ -53,13 +51,55 @@ spec: service: name: {{ $fullName }} port: - number: {{ $svcPortAdmin }} + number: {{ $svcPortPublic }} {{- else }} serviceName: {{ $fullName }} - servicePort: {{ $svcPortAdmin }} + servicePort: {{ $svcPortPublic }} {{- end }} {{- end }} - {{- else }} + {{- end }} +{{- end }} +--- +{{- if .Values.ingressAdmin.enabled -}} +{{- $fullName := include "assertoor.fullname" . -}} +{{- $svcPortAdmin := include "assertoor.httpPortAdmin" . -}} +{{- if and .Values.ingressAdmin.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingressAdmin.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingressAdmin.annotations "kubernetes.io/ingress.class" .Values.ingressAdmin.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 "assertoor.labels" . | nindent 4 }} + {{- with .Values.ingressAdmin.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingressAdmin.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingressAdmin.className }} + {{- end }} + {{- if .Values.ingressAdmin.tls }} + tls: + {{- range .Values.ingressAdmin.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingressAdmin.hosts }} - host: {{ .host | quote }} http: paths: @@ -73,12 +113,11 @@ spec: service: name: {{ $fullName }} port: - number: {{ $svcPortPublic }} + number: {{ $svcPortAdmin }} {{- else }} serviceName: {{ $fullName }} - servicePort: {{ $svcPortPublic }} + servicePort: {{ $svcPortAdmin }} {{- end }} {{- end }} - {{- end }} {{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/assertoor/templates/service.yaml b/charts/assertoor/templates/service.yaml index 162bc6d3..4537b25a 100644 --- a/charts/assertoor/templates/service.yaml +++ b/charts/assertoor/templates/service.yaml @@ -11,10 +11,10 @@ spec: targetPort: http protocol: TCP name: http - - port: {{ include "assertoor.publicHttpPort" . }} - targetPort: public-http + - port: {{ include "assertoor.httpPortAdmin" . }} + targetPort: http-admin protocol: TCP - name: public-http + name: http-admin {{- if .Values.extraPorts }} {{ toYaml .Values.extraPorts | nindent 4}} {{- end }} diff --git a/charts/assertoor/values.yaml b/charts/assertoor/values.yaml index 09077b08..44f18ad8 100644 --- a/charts/assertoor/values.yaml +++ b/charts/assertoor/values.yaml @@ -26,12 +26,27 @@ ingress: annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - # -- Ingress host - # -- if you set "admin" in the hostname it will use the admin service (8080) - # -- if you do not set admin in the hostname it will use the public service (8082) + # -- Ingress host for public service hosts: - host: chart-example.local paths: [] + # -- Ingress TLS + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +ingressAdmin: + # -- Ingress resource for the HTTP API + # -- This is the admin interface + # -- Please ensure you put this behind authorization + enabled: false + # -- Annotations for Ingress + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- Ingress host for admin service + hosts: - host: chart-example-admin.local paths: [] # -- Ingress TLS @@ -139,10 +154,10 @@ extraEnv: [] # -- HTTP port for assertoor interface -httpPort: 8080 +httpPort: 8082 -# -- HTTP port for assertoor public interface -publicHttpPort: 8082 +# -- HTTP port for assertoor admin interface +httpPortAdmin: 8080 # -- An array of endpoints to use for assertoor # -- executionUrl & consensusUrl are the only required fields @@ -186,10 +201,10 @@ config: | web: server: host: "0.0.0.0" - port: {{ .Values.httpPort }} + port: {{ .Values.httpPortAdmin }} publicServer: host: "0.0.0.0" - port: {{ .Values.publicHttpPort }} + port: {{ .Values.httpPort }} frontend: enabled: {{ .Values.assertoorFrontendEnabled }} api: From 6b43c6076bbcccf348f80fcd359dd441364fa0b5 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 8 Aug 2024 15:55:46 +0200 Subject: [PATCH 3/5] newline --- charts/assertoor/templates/ingress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/assertoor/templates/ingress.yaml b/charts/assertoor/templates/ingress.yaml index cf165e42..e24a6c7c 100644 --- a/charts/assertoor/templates/ingress.yaml +++ b/charts/assertoor/templates/ingress.yaml @@ -120,4 +120,4 @@ spec: {{- end }} {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} From fd9a847c6358683fe1da56f998672add8232eecd Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 8 Aug 2024 16:05:46 +0200 Subject: [PATCH 4/5] fix ingress name --- charts/assertoor/templates/ingress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/assertoor/templates/ingress.yaml b/charts/assertoor/templates/ingress.yaml index e24a6c7c..255b5667 100644 --- a/charts/assertoor/templates/ingress.yaml +++ b/charts/assertoor/templates/ingress.yaml @@ -77,7 +77,7 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: - name: {{ $fullName }} + name: {{ $fullName }}-admin labels: {{- include "assertoor.labels" . | nindent 4 }} {{- with .Values.ingressAdmin.annotations }} From f81537e62c3f4ef2718c992246a5fd10c3fa07c3 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 8 Aug 2024 16:12:44 +0200 Subject: [PATCH 5/5] fix ci --- charts/assertoor/templates/tests/test-connection.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/assertoor/templates/tests/test-connection.yaml b/charts/assertoor/templates/tests/test-connection.yaml index cfd651b0..c24424e1 100644 --- a/charts/assertoor/templates/tests/test-connection.yaml +++ b/charts/assertoor/templates/tests/test-connection.yaml @@ -15,5 +15,5 @@ spec: - --location - --request - GET - - '{{ include "assertoor.fullname" . }}:{{ include "assertoor.httpPort" . }}/' + - '{{ include "assertoor.fullname" . }}:{{ include "assertoor.httpPortAdmin" . }}/' restartPolicy: Never