From c7805268c7dc931cd09670c720af4970366398f2 Mon Sep 17 00:00:00 2001 From: Ivan Vandot Date: Tue, 12 Sep 2023 21:38:21 +0200 Subject: [PATCH] feat: add etherproxy helm chart --- charts/etherproxy/.helmignore | 23 +++++ charts/etherproxy/Chart.yaml | 17 ++++ charts/etherproxy/README.md | 99 +++++++++++++++++++ charts/etherproxy/templates/NOTES.txt | 21 ++++ charts/etherproxy/templates/_helpers.tpl | 63 ++++++++++++ charts/etherproxy/templates/config.yaml | 10 ++ charts/etherproxy/templates/deployment.yaml | 66 +++++++++++++ charts/etherproxy/templates/hpa.yaml | 28 ++++++ charts/etherproxy/templates/ingress.yaml | 45 +++++++++ charts/etherproxy/templates/service.yaml | 15 +++ .../etherproxy/templates/serviceaccount.yaml | 12 +++ charts/etherproxy/values.yaml | 88 +++++++++++++++++ charts/geth-swap/Chart.yaml | 2 +- charts/geth-swap/values.yaml | 2 +- 14 files changed, 489 insertions(+), 2 deletions(-) create mode 100644 charts/etherproxy/.helmignore create mode 100644 charts/etherproxy/Chart.yaml create mode 100644 charts/etherproxy/README.md create mode 100644 charts/etherproxy/templates/NOTES.txt create mode 100644 charts/etherproxy/templates/_helpers.tpl create mode 100644 charts/etherproxy/templates/config.yaml create mode 100644 charts/etherproxy/templates/deployment.yaml create mode 100644 charts/etherproxy/templates/hpa.yaml create mode 100644 charts/etherproxy/templates/ingress.yaml create mode 100644 charts/etherproxy/templates/service.yaml create mode 100644 charts/etherproxy/templates/serviceaccount.yaml create mode 100644 charts/etherproxy/values.yaml diff --git a/charts/etherproxy/.helmignore b/charts/etherproxy/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/etherproxy/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/etherproxy/Chart.yaml b/charts/etherproxy/Chart.yaml new file mode 100644 index 0000000..3f4fe9d --- /dev/null +++ b/charts/etherproxy/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +appVersion: latest +name: etherproxy +version: 0.1.0 +description: EtherProxy Helm chart for Kubernetes +home: https://www.ethswarm.org +icon: https://docs.ethswarm.org/img/swarm-logo-2.svg +keywords: + - blockchain + - ethereum + - proxy +maintainers: + - name: vandot + email: vandot@ethswarm.org +sources: + - https://github.com/ethersphere/etherproxy +type: application diff --git a/charts/etherproxy/README.md b/charts/etherproxy/README.md new file mode 100644 index 0000000..8ef2075 --- /dev/null +++ b/charts/etherproxy/README.md @@ -0,0 +1,99 @@ +# EtherProxy Helm Chart + +[EtherProxy](https://github.com/ethersphere/etherproxy) is a lightweight Prometheus proxy that will output Ethereum wallet balances from a list of addresses you specify. + +## Prerequisites + +Make sure you have Helm [installed](https://helm.sh/docs/intro/install/) installed. + +## Get Repo Info + +```bash +helm repo add ethersphere https://ethersphere.github.io/helm +helm repo update +``` + +_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._ + +## QuickStart + +```bash +$ helm install --generate-name ethersphere/etherproxy +``` + +## Introduction + +This chart deploys a [EtherProxy](https://github.com/ethersphere/etherproxy) onto a Kubernetes cluster using the Helm package manager. + +## Prerequisites + +* Kubernetes 1.15 +* Helm 3.0 + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install my-release ethersphere/etherproxy +``` + +The command deploys EtherProxy on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The default configuration values for this chart are listed in **values.yaml**. + +## Helmsman Usage + +### Prerequisites + +* Kubernetes 1.15 +* Helm 3.0 +* Helmsman 3.0 + +### Installing + +Create etherproxy.yaml file as shown bellow: + +```yaml +namespaces: + etherproxy: + +helmRepos: + ethersphere: "https://ethersphere.github.io/helm" + +apps: + etherproxy: + name: etherproxy + namespace: etherproxy + description: "EtherProxy" + chart: "ethersphere/etherproxy" + version: "0.1.0" + enabled: true + wait: true + timeout: 120 + +``` + +Execute following command: +```bash +$ helmsman -apply -f etherproxy.yaml +``` + +### Uninstalling + +Execute following command: +```bash +$ helmsman -destroy -f etherproxy.yaml +``` diff --git a/charts/etherproxy/templates/NOTES.txt b/charts/etherproxy/templates/NOTES.txt new file mode 100644 index 0000000..f949482 --- /dev/null +++ b/charts/etherproxy/templates/NOTES.txt @@ -0,0 +1,21 @@ +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 }}{{ . }} + {{- 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 "etherproxy.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 "etherproxy.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "etherproxy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "etherproxy.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:{{ .Values.service.port }} +{{- end }} diff --git a/charts/etherproxy/templates/_helpers.tpl b/charts/etherproxy/templates/_helpers.tpl new file mode 100644 index 0000000..01978e8 --- /dev/null +++ b/charts/etherproxy/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "etherproxy.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "etherproxy.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "etherproxy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "etherproxy.labels" -}} +helm.sh/chart: {{ include "etherproxy.chart" . }} +{{ include "etherproxy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "etherproxy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "etherproxy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "etherproxy.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "etherproxy.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/etherproxy/templates/config.yaml b/charts/etherproxy/templates/config.yaml new file mode 100644 index 0000000..047af8d --- /dev/null +++ b/charts/etherproxy/templates/config.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "etherproxy.fullname" . }} + labels: + {{- include "etherproxy.labels" . | nindent 4 }} +data: + ETHERPROXY_PORT: {{ .Values.service.port | quote }} + ETHERPROXY_TARGET: {{ .Values.config.ETHERPROXY_TARGET | quote }} + ETHERPROXY_EXPIRY: {{ .Values.config.ETHERPROXY_EXPIRY | quote }} diff --git a/charts/etherproxy/templates/deployment.yaml b/charts/etherproxy/templates/deployment.yaml new file mode 100644 index 0000000..29d6931 --- /dev/null +++ b/charts/etherproxy/templates/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "etherproxy.fullname" . }} + labels: + {{- include "etherproxy.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + strategy: + {{- toYaml .Values.strategy | nindent 4 }} + selector: + matchLabels: + {{- include "etherproxy.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "etherproxy.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "etherproxy.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "etherproxy.fullname" . }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /health + port: http + readinessProbe: + httpGet: + path: /readiness + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/etherproxy/templates/hpa.yaml b/charts/etherproxy/templates/hpa.yaml new file mode 100644 index 0000000..f595bc1 --- /dev/null +++ b/charts/etherproxy/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "etherproxy.fullname" . }} + labels: + {{- include "etherproxy.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "etherproxy.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/etherproxy/templates/ingress.yaml b/charts/etherproxy/templates/ingress.yaml new file mode 100644 index 0000000..9116bd5 --- /dev/null +++ b/charts/etherproxy/templates/ingress.yaml @@ -0,0 +1,45 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "etherproxy.fullname" . -}} +{{- $svcPort := .Values.service.portAPI -}} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version -}} +apiVersion: networking.k8s.io/v1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "etherproxy.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.class }} + {{- 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: {{ . }} + pathType: ImplementationSpecific + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/charts/etherproxy/templates/service.yaml b/charts/etherproxy/templates/service.yaml new file mode 100644 index 0000000..abe7643 --- /dev/null +++ b/charts/etherproxy/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "etherproxy.fullname" . }} + labels: + {{- include "etherproxy.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "etherproxy.selectorLabels" . | nindent 4 }} diff --git a/charts/etherproxy/templates/serviceaccount.yaml b/charts/etherproxy/templates/serviceaccount.yaml new file mode 100644 index 0000000..59e8a72 --- /dev/null +++ b/charts/etherproxy/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "etherproxy.serviceAccountName" . }} + labels: + {{- include "etherproxy.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/etherproxy/values.yaml b/charts/etherproxy/values.yaml new file mode 100644 index 0000000..aae5fb6 --- /dev/null +++ b/charts/etherproxy/values.yaml @@ -0,0 +1,88 @@ +# Default values for etherproxy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ethersphere/etherproxy + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart version. + tag: 1.0.0 + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 9000 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + class: "" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # If you do want to specify resources, uncomment the following lines, + # adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 300m + # ephemeral-storage: 2Gi + # memory: 512Mi + # requests: + # cpu: 300m + # ephemeral-storage: 512Mi + # memory: 512Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +strategy: + type: Recreate + +# environment variables +config: + ETHERPROXY_TARGET: "https://rpc.gnosischain.com/" + ETHERPROXY_EXPIRY: "2000" diff --git a/charts/geth-swap/Chart.yaml b/charts/geth-swap/Chart.yaml index 7e29dd7..8ea6b48 100644 --- a/charts/geth-swap/Chart.yaml +++ b/charts/geth-swap/Chart.yaml @@ -20,7 +20,7 @@ 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. -version: 0.4.0 +version: 0.4.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. diff --git a/charts/geth-swap/values.yaml b/charts/geth-swap/values.yaml index 32a33a6..7f5930a 100644 --- a/charts/geth-swap/values.yaml +++ b/charts/geth-swap/values.yaml @@ -90,7 +90,7 @@ etherProxy: image: repository: ethersphere/etherproxy - tag: "1.3.0" + tag: "1.0.0" pullPolicy: IfNotPresent # digest: