From 992a71782f3f6d97dc93e3f6d38358217f8130b2 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 16 Apr 2024 14:20:08 +0200 Subject: [PATCH] feat: add nodeport config to dugtrio --- charts/dugtrio/Chart.yaml | 2 +- charts/dugtrio/README.md | 11 ++++++-- charts/dugtrio/templates/NOTES.txt | 22 --------------- .../dugtrio/templates/service.nodeport.yaml | 23 +++++++++++++++ charts/dugtrio/templates/service.yaml | 2 +- charts/dugtrio/values.yaml | 28 +++++++++++++++++-- 6 files changed, 59 insertions(+), 29 deletions(-) delete mode 100644 charts/dugtrio/templates/NOTES.txt create mode 100644 charts/dugtrio/templates/service.nodeport.yaml diff --git a/charts/dugtrio/Chart.yaml b/charts/dugtrio/Chart.yaml index 331dc248..1f37a984 100644 --- a/charts/dugtrio/Chart.yaml +++ b/charts/dugtrio/Chart.yaml @@ -6,7 +6,7 @@ home: https://github.com/ethpandaops/dugtrio sources: - https://github.com/ethpandaops/dugtrio type: application -version: 0.0.4 +version: 0.0.5 appVersion: "1.0.0" maintainers: - name: pk910 diff --git a/charts/dugtrio/README.md b/charts/dugtrio/README.md index f1bbafbf..c3c0ba0f 100644 --- a/charts/dugtrio/README.md +++ b/charts/dugtrio/README.md @@ -1,7 +1,7 @@ # dugtrio -![Version: 0.0.4](https://img.shields.io/badge/Version-0.0.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) +![Version: 0.0.5](https://img.shields.io/badge/Version-0.0.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) Fault tolerant load balancer for beacon chain RPC apis @@ -35,6 +35,14 @@ endpoints: | Key | Type | Default | Description | |-----|------|---------|-------------| +| NodePort.enabled | bool | `false` | Expose P2P port via NodePort | +| NodePort.initContainer.image.pullPolicy | string | `"IfNotPresent"` | Container pull policy | +| NodePort.initContainer.image.repository | string | `"lachlanevenson/k8s-kubectl"` | Container image to fetch nodeport information | +| NodePort.initContainer.image.tag | string | `"v1.25.4"` | Container tag | +| NodePort.port | int | `31000` | NodePort to be used | +| NodePort.portForwardContainer.image.pullPolicy | string | `"IfNotPresent"` | Container pull policy | +| NodePort.portForwardContainer.image.repository | string | `"alpine/socat"` | Container image for the port forwarder | +| NodePort.portForwardContainer.image.tag | string | `"latest"` | Container tag | | affinity | object | `{}` | Affinity configuration for pods | | annotations | object | `{}` | Annotations for the StatefulSet | | config | string | See `values.yaml` | Config file | @@ -80,7 +88,6 @@ endpoints: | priorityClassName | string | `nil` | Pod priority class | | resources | object | `{}` | Resource requests and limits | | securityContext | object | See `values.yaml` | The security context for pods | -| service.type | string | `"ClusterIP"` | Service type | | serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | diff --git a/charts/dugtrio/templates/NOTES.txt b/charts/dugtrio/templates/NOTES.txt deleted file mode 100644 index 14ce3e48..00000000 --- a/charts/dugtrio/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dugtrio.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dugtrio.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dugtrio.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ include "dugtrio.httpPort" . }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dugtrio.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/charts/dugtrio/templates/service.nodeport.yaml b/charts/dugtrio/templates/service.nodeport.yaml new file mode 100644 index 00000000..fc22606c --- /dev/null +++ b/charts/dugtrio/templates/service.nodeport.yaml @@ -0,0 +1,23 @@ +{{- if .Values.NodePort.enabled -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dugtrio.fullname" $ }}-nodeport-0 + labels: + {{- include "dugtrio.labels" $ | nindent 4 }} + pod: {{ include "dugtrio.fullname" $ }}-0 + type: nodeport +spec: + type: NodePort + externalTrafficPolicy: Local + ports: + - name: nodeport-tcp + port: {{ .Values.httpPort }} + protocol: TCP + targetPort: http + nodePort: {{ .Values.NodePort.port }} + selector: + {{- include "dugtrio.selectorLabels" $ | nindent 4 }} + statefulset.kubernetes.io/pod-name: "{{ include "dugtrio.fullname" $ }}-0" +{{- end }} diff --git a/charts/dugtrio/templates/service.yaml b/charts/dugtrio/templates/service.yaml index f23181e7..fe813eeb 100644 --- a/charts/dugtrio/templates/service.yaml +++ b/charts/dugtrio/templates/service.yaml @@ -5,7 +5,7 @@ metadata: labels: {{- include "dugtrio.labels" . | nindent 4 }} spec: - type: {{ .Values.service.type }} + type: ClusterIP ports: - port: {{ include "dugtrio.httpPort" . }} targetPort: http diff --git a/charts/dugtrio/values.yaml b/charts/dugtrio/values.yaml index 4c7ca475..db24ac52 100644 --- a/charts/dugtrio/values.yaml +++ b/charts/dugtrio/values.yaml @@ -36,9 +36,31 @@ ingress: # hosts: # - chart-example.local -service: - # -- Service type - type: ClusterIP +# When NodePort is enabled, your port will be exposed via service type NodePort. +# This is useful if you want to expose the load balancer to the Internet, or other machines on your network. +# Limitation: You can only one have one replica when exposing via NodePort. +# Check the chart README.md for more details +NodePort: + # -- Expose P2P port via NodePort + enabled: false + # -- NodePort to be used + port: 31000 + initContainer: + image: + # -- Container image to fetch nodeport information + repository: lachlanevenson/k8s-kubectl + # -- Container tag + tag: v1.25.4 + # -- Container pull policy + pullPolicy: IfNotPresent + portForwardContainer: + image: + # -- Container image for the port forwarder + repository: alpine/socat + # -- Container tag + tag: latest + # -- Container pull policy + pullPolicy: IfNotPresent # -- Affinity configuration for pods affinity: {}