From 91cb1976d7791ba03087a13b53b44d86e2ba7e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20Vandot?= Date: Sat, 13 Apr 2024 21:05:22 +0200 Subject: [PATCH] chore: add chart for bee-localchain (#205) --- .github/workflows/lint-test.yaml | 6 +- .github/workflows/release.yaml | 6 +- README.md | 1 + charts/bee-localchain/.helmignore | 23 +++++ charts/bee-localchain/Chart.yaml | 17 ++++ charts/bee-localchain/README.md | 99 +++++++++++++++++++ charts/bee-localchain/templates/NOTES.txt | 21 ++++ charts/bee-localchain/templates/_helpers.tpl | 63 ++++++++++++ .../bee-localchain/templates/deployment.yaml | 63 ++++++++++++ charts/bee-localchain/templates/hpa.yaml | 28 ++++++ charts/bee-localchain/templates/ingress.yaml | 45 +++++++++ charts/bee-localchain/templates/service.yaml | 15 +++ .../templates/serviceaccount.yaml | 12 +++ charts/bee-localchain/values.yaml | 83 ++++++++++++++++ charts/bee/Chart.yaml | 4 +- 15 files changed, 478 insertions(+), 8 deletions(-) create mode 100644 charts/bee-localchain/.helmignore create mode 100644 charts/bee-localchain/Chart.yaml create mode 100644 charts/bee-localchain/README.md create mode 100644 charts/bee-localchain/templates/NOTES.txt create mode 100644 charts/bee-localchain/templates/_helpers.tpl create mode 100644 charts/bee-localchain/templates/deployment.yaml create mode 100644 charts/bee-localchain/templates/hpa.yaml create mode 100644 charts/bee-localchain/templates/ingress.yaml create mode 100644 charts/bee-localchain/templates/service.yaml create mode 100644 charts/bee-localchain/templates/serviceaccount.yaml create mode 100644 charts/bee-localchain/values.yaml diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 97b954c..59a72f3 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -7,12 +7,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up chart-testing - uses: helm/chart-testing-action@v2.2.1 + uses: helm/chart-testing-action@v2.6.1 - name: Run chart-testing (list-changed) id: list-changed @@ -26,7 +26,7 @@ jobs: run: ct lint - name: Create kind cluster - uses: helm/kind-action@v1.2.0 + uses: helm/kind-action@v1.9.0 if: steps.list-changed.outputs.changed == 'true' - name: Run chart-testing (install) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 62ec36a..e063f94 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -20,11 +20,11 @@ jobs: git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - name: Install Helm - uses: azure/setup-helm@v1 + uses: azure/setup-helm@v4 with: version: v3.6.3 - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.4.0 + uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.CR_TOKEN }}" diff --git a/README.md b/README.md index ebe5564..f1d4c5a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This repo contains Ethersphere Helm Charts: * [beekeeper](https://github.com/ethersphere/helm/tree/master/charts/beekeeper) * [eks-local-disk-provisioner](https://github.com/ethersphere/helm/tree/master/charts/eks-local-disk-provisioner) * [geth-swap](https://github.com/ethersphere/helm/tree/master/charts/geth-swap) +* [bee-localchain](https://github.com/ethersphere/helm/tree/master/charts/bee-localchain) * [tokenexporter](https://github.com/ethersphere/helm/tree/master/charts/tokenexporter) * [ethexporter](https://github.com/ethersphere/helm/tree/master/charts/ethexporter) * [nethermind](https://github.com/ethersphere/helm/tree/master/charts/nethermind) diff --git a/charts/bee-localchain/.helmignore b/charts/bee-localchain/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/bee-localchain/.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/bee-localchain/Chart.yaml b/charts/bee-localchain/Chart.yaml new file mode 100644 index 0000000..1e6dc10 --- /dev/null +++ b/charts/bee-localchain/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +appVersion: latest +name: bee-localchain +version: 0.1.0 +description: BZZ Token Service Helm chart for Kubernetes +home: https://www.ethswarm.org +icon: https://docs.ethswarm.org/img/swarm-logo-2.svg +keywords: + - blockchain + - ethereum + - bee +maintainers: + - name: vandot + email: vandot@ethswarm.org +sources: + - https://github.com/ethersphere/bee-localchain +type: application diff --git a/charts/bee-localchain/README.md b/charts/bee-localchain/README.md new file mode 100644 index 0000000..7bcbfd8 --- /dev/null +++ b/charts/bee-localchain/README.md @@ -0,0 +1,99 @@ +# Bee localchain Helm Chart + +[Bee localchain](https://github.com/ethersphere/bee-localchain) 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/bee-localchain +``` + +## Introduction + +This chart deploys a [Bee localchain](https://github.com/ethersphere/bee-localchain) 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/bee-localchain +``` + +The command deploys Bee localchain 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 bee-localchain.yaml file as shown bellow: + +```yaml +namespaces: + bee-localchain: + +helmRepos: + ethersphere: "https://ethersphere.github.io/helm" + +apps: + bee-localchain: + name: bee-localchain + namespace: bee-localchain + description: "Bee localchain" + chart: "ethersphere/bee-localchain" + version: "0.1.0" + enabled: true + wait: true + timeout: 120 + +``` + +Execute following command: +```bash +$ helmsman -apply -f bee-localchain.yaml +``` + +### Uninstalling + +Execute following command: +```bash +$ helmsman -destroy -f bee-localchain.yaml +``` diff --git a/charts/bee-localchain/templates/NOTES.txt b/charts/bee-localchain/templates/NOTES.txt new file mode 100644 index 0000000..5c8fa77 --- /dev/null +++ b/charts/bee-localchain/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 "bee-localchain.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 "bee-localchain.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bee-localchain.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 "bee-localchain.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Use http://127.0.0.1:8545 to access your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8545:8545 +{{- end }} diff --git a/charts/bee-localchain/templates/_helpers.tpl b/charts/bee-localchain/templates/_helpers.tpl new file mode 100644 index 0000000..7056bac --- /dev/null +++ b/charts/bee-localchain/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "bee-localchain.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 "bee-localchain.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 "bee-localchain.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "bee-localchain.labels" -}} +helm.sh/chart: {{ include "bee-localchain.chart" . }} +{{ include "bee-localchain.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "bee-localchain.selectorLabels" -}} +app.kubernetes.io/name: {{ include "bee-localchain.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "bee-localchain.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "bee-localchain.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/bee-localchain/templates/deployment.yaml b/charts/bee-localchain/templates/deployment.yaml new file mode 100644 index 0000000..061fa19 --- /dev/null +++ b/charts/bee-localchain/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "bee-localchain.fullname" . }} + labels: + {{- include "bee-localchain.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + strategy: + {{- toYaml .Values.strategy | nindent 4 }} + selector: + matchLabels: + {{- include "bee-localchain.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bee-localchain.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "bee-localchain.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 }} + ports: + - name: rpc + containerPort: 8545 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: rpc + readinessProbe: + httpGet: + path: / + port: rpc + 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/bee-localchain/templates/hpa.yaml b/charts/bee-localchain/templates/hpa.yaml new file mode 100644 index 0000000..3f99842 --- /dev/null +++ b/charts/bee-localchain/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "bee-localchain.fullname" . }} + labels: + {{- include "bee-localchain.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "bee-localchain.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/bee-localchain/templates/ingress.yaml b/charts/bee-localchain/templates/ingress.yaml new file mode 100644 index 0000000..3ab78cf --- /dev/null +++ b/charts/bee-localchain/templates/ingress.yaml @@ -0,0 +1,45 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "bee-localchain.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- 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 "bee-localchain.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/bee-localchain/templates/service.yaml b/charts/bee-localchain/templates/service.yaml new file mode 100644 index 0000000..be10678 --- /dev/null +++ b/charts/bee-localchain/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bee-localchain.fullname" . }} + labels: + {{- include "bee-localchain.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: rpc + protocol: TCP + name: rpc + selector: + {{- include "bee-localchain.selectorLabels" . | nindent 4 }} diff --git a/charts/bee-localchain/templates/serviceaccount.yaml b/charts/bee-localchain/templates/serviceaccount.yaml new file mode 100644 index 0000000..47eeac7 --- /dev/null +++ b/charts/bee-localchain/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "bee-localchain.serviceAccountName" . }} + labels: + {{- include "bee-localchain.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/bee-localchain/values.yaml b/charts/bee-localchain/values.yaml new file mode 100644 index 0000000..aa643dc --- /dev/null +++ b/charts/bee-localchain/values.yaml @@ -0,0 +1,83 @@ +# Default values for bee-localchain. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ethersphere/bee-localchain + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart version. + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # 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: 8545 + +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 diff --git a/charts/bee/Chart.yaml b/charts/bee/Chart.yaml index 8897f5e..db22fcf 100644 --- a/charts/bee/Chart.yaml +++ b/charts/bee/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 -appVersion: 1.17.6 +appVersion: 2.0.0 name: bee -version: 0.14.4 +version: 0.15.0 kubeVersion: ">=1.19.0-0" description: Ethereum Swarm Bee Helm chart for Kubernetes home: https://www.ethswarm.org