From 590140ae3923ea6ce7a599f0eaf338ca061da329 Mon Sep 17 00:00:00 2001 From: Wesley Charles Blake Date: Wed, 17 Jan 2024 17:25:14 +0200 Subject: [PATCH] [sc-3400]: refactor gofer chart to allow some override (#114) * [sc-3400]: refactor gofer chart to allow some override * update image * fix test connection --- charts/gofer/Chart.yaml | 4 +-- charts/gofer/README.md | 16 ++++++++--- charts/gofer/ci/agent-values.yaml | 1 + charts/gofer/ci/watch-values.yaml | 8 ++++++ charts/gofer/templates/deployment.yaml | 28 +++++++++---------- charts/gofer/templates/service.yaml | 10 ++++--- .../templates/tests/test-connection.yaml | 10 +++++-- charts/gofer/values.yaml | 24 ++++++++++++++-- 8 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 charts/gofer/ci/agent-values.yaml create mode 100644 charts/gofer/ci/watch-values.yaml diff --git a/charts/gofer/Chart.yaml b/charts/gofer/Chart.yaml index af050bf8..02842430 100644 --- a/charts/gofer/Chart.yaml +++ b/charts/gofer/Chart.yaml @@ -21,10 +21,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.0.4 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.10.0" +appVersion: "0.29" diff --git a/charts/gofer/README.md b/charts/gofer/README.md index 7d4b198b..552fc3e3 100644 --- a/charts/gofer/README.md +++ b/charts/gofer/README.md @@ -1,6 +1,6 @@ # gofer -![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) ![AppVersion: 0.10.0](https://img.shields.io/badge/AppVersion-0.10.0-informational?style=flat-square) +![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.29](https://img.shields.io/badge/AppVersion-0.29-informational?style=flat-square) A Helm chart for deploying gofer to Kubernetes @@ -21,11 +21,12 @@ A Helm chart for deploying gofer to Kubernetes | autoscaling.minReplicas | int | `1` | | | autoscaling.targetCPUUtilizationPercentage | int | `80` | | | configHcl | object | `{}` | | -| env | object | `{}` | | +| env | object | `{}` | Environment variable listing | | fullnameOverride | string | `""` | | +| goferMode | string | `"agent"` | can be "agent" or "watch" | | image.pullPolicy | string | `"IfNotPresent"` | | | image.repository | string | `"ghcr.io/chronicleprotocol/gofer"` | | -| image.tag | string | `"sha-7375716"` | | +| image.tag | string | `"sha-f2a5f01"` | | | imagePullSecrets | list | `[]` | | | ingress.annotations | object | `{}` | | | ingress.className | string | `""` | | @@ -34,15 +35,22 @@ A Helm chart for deploying gofer to Kubernetes | ingress.hosts[0].paths[0].path | string | `"/"` | | | ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | | ingress.tls | list | `[]` | | +| livenessProbe.initialDelaySeconds | int | `60` | | +| livenessProbe.periodSeconds | int | `120` | | +| livenessProbe.tcpSocket.port | string | `"gofer"` | | | logLevel | string | `"debug"` | | | nameOverride | string | `""` | | | nodeSelector | object | `{}` | | | podAnnotations | object | `{}` | | | podSecurityContext | object | `{}` | | +| readinessProbe.initialDelaySeconds | int | `10` | | +| readinessProbe.periodSeconds | int | `10` | | +| readinessProbe.tcpSocket.port | string | `"gofer"` | | | replicaCount | int | `1` | | | resources | object | `{}` | | | securityContext | object | `{}` | | -| service.port | int | `9200` | | +| service.ports.gofer.port | int | `9090` | | +| service.ports.gofer.protocol | string | `"TCP"` | | | service.type | string | `"ClusterIP"` | | | serviceAccount.annotations | object | `{}` | | | serviceAccount.create | bool | `true` | | diff --git a/charts/gofer/ci/agent-values.yaml b/charts/gofer/ci/agent-values.yaml new file mode 100644 index 00000000..ffebc811 --- /dev/null +++ b/charts/gofer/ci/agent-values.yaml @@ -0,0 +1 @@ +goferMode: "agent" diff --git a/charts/gofer/ci/watch-values.yaml b/charts/gofer/ci/watch-values.yaml new file mode 100644 index 00000000..00d49e1a --- /dev/null +++ b/charts/gofer/ci/watch-values.yaml @@ -0,0 +1,8 @@ +goferMode: "watch" + +env: + normal: + WATCHDOG_CHAIN_RPC_URLS: "https://rpc.testnet.chroniclelabs.io/sep" + WATCHDOG_CONFIG_REGISTRY: 0xE1CcD31f46F30A764DbACB4759E69d8799126941 + WATCHDOG_INTERVAL: 60s + WATCHDOG_ETH_FROM: "0x0000000000000000000000000000000000000000" diff --git a/charts/gofer/templates/deployment.yaml b/charts/gofer/templates/deployment.yaml index afed3968..3e5a7ac6 100644 --- a/charts/gofer/templates/deployment.yaml +++ b/charts/gofer/templates/deployment.yaml @@ -37,24 +37,20 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.configHcl }} - args: [ "-c", "/config/gofer.hcl", "agent", "-v", "{{ .Values.logLevel | default "debug" }}"] + args: [ "-c", "/config/gofer.hcl", "{{ .Values.goferMode }}", "-v", "{{ .Values.logLevel | default "debug" }}"] {{- else }} - args: ["agent", "-v", "{{ .Values.logLevel | default "debug" }}"] + args: ["{{ .Values.goferMode }}", "-v", "{{ .Values.logLevel | default "debug" }}"] {{- end }} ports: - - name: listener - containerPort: {{ .Values.service.port }} - protocol: TCP - # readinessProbe: - # tcpSocket: - # port: {{ .Values.service.port }} - # initialDelaySeconds: 5 - # periodSeconds: 10 - # livenessProbe: - # tcpSocket: - # port: {{ .Values.service.port }} - # initialDelaySeconds: 15 - # periodSeconds: 20 + {{- range $key, $val := .Values.service.ports }} + - name: {{ $key }} + containerPort: {{ $val.port }} + protocol: {{ $val.protocol }} + {{- end }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: @@ -67,9 +63,11 @@ spec: {{- include "helpers.list-env-variables" . | indent 12 }} volumes: + {{- if .Values.configHcl }} - name: config configMap: name: {{ include "gofer.fullname" . -}}-config + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/gofer/templates/service.yaml b/charts/gofer/templates/service.yaml index 3a00fcbe..525ea42f 100644 --- a/charts/gofer/templates/service.yaml +++ b/charts/gofer/templates/service.yaml @@ -7,9 +7,11 @@ metadata: spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.service.port }} - targetPort: listener - protocol: TCP - name: listener + {{- range $key, $val := .Values.service.ports }} + - port: {{ $val.port }} + targetPort: {{ $val.port }} + protocol: {{ $val.protocol }} + name: {{ $key }} + {{- end }} selector: {{- include "gofer.selectorLabels" . | nindent 4 }} diff --git a/charts/gofer/templates/tests/test-connection.yaml b/charts/gofer/templates/tests/test-connection.yaml index 94e93150..0d7f82a2 100644 --- a/charts/gofer/templates/tests/test-connection.yaml +++ b/charts/gofer/templates/tests/test-connection.yaml @@ -8,11 +8,15 @@ metadata: "helm.sh/hook": test spec: containers: - - name: nc + {{- $serviceName := include "gofer.fullname" . }} + {{- range $name, $config := .Values.service.ports }} + - name: nc-{{ $name }} image: busybox command: ['nc'] args: - '-zv' - - '{{ include "gofer.fullname" . }}' - - '{{ .Values.service.port }}' + - '-v' + - '{{ $serviceName }}' + - '{{ $config.port }}' + {{- end }} restartPolicy: Never diff --git a/charts/gofer/values.yaml b/charts/gofer/values.yaml index dec59e62..f9651cae 100644 --- a/charts/gofer/values.yaml +++ b/charts/gofer/values.yaml @@ -5,8 +5,10 @@ replicaCount: 1 logLevel: "debug" +# -- can be "agent" or "watch" +goferMode: "agent" -# Environment variable listing +# -- Environment variable listing env: {} # non sensitive variables # refer to https://github.com/chronicleprotocol/oracle-suite/tree/master/cmd/gofer#environment-variables @@ -17,7 +19,7 @@ image: repository: ghcr.io/chronicleprotocol/gofer pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "sha-7375716" + tag: "sha-f2a5f01" imagePullSecrets: [] nameOverride: "" @@ -47,7 +49,10 @@ securityContext: {} service: type: ClusterIP - port: 9200 + ports: + gofer: + port: 9090 + protocol: TCP ingress: enabled: false @@ -65,6 +70,19 @@ ingress: # hosts: # - chart-example.local +# @default -- See `values.yaml` +livenessProbe: + tcpSocket: + port: gofer + initialDelaySeconds: 60 + periodSeconds: 120 + +# @default -- See `values.yaml` +readinessProbe: + tcpSocket: + port: gofer + initialDelaySeconds: 10 + periodSeconds: 10 resources: {} # We usually recommend not to specify default resources and to leave this as a conscious