diff --git a/.github/chart-release.config.js b/.github/chart-release.config.js new file mode 100644 index 0000000..1f04533 --- /dev/null +++ b/.github/chart-release.config.js @@ -0,0 +1,38 @@ +const path = require('path'); + +module.exports = { + branches: ['main'], + tagFormat: '${CHART_NAME}-v${version}', + plugins: [ + ['@semantic-release/commit-analyzer', { + preset: 'conventionalcommits', + releaseRules: [ + { type: 'feat', release: 'minor' }, + { type: 'fix', release: 'patch' }, + ], + }], + '@semantic-release/release-notes-generator', + ['@semantic-release/changelog', { + changelogFile: 'CHANGELOG.md', + }], + ['@semantic-release/git', { + assets: ['CHANGELOG.md', 'Chart.yaml'], + message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}', + }], + ['@semantic-release/github', { + assets: [ + { path: '${CHART_NAME}-${nextRelease.version}.tgz', label: '${CHART_NAME} Chart' }, + ], + }], + ], + prepare: [ + { + path: '@semantic-release/exec', + cmd: 'sed -i "s/^version:.*$/version: ${nextRelease.version}/" Chart.yaml', + }, + { + path: '@semantic-release/exec', + cmd: 'helm package . --version ${nextRelease.version} --app-version ${nextRelease.version}', + }, + ], +}; diff --git a/.github/workflows/release-and-deploy.yml b/.github/workflows/release-and-deploy.yml new file mode 100644 index 0000000..65f2e1a --- /dev/null +++ b/.github/workflows/release-and-deploy.yml @@ -0,0 +1,194 @@ +name: Release Charts and Deploy to GitHub Pages + +on: + push: + branches: + - main + +jobs: + check-changes: + runs-on: ubuntu-latest + outputs: + changes_detected: ${{ steps.check.outputs.changes_detected }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Check for changes in Helm charts + id: check + run: | + # Find all directories containing Chart.yaml + chart_dirs=$(find ./charts -name Chart.yaml -exec dirname {} \;) + + changes_detected=false + for dir in $chart_dirs; do + if git diff --quiet HEAD^ HEAD -- "$dir"; then + echo "No changes in $dir" + else + echo "Changes detected in $dir" + changes_detected=true + break + fi + done + + echo "changes_detected=$changes_detected" >> $GITHUB_OUTPUT + + release-charts: + needs: check-changes + if: needs.check-changes.outputs.changes_detected == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Add dependency repositories + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies + run: npm install @semantic-release/git @semantic-release/changelog @semantic-release/exec conventional-changelog-conventionalcommits + + - name: Release charts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mkdir -p release + chart_dirs=$(find ./charts -name Chart.yaml -exec dirname {} \;) + for dir in $chart_dirs; do + echo "Checking for changes in ${dir}" + if git diff --quiet HEAD^ HEAD -- "${dir}"; then + echo "No changes in ${dir}, skipping release" + else + echo "Changes detected in ${dir}, releasing chart" + cd "${dir}" + export CHART_PATH=$(pwd) + export CHART_NAME=$(basename $(pwd)) + npx semantic-release -e ../../.github/chart-release.config.js + helm package . --destination ../release/ + cd $GITHUB_WORKSPACE + fi + done + + - name: Upload release as artifact + uses: actions/upload-artifact@v3 + with: + name: release + path: release + + generate-index: + needs: release-charts + if: needs.check-changes.outputs.changes_detected == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Install yq + run: | + sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + + - name: Generate Helm repo index and README + run: | + mkdir -p ./release/images + cp -r docs/images/* ./release/images/ + helm repo index ./release --url https://${{ github.repository_owner }}.github.io/cosmos-helm-charts/ + + # Get list of charts + charts=$(find ./charts -name Chart.yaml -exec dirname {} \; | sed 's/.\///') + + # Generate chart info + chart_info="" + for chart in $charts; do + if [ -f "${chart}/Chart.yaml" ]; then + name=$(yq e '.name' ${chart}/Chart.yaml) + # Get the latest tag for this chart, sorting by version number + version=$(git tag -l "${name}-v*" | sort -V | tail -n 1) + version=${version#${name}-v} + description=$(yq e '.description' ${chart}/Chart.yaml) + chart_info+="
" + chart_info+="

${name}

" + chart_info+="

Version: ${version}

" + chart_info+="

Description: ${description}

" + chart_info+="
" + fi + done + + # Use the template to generate index.html + cp docs/index.html.template ./release/index.html + sed -i "s|{{GITHUB_REPOSITORY_OWNER}}|${GITHUB_REPOSITORY_OWNER}|g" ./release/index.html + sed -i "s|{{AVAILABLE_CHARTS}}|${chart_info}|g" ./release/index.html + + - name: Upload release as artifact + uses: actions/upload-artifact@v3 + with: + name: release + path: release + + deploy: + needs: generate-index + if: needs.check-changes.outputs.changes_detected == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download release artifacts + uses: actions/download-artifact@v3 + with: + name: release + path: release + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./release + force_orphan: true + + verify-files: + needs: deploy + if: needs.check-changes.outputs.changes_detected == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download release artifacts + uses: actions/download-artifact@v3 + with: + name: release + path: release + + - name: Verify files + run: | + ls -l ./release + echo "Content of index.yaml:" + cat ./release/index.yaml + echo "Content of index.html:" + cat ./release/index.html diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..019ca25 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test Charts + +on: + pull_request: + branches: [main] + +jobs: + discover-charts: + runs-on: ubuntu-latest + outputs: + chart_dirs: ${{ steps.set-chart-dirs.outputs.chart_dirs }} + steps: + - uses: actions/checkout@v3 + - id: set-chart-dirs + run: | + CHART_DIRS=$(find ./charts -name Chart.yaml -exec dirname {} \; | jq -R -s -c 'split("\n")[:-1]') + echo "chart_dirs=$CHART_DIRS" >> $GITHUB_OUTPUT + + test-charts: + needs: discover-charts + runs-on: ubuntu-latest + strategy: + matrix: + chart_dir: ${{ fromJson(needs.discover-charts.outputs.chart_dirs) }} + steps: + - uses: actions/checkout@v3 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.10.0 + + - name: Run Helm lint + run: helm lint ${{ matrix.chart_dir }} -f ${{ matrix.chart_dir }}/examples/values.yaml + + - name: Run Helm template + run: helm template ${{ matrix.chart_dir }} -f ${{ matrix.chart_dir }}/examples/values.yaml + + - name: Install chart dependencies + run: | + if [ -f ${{ matrix.chart_dir }}/Chart.yaml ]; then + helm dependency update ${{ matrix.chart_dir }} + fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..abd21e8 --- /dev/null +++ b/LICENCE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 p2p.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c36dd4 --- /dev/null +++ b/README.md @@ -0,0 +1,98 @@ +

+ +

+ +

+ + + +

+ +# P2P Cosmos Helm Charts + +This repository contains Helm charts for P2P Cosmos projects. These charts are used for deploying and managing various components of the Cosmos ecosystem. + +## Adding a New Chart + +To add a new chart to this repository, follow these steps: + +1. Create a new directory for your chart: + + ``` + mkdir -p charts/my-new-chart + ``` + +2. Initialize a new Helm chart in this directory: + + ``` + helm create charts/my-new-chart + ``` + +3. Customize the chart according to your needs. Make sure to update the following files: + - `Chart.yaml`: Update metadata, especially the `name`, `description`, and `version` fields. + - `values.yaml`: Define default values for your chart. + - Templates in the `templates/` directory. + +4. Create a `.releaserc.js` file in your chart directory using an existing one as an example - you simply need to change these lines + +```js +const chartName = +``` + +```js + tagFormat: 'cosmos-operator-rpc-node-v${version}', +``` + +## Contributing + +We welcome contributions to our Helm charts! Here's how you can contribute: + +1. Create a new branch for your feature or bug fix +2. Make your changes +3. Submit a pull request + +### Conventional Commits + +We use Conventional Commits to standardize our commit messages. This helps us automatically determine version bumps and generate changelogs. Please format your commit messages as follows: + +``` +(): + +[optional body] + +[optional footer(s)] +``` + +Types: + +- `feat`: A new feature (minor version bump) +- `fix`: A bug fix (patch version bump) +- `docs`: Documentation only changes +- `style`: Changes that do not affect the meaning of the code +- `refactor`: A code change that neither fixes a bug nor adds a feature +- `perf`: A code change that improves performance +- `test`: Adding missing tests or correcting existing tests +- `chore`: Changes to the build process or auxiliary tools and libraries + +Examples: + +- `feat(allora-worker): add new configuration option for worker threads` +- `fix(cosmos-operator-rpc-node): resolve issue with persistent volume claims` +- `docs: update installation instructions in README` + +When to use each type: + +- Use `feat` when you add a new feature or significant enhancement to a chart +- Use `fix` when you fix a bug or resolve an issue in a chart +- Use `docs` for changes to documentation files (README, CONTRIBUTING, etc.) +- Use `style` for formatting changes, missing semicolons, etc. +- Use `refactor` when you restructure code without changing its behavior +- Use `perf` for performance improvements +- Use `test` when adding or modifying tests +- Use `chore` for updates to build scripts, CI configurations, etc. + +By following these conventions, you help maintain a clear and useful git history, which aids in the automatic versioning and changelog generation for our charts. + +### Testing Your Changes + +Tests are ran on PR. diff --git a/charts/allora-worker/.helmignore b/charts/allora-worker/.helmignore new file mode 100644 index 0000000..165cbb8 --- /dev/null +++ b/charts/allora-worker/.helmignore @@ -0,0 +1,31 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. + +# Ignore all .tgz files +*.tgz + +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ + +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ + +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ + +# Project specific +.releaserc.js diff --git a/charts/allora-worker/.releaserc.js b/charts/allora-worker/.releaserc.js new file mode 100644 index 0000000..25baedc --- /dev/null +++ b/charts/allora-worker/.releaserc.js @@ -0,0 +1,17 @@ +const chartName = 'allora-worker'; +const chartPath = __dirname; + +module.exports = { + extends: '../.github/chart-release.config.js', + tagFormat: 'allora-worker-v${version}', + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + '@semantic-release/changelog', + '@semantic-release/git', + '@semantic-release/github', + ['@semantic-release/exec', { + prepareCmd: 'sed -i "s/^version:.*$/version: ${nextRelease.version}/" Chart.yaml && helm package . --version ${nextRelease.version} --app-version ${nextRelease.version} && mv *.tgz ../' + }] + ] +}; diff --git a/charts/allora-worker/Chart.yaml b/charts/allora-worker/Chart.yaml new file mode 100644 index 0000000..d1f339e --- /dev/null +++ b/charts/allora-worker/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: allora-worker +description: A Helm chart for deploying an allora worker +type: application +version: 0.0.0-development +appVersion: "1.0" diff --git a/charts/allora-worker/examples/values.yaml b/charts/allora-worker/examples/values.yaml new file mode 100644 index 0000000..689629e --- /dev/null +++ b/charts/allora-worker/examples/values.yaml @@ -0,0 +1,184 @@ +# Default values for allora-worker. + +replicaCount: 1 + + +# Container configurations +containers: + main: + image: "your-image-repository:tag" + ports: + - name: http + containerPort: 8080 + protocol: TCP + resources: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "256Mi" + cpu: "200m" + command: ["./start.sh"] + args: ["--config", "/app/config.yaml"] + livenessProbe: + httpGet: + path: /healthz + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /ready + port: 8080 + initialDelaySeconds: 5 + periodSeconds: 5 + volumeMounts: + - name: data + mountPath: /app/data + env: + - name: ENV_VAR_1 + value: "value1" + - name: ENV_VAR_2 + valueFrom: + secretKeyRef: + name: my-secret + key: secret-key + envFrom: + - secretRef: + name: my-secret-env + service: + enabled: true + type: ClusterIP + port: 80 + targetPort: 8080 + +imagePullSecrets: + - name: regcred + +persistence: + enabled: true + storageClass: "standard" + accessMode: ReadWriteOnce + size: "1Gi" + +# External Secrets configuration +externalSecrets: + - name: my-external-secret + refreshInterval: 1h + secretStoreRef: + kind: ClusterSecretStore + name: secretstore-sample + target: + name: my-k8s-secret + creationPolicy: Owner + data: + - secretKey: username + remoteRef: + key: /path/to/secret + property: username + - secretKey: password + remoteRef: + key: /path/to/secret + property: password + +# Ingress configuration +ingress: + enabled: true + className: "nginx" + annotations: + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: your-domain.com + paths: + - path: / + pathType: Prefix + serviceName: main + servicePort: 80 + tls: + - secretName: your-domain-tls + hosts: + - your-domain.com + +# Affinity settings +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/e2e-az-name + operator: In + values: + - e2e-az1 + - e2e-az2 + +# Node selector +nodeSelector: + disktype: ssd + +# Tolerations +tolerations: + - key: "key1" + operator: "Equal" + value: "value1" + effect: "NoSchedule" + +# Additional labels +labels: + environment: production + team: allora + +# Pod annotations +podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8080" + +# Service account +serviceAccount: + create: true + name: "" + annotations: {} + +# Pod security context +podSecurityContext: + fsGroup: 2000 + +# Security context +securityContext: + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + +# Image pull policy +imagePullPolicy: IfNotPresent + +# Additional volumes +volumes: + - name: config + configMap: + name: allora-worker-config + +# Additional volumes +additionalVolumes: + - name: extra-config + configMap: + name: allora-worker-extra-config + +# Init containers +initContainers: + init-db: + image: busybox:1.28 + command: ['sh', '-c', 'echo "The app is running!" && sleep 10'] + volumeMounts: + - name: data + mountPath: /data + +# Deployment strategy +strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 diff --git a/charts/allora-worker/templates/_helpers.tpl b/charts/allora-worker/templates/_helpers.tpl new file mode 100644 index 0000000..e816812 --- /dev/null +++ b/charts/allora-worker/templates/_helpers.tpl @@ -0,0 +1,47 @@ +{{- define "allora-worker.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "allora-worker.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} + +{{- define "allora-worker.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "allora-worker.labels" -}} +helm.sh/chart: {{ include "allora-worker.chart" . }} +{{ include "allora-worker.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "allora-worker.selectorLabels" -}} +app.kubernetes.io/name: {{ include "allora-worker.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "allora-worker.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "allora-worker.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/allora-worker/templates/external-secrets.yaml b/charts/allora-worker/templates/external-secrets.yaml new file mode 100644 index 0000000..ec44bd1 --- /dev/null +++ b/charts/allora-worker/templates/external-secrets.yaml @@ -0,0 +1,27 @@ +{{- if .Values.externalSecrets }} +{{- range .Values.externalSecrets }} +--- +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: {{ .name }} + namespace: {{ $.Release.Namespace }} +spec: + refreshInterval: {{ .refreshInterval | default "1h" }} + secretStoreRef: + kind: {{ .secretStoreRef.kind }} + name: {{ .secretStoreRef.name }} + target: + name: {{ .target.name }} + creationPolicy: {{ .target.creationPolicy | default "Owner" }} + data: + {{- range .data }} + - secretKey: {{ .secretKey }} + remoteRef: + key: {{ .remoteRef.key }} + {{- if .remoteRef.property }} + property: {{ .remoteRef.property }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/allora-worker/templates/ingress.yaml b/charts/allora-worker/templates/ingress.yaml new file mode 100644 index 0000000..db2e46b --- /dev/null +++ b/charts/allora-worker/templates/ingress.yaml @@ -0,0 +1,42 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "allora-worker.fullname" . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "allora-worker.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ $fullName }}-{{ .serviceName }} + port: + number: {{ .servicePort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/allora-worker/templates/service-account.yaml b/charts/allora-worker/templates/service-account.yaml new file mode 100644 index 0000000..1527b23 --- /dev/null +++ b/charts/allora-worker/templates/service-account.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "allora-worker.serviceAccountName" . }} + labels: + {{- include "allora-worker.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/allora-worker/templates/service.yaml b/charts/allora-worker/templates/service.yaml new file mode 100644 index 0000000..594b4ec --- /dev/null +++ b/charts/allora-worker/templates/service.yaml @@ -0,0 +1,20 @@ +{{- range $key, $value := .Values.containers }} +{{- if $value.service.enabled }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "allora-worker.fullname" $ }}-{{ $key }} + labels: + {{- include "allora-worker.labels" $ | nindent 4 }} +spec: + type: {{ $value.service.type }} + ports: + - port: {{ $value.service.port }} + targetPort: {{ $value.service.targetPort | default $value.containerPort }} + protocol: TCP + name: {{ $key }} + selector: + {{- include "allora-worker.selectorLabels" $ | nindent 4 }} +{{- end }} +{{- end }} diff --git a/charts/allora-worker/templates/statefulset.yaml b/charts/allora-worker/templates/statefulset.yaml new file mode 100644 index 0000000..388f2c8 --- /dev/null +++ b/charts/allora-worker/templates/statefulset.yaml @@ -0,0 +1,125 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "allora-worker.fullname" . }} + labels: + {{- include "allora-worker.labels" . | nindent 4 }} + {{- with .Values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + serviceName: "{{ include "allora-worker.fullname" . }}" + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "allora-worker.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "allora-worker.selectorLabels" . | nindent 8 }} + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "allora-worker.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + {{- range $key, $value := .Values.containers }} + - name: {{ $key }} + image: {{ $value.image }} + imagePullPolicy: {{ $.Values.imagePullPolicy | default "IfNotPresent" }} + ports: + {{- toYaml $value.ports | nindent 12 }} + {{- if $value.command }} + command: + {{- toYaml $value.command | nindent 12 }} + {{- end }} + envFrom: + {{- if $value.envFrom }} + {{- toYaml $value.envFrom | nindent 12 }} + {{- end }} + {{- range $.Values.externalSecrets }} + - secretRef: + name: {{ .target.name }} + {{- end }} + {{- if $value.volumeMounts }} + volumeMounts: + {{- toYaml $value.volumeMounts | nindent 12 }} + {{- end }} + {{- if $value.env }} + env: + {{- toYaml $value.env | nindent 12 }} + {{- end }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.initContainers }} + initContainers: + {{- range $key, $value := .Values.initContainers }} + - name: {{ $key }} + image: {{ $value.image }} + command: {{- toYaml $value.command | nindent 12 }} + volumeMounts: + {{- range $value.volumeMounts }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + {{- if .subPath }} + subPath: {{ .subPath }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + volumes: + {{- if .Values.additionalVolumes }} + {{- range $key, $value := .Values.additionalVolumes }} + - name: {{ $key }} + {{- if $value.hostPath }} + hostPath: + path: {{ $value.hostPath.path }} + type: {{ $value.hostPath.type | default "DirectoryOrCreate" }} + {{- end }} + {{- if $value.configMap }} + configMap: + name: {{ $value.configMap.name }} + {{- end }} + {{- if $value.secret }} + secret: + secretName: {{ $value.secret.secretName }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.affinity }} + affinity: + {{- toYaml .Values.affinity | nindent 8 }} + {{- end }} + volumeClaimTemplates: + - metadata: + name: data + labels: + app: {{ include "allora-worker.name" . }} + release: {{ .Release.Name }} + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: {{ .Values.persistence.size }} diff --git a/charts/allora-worker/vaules.yaml b/charts/allora-worker/vaules.yaml new file mode 100644 index 0000000..4547708 --- /dev/null +++ b/charts/allora-worker/vaules.yaml @@ -0,0 +1,115 @@ +# Default values for allora-worker. + +replicaCount: 1 + +# Container configurations +containers: + # You can define multiple containers here + main: + image: "" + ports: + - name: http + containerPort: + protocol: TCP + resources: + requests: + memory: "" + cpu: "" + limits: + memory: "" + cpu: "" + command: [] + args: [] + livenessProbe: {} + readinessProbe: {} + volumeMounts: [] + env: [] + envFrom: [] + service: + enabled: false + type: ClusterIP + port: + targetPort: + +imagePullSecrets: [] + +persistence: + enabled: false + storageClass: "" + accessMode: ReadWriteOnce + size: 1Gi + +# External Secrets configuration +externalSecrets: [] +# - name: +# refreshInterval: 1h +# secretStoreRef: +# kind: ClusterSecretStore +# name: +# target: +# name: +# creationPolicy: Owner +# data: +# - secretKey: +# remoteRef: +# key: +# property: + +# Ingress configuration +ingress: + enabled: false + className: "" + annotations: {} + hosts: + - host: chart-example.local + paths: + - path: / + pathType: Prefix + tls: [] + +# Affinity settings +affinity: {} + +# Node selector +nodeSelector: {} + +# Tolerations +tolerations: [] + +# Additional labels +labels: {} + +# Pod annotations +podAnnotations: {} + +# Service account +serviceAccount: + create: true + name: "" + annotations: {} + +# Pod security context +podSecurityContext: {} + +# Security context +securityContext: {} + +# Image pull policy +imagePullPolicy: IfNotPresent + +# Additional volumes +volumes: [] + +# Additional volumes +additionalVolumes: [] + +# Init containers +initContainers: {} + +# Deployment strategy +strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + diff --git a/charts/cosmos-operator-rpc-node/.helmignore b/charts/cosmos-operator-rpc-node/.helmignore new file mode 100644 index 0000000..165cbb8 --- /dev/null +++ b/charts/cosmos-operator-rpc-node/.helmignore @@ -0,0 +1,31 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. + +# Ignore all .tgz files +*.tgz + +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ + +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ + +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ + +# Project specific +.releaserc.js diff --git a/charts/cosmos-operator-rpc-node/.releaserc.js b/charts/cosmos-operator-rpc-node/.releaserc.js new file mode 100644 index 0000000..1928a4a --- /dev/null +++ b/charts/cosmos-operator-rpc-node/.releaserc.js @@ -0,0 +1,17 @@ +const chartName = 'cosmos-operator-rpc-node'; +const chartPath = __dirname; + +module.exports = { + extends: '../.github/chart-release.config.js', + tagFormat: 'cosmos-operator-rpc-node-v${version}', + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + '@semantic-release/changelog', + '@semantic-release/git', + '@semantic-release/github', + ['@semantic-release/exec', { + prepareCmd: 'sed -i "s/^version:.*$/version: ${nextRelease.version}/" Chart.yaml && helm package . --version ${nextRelease.version} --app-version ${nextRelease.version} && mv *.tgz ../' + }] + ] +}; diff --git a/charts/cosmos-operator-rpc-node/Chart.yaml b/charts/cosmos-operator-rpc-node/Chart.yaml new file mode 100644 index 0000000..9dd4273 --- /dev/null +++ b/charts/cosmos-operator-rpc-node/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: cosmos-operator-rpc-node +description: A Helm chart for deploying an RPC node using the Cosmos Operator +type: application +version: 0.0.0-development +appVersion: "1.0" diff --git a/charts/cosmos-operator-rpc-node/examples/values.yaml b/charts/cosmos-operator-rpc-node/examples/values.yaml new file mode 100644 index 0000000..9c5889f --- /dev/null +++ b/charts/cosmos-operator-rpc-node/examples/values.yaml @@ -0,0 +1,129 @@ +# Default values for cosmos-operator-rpc-node + + +replicas: 1 +maxUnavailable: 1 +image: "ghcr.io/p2p-org/cosmos-operator-rpc-node" +imageTag: "v1.0.0" +imagePullSecrets: + - name: regcred +storage: "100Gi" +storageClassName: "standard" +nodeSelectorKey: "cosmos-node" +affinityAdditionalMatches: + - key: "node-type" + operator: In + values: + - "rpc" +nodeSelectorLabel: + node-role: "cosmos-rpc" +podAntiAffinityPerNode: true +volumeRetainPolicy: "Retain" + +resources: + limits: + cpu: 2 + memory: 4Gi + requests: + cpu: 1 + memory: 2Gi + +initContainers: + init-data: + image: busybox + command: ['sh', '-c', 'echo "Initializing data" && sleep 10'] + +cosmosNodeLabels: + app: cosmos-rpc +cosmosNodeAnnotations: + prometheus.io/scrape: "true" + +priorityClassName: "high-priority" + +blch: + nodeType: "full" + id: "cosmoshub-4" + network: "cosmos" + binary: "gaiad" + skipInvariants: true + genesisURL: "https://github.com/cosmos/mainnet/raw/master/genesis.cosmoshub-4.json.gz" + snapshotURL: "https://snapshots.cosmos.network/cosmoshub-4-pruned.tar.lz4" + minGasPrice: "0.025uatom" + appOverrides: | + minimum-gas-prices = "0.025uatom" + pruning = "custom" + addrbookURL: "https://github.com/cosmos/mainnet/raw/master/cosmoshub-4/addrbook.json" + config: + seeds: "ade4d8bc8cbe014af6ebdf3cb7b1e9ad36f412c0@seeds.polkachu.com:14956" + peers: "d72b3011ed46d783e369fdf8ae2055b99a1e5074@65.21.34.226:26656" + overrides: | + [p2p] + max_num_inbound_peers = 100 + max_num_outbound_peers = 50 + additionalStartArgs: + - "--x-crisis-skip-assert-invariants" + homeDir: "/root/.gaia" + pruning: + strategy: "custom" + interval: 10 + keepEvery: 0 + keepRecent: 100 + +additionalServiceConfig: + type: LoadBalancer + ports: + - port: 26656 + targetPort: 26656 + name: p2p + +endpoints: + rpc: + enabled: true + servicePort: 26657 + path: "/" + ingressName: "rpc-ingress" + host: "rpc.example.com" + tlsHost: "rpc.example.com" + tlsSecretName: "rpc-tls-secret" + additionalIngressAnnotations: + kubernetes.io/ingress.class: nginx + grpc: + enabled: true + servicePort: 9090 + path: "/" + ingressName: "grpc-ingress" + host: "grpc.example.com" + tlsHost: "grpc.example.com" + tlsSecretName: "grpc-tls-secret" + additionalIngressAnnotations: + kubernetes.io/ingress.class: nginx + ws: + enabled: true + servicePort: 8546 + path: "/" + ingressName: "ws-ingress" + host: "ws.example.com" + tlsHost: "ws.example.com" + tlsSecretName: "ws-tls-secret" + additionalIngressAnnotations: + kubernetes.io/ingress.class: nginx + ws-rpc: + enabled: true + servicePort: 26657 + path: "/websocket" + ingressName: "ws-rpc-ingress" + host: "ws-rpc.example.com" + tlsHost: "ws-rpc.example.com" + tlsSecretName: "ws-rpc-tls-secret" + additionalIngressAnnotations: + kubernetes.io/ingress.class: nginx + rest: + enabled: true + servicePort: 1317 + path: "/" + ingressName: "rest-ingress" + host: "rest.example.com" + tlsHost: "rest.example.com" + tlsSecretName: "rest-tls-secret" + additionalIngressAnnotations: + kubernetes.io/ingress.class: nginx diff --git a/charts/cosmos-operator-rpc-node/templates/_helpers.tpl b/charts/cosmos-operator-rpc-node/templates/_helpers.tpl new file mode 100644 index 0000000..935bccb --- /dev/null +++ b/charts/cosmos-operator-rpc-node/templates/_helpers.tpl @@ -0,0 +1,11 @@ +{{- define "host" -}} +{{- $context := .context -}} +{{- $endpointName := .endpointName -}} +{{- if (index $context.Values.endpoints $endpointName).host }} +{{- printf "%s" (index $context.Values.endpoints $endpointName).host }} +{{- else if eq $endpointName "rpc" }} +{{- printf "%s-%s.%s" $context.Release.Name $context.Values.blch.nodeType "tm.p2p.org" }} +{{- else }} +{{- printf "%s-%s-%s.%s" $context.Release.Name $context.Values.blch.nodeType $endpointName "tm.p2p.org" }} +{{- end -}} +{{- end -}} diff --git a/charts/cosmos-operator-rpc-node/templates/ingress-nlb.yaml b/charts/cosmos-operator-rpc-node/templates/ingress-nlb.yaml new file mode 100644 index 0000000..9f8fbfb --- /dev/null +++ b/charts/cosmos-operator-rpc-node/templates/ingress-nlb.yaml @@ -0,0 +1,33 @@ +{{- range $key, $val := .Values.endpoints }} +{{- if $val.enabled }} +{{- $name := printf "%s-%s" $.Release.Name $key }} +{{- $host := include "host" (dict "context" $ "endpointName" $key) }} +{{- $tlsSecretName := printf "%s-%s" $host "tls" }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ default $name $val.ingressName }}-nlb + {{- if $val.additionalIngressAnnotations }} + annotations: + {{ toYaml $val.additionalIngressAnnotations | nindent 4 }} + {{- end }} +spec: + ingressClassName: nginx-nlb + rules: + - host: {{ $host | quote }} + http: + paths: + - path: {{ default "/" $val.path }} + pathType: ImplementationSpecific + backend: + service: + name: {{ $.Release.Name }}-rpc + port: + number: {{ $val.servicePort }} + tls: + - hosts: + - {{ default $host $val.tlsHost | quote }} + secretName: {{ default $tlsSecretName $val.tlsSecretName }} +{{- end }} +{{- end }} diff --git a/charts/cosmos-operator-rpc-node/templates/prometheus-rules.yaml b/charts/cosmos-operator-rpc-node/templates/prometheus-rules.yaml new file mode 100644 index 0000000..d28b610 --- /dev/null +++ b/charts/cosmos-operator-rpc-node/templates/prometheus-rules.yaml @@ -0,0 +1,79 @@ +{{- if .Values.monitoring.enabled -}} +{{- if .Values.monitoring.alerts.enabled -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ .Release.Name }}-rules + labels: + app: kube-prometheus-stack +spec: + groups: + - name: blockchain-alerts + rules: + - record: chain_block_height_diff + expr: | + label_replace(chain_latest_block_height{cosmos_node="{{ .Release.Name }}", namespace="{{ .Release.Namespace }}"}, "cosmos_node", "$1", "pod", "") + - on (namespace) group_left(pod) + cometbft_consensus_height{pod=~"{{ .Release.Name }}-.?", namespace="{{ .Release.Namespace }}"} + labels: + cosmos_node: "{{ .Release.Name }}" + namespace: "{{ .Release.Namespace }}" + - alert: BlockHeightDifferenceGrowing + expr: | + chain_block_height_diff{cosmos_node="{{ .Release.Name }}", namespace="{{ .Release.Namespace }}"} > {{ .Values.monitoring.alerts.growingBlockHeightDifference }} + for: 5m + labels: + severity: warning + annotations: + summary: "Block height difference is growing for chain {{ .Values.blch.id }}" + description: "{{ .Release.Name }} node for chain {{ .Values.blch.id }} in namespace {{ .Values.namespace }} is more than {{ .Values.monitoring.alerts.growingBlockHeightDifference }} blocks behind the public RPC endpoint." + - alert: BlockHeightDifferenceCritical + expr: | + chain_block_height_diff{cosmos_node="{{ .Release.Name }}", namespace="{{ .Release.Namespace }}"} > {{ .Values.monitoring.alerts.maximumBlockHeightDifference }} + for: 5m + labels: + severity: critical + annotations: + summary: "Block height difference too high for chain {{ .Values.blch.id }}" + description: "{{ .Release.Name }} node for chain {{ .Values.blch.id }} in namespace {{ .Values.namespace }} is more than {{ .Values.monitoring.alerts.maximumBlockHeightDifference }} blocks behind the public RPC endpoint." + - alert: CometBFTPeersDrop + expr: | + (cometbft_p2p_peers{pod=~"{{ .Release.Name }}-.*", namespace="{{ .Release.Namespace }}"} + - cometbft_p2p_peers{pod=~"{{ .Release.Name }}-.*", namespace="{{ .Release.Namespace }}"} offset 5m) + / cometbft_p2p_peers{pod=~"{{ .Release.Name }}-.*", namespace="{{ .Release.Namespace }}"} + * 100 > {{ .Values.monitoring.alerts.maximumPeerDropPercentage }} + for: 5m + labels: + severity: info + annotations: + summary: "CometBFT P2P Peers Drop for {{`$labels.chain_id`}}" + description: "The number of P2P peers for chain {{`$labels.chain_id`}} in {{`$labels.namespace`}}/{{`$labels.pod`}} has dropped by more than 25% over the last 5 minutes." + - alert: LowTxSuccessRate + expr: | + cometbft_consensus_total_txs{pod=~"{{ .Release.Name }}-.*", namespace="{{ .Release.Namespace }}"} + - cometbft_mempool_failed_txs{pod=~"{{ .Release.Name }}-.*", namespace="{{ .Release.Namespace }}"} + / cometbft_consensus_total_txs{pod=~"{{ .Release.Name }}-.*", namespace="{{ .Release.Namespace }}"} + * 100 < {{ .Values.monitoring.alerts.txSuccessRateThreshold }} + for: 5m + labels: + severity: warning + annotations: + summary: "High Failed TXs for {{`$labels.pod`}}" + description: "Transaction success rate is below the SLO for {{`$labels.chain_id`}} in {{`$labels.namespace`}} /{{`$labels.pod`}}." + - alert: RpcSvcDown + expr: | + probe_http_status_code{ + rpc_svc="{{ .Release.Name }}-rpc.{{ .Release.Namespace }}"} + < 200 + or + probe_http_status_code{rpc_svc="{{ .Release.Name }}-rpc.{{ .Release.Namespace }}"} + >= 300 + for: 5m + labels: + severity: critical + annotations: + summary: "The RPC svc for {{ .Release.Name }}-rpc.{{ .Release.Namespace }} is down." + description: "Service {{ .Release.Name }}-rpc in namespace {{ .Release.Namespace }} has been down for the last 5 minutes." +{{- end -}} +{{- end -}} diff --git a/charts/cosmos-operator-rpc-node/templates/rpc_node.yaml b/charts/cosmos-operator-rpc-node/templates/rpc_node.yaml new file mode 100644 index 0000000..11d9597 --- /dev/null +++ b/charts/cosmos-operator-rpc-node/templates/rpc_node.yaml @@ -0,0 +1,136 @@ +--- +apiVersion: cosmos.strange.love/v1 +kind: CosmosFullNode +metadata: + name: {{ .Release.Name }} + {{ if .Values.cosmosNodeLabels }} + labels: + {{- toYaml .Values.cosmosNodeLabels | nindent 4 }} + {{ end }} + {{ if .Values.cosmosNodeAnnotations }} + annotations: + {{- toYaml .Values.cosmosNodeAnnotations | nindent 4 }} + {{ end }} + +spec: + replicas: {{ .Values.replicas }} + {{ if .Values.maxUnavailable }} + strategy: + maxUnavailable: {{ .Values.maxUnavailable }} + {{ end }} + chain: + app: + pruning: + {{ if .Values.blch.pruning }} + {{ toYaml .Values.blch.pruning | nindent 8 }} + {{ else if eq .Values.blch.nodeType "archive" }} + strategy: "nothing" + {{ else if eq .Values.blch.nodeType "full" }} + strategy: "custom" + interval: 10 + keepEvery: 0 + keepRecent: 100 + {{ end }} + minGasPrice: {{ .Values.blch.minGasPrice }} + {{- if .Values.blch.appOverrides }} + overrides: |- +{{ .Values.blch.appOverrides | nindent 8 }} + {{- end }} + network: {{ .Values.blch.network }} + chainID: {{ .Values.blch.id }} + binary: {{ .Values.blch.binary }} + {{ if .Values.blch.skipInvariants }} + skipInvariants: {{ .Values.blch.skipInvariants }} + {{ end }} + {{ if .Values.blch.homeDir }} + homeDir: {{ .Values.blch.homeDir }} + {{ end }} + {{ if .Values.blch.genesisURL }} + genesisURL: {{ .Values.blch.genesisURL }} + {{ end }} + {{ if .Values.blch.snapshotURL }} + snapshotURL: {{ .Values.blch.snapshotURL }} + {{ end }} + {{ if .Values.blch.additionalStartArgs }} + additionalStartArgs: {{ toYaml .Values.blch.additionalStartArgs | nindent 6 }} + {{ end }} + {{ if .Values.blch.addrbookURL }} + addrbookURL: {{ .Values.blch.addrbookURL }} + {{ end }} + {{ if .Values.blch.config }} + config: + {{ if .Values.blch.config.seeds }} + seeds: {{ .Values.blch.config.seeds }} + {{ end }} + {{ if .Values.blch.config.peers }} + peers: {{ .Values.blch.config.peers }} + {{ end }} + {{ if .Values.blch.config.overrides }} + overrides: |- +{{ .Values.blch.config.overrides | nindent 8 }} + {{ end }} + {{ end }} + podTemplate: + imagePullPolicy: "Always" + imagePullSecrets: + - name: {{ .Values.imagePullSecrets }} + image: "{{ .Values.image }}:{{ .Values.imageTag }}" + {{ if .Values.resources }} + resources: + {{ toYaml .Values.resources | nindent 6 }} + {{ end }} + {{ if .Values.nodeSelectorLabel }} + nodeSelector: + {{ toYaml .Values.nodeSelectorLabel | nindent 6 }} + {{ end }} + {{ if .Values.nodeSelectorKey }} + affinity: + {{- if .Values.podAntiAffinityPerNode }} + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - {{ .Release.Name }} + topologyKey: "kubernetes.io/hostname" + {{- end }} + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + {{- if .Values.affinityAdditionalMatches }} + {{ toYaml .Values.affinityAdditionalMatches | nindent 12 }} + {{- end }} + - key: blch + operator: In + values: + - "true" + - key: {{ .Values.nodeSelectorKey }} + operator: In + values: + - "true" + {{ end }} + {{- if .Values.initContainers }} + initContainers: + {{- range $key, $value := .Values.initContainers }} + - name: "{{ $key }}" + {{ toYaml $value | nindent 8 }} + {{- end }} + {{- end }} + {{ if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName }} + {{ end }} + {{ if .Values.additionalServiceConfig }} + service: + {{ toYaml .Values.additionalServiceConfig | nindent 4 }} + {{ end }} + volumeClaimTemplate: + resources: + requests: + storage: {{ .Values.storage }} + storageClassName: {{ .Values.storageClassName }} + {{ if .Values.volumeRetainPolicy }} + volumeRetentionPolicy: {{ .Values.volumeRetainPolicy }} + {{ end }} diff --git a/charts/cosmos-operator-rpc-node/templates/service-monitor.yaml b/charts/cosmos-operator-rpc-node/templates/service-monitor.yaml new file mode 100644 index 0000000..6b53ed1 --- /dev/null +++ b/charts/cosmos-operator-rpc-node/templates/service-monitor.yaml @@ -0,0 +1,98 @@ +{{- if .Values.monitoring.enabled -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-metrics + labels: + app.kubernetes.io/name: {{ .Release.Name }} +spec: + selector: + app.kubernetes.io/name: {{ .Release.Name }} + ports: + - name: metrics + port: 26660 + targetPort: 26660 +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ .Release.Name }}-sdk-metrics + labels: + release: kube-prometheus-stack +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ .Release.Name }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + endpoints: + - port: metrics + interval: 15s + path: /metrics +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ .Release.Name }}-block-height + labels: + release: kube-prometheus-stack +spec: + selector: + matchLabels: + app.kubernetes.io/name: prometheus-json-exporter + namespaceSelector: + matchNames: + - monitoring + endpoints: + - port: http + path: /probe + params: + module: [latest_block_height] + target: [{{ trimSuffix "/" .Values.monitoring.publicRpcEndpoint }}/status] + interval: 30s + scrapeTimeout: 10s + metricRelabelings: + - sourceLabels: [] + targetLabel: chain_id + replacement: {{ .Values.blch.id }} + - sourceLabels: [] + targetLabel: namespace + replacement: {{ .Release.Namespace }} + - sourceLabels: [] + targetLabel: cosmos_node + replacement: {{ .Release.Name }} + - sourceLabels: [] + targetLabel: rpc_endpoint + replacement: {{ .Values.monitoring.publicRpcEndpoint }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ .Release.Name }}-rpc-endpoint + labels: + release: kube-prometheus-stack +spec: + selector: + matchLabels: + app.kubernetes.io/name: prometheus-blackbox-exporter + namespaceSelector: + matchNames: + - monitoring + endpoints: + - port: http + path: /probe + params: + module: [http_2xx] + target: [{{ .Release.Name }}-rpc.{{ .Release.Namespace }}.svc.cluster.local:26657] + interval: 30s + scrapeTimeout: 10s + metricRelabelings: + - sourceLabels: [] + targetLabel: namespace + replacement: {{ .Release.Namespace }} + - sourceLabels: [] + targetLabel: rpc_svc + replacement: {{ .Release.Name }}-rpc.{{ .Release.Namespace }} +{{- end -}} diff --git a/charts/cosmos-operator-rpc-node/values.yaml b/charts/cosmos-operator-rpc-node/values.yaml new file mode 100644 index 0000000..f4d0acf --- /dev/null +++ b/charts/cosmos-operator-rpc-node/values.yaml @@ -0,0 +1,134 @@ +# Default values for RPC nodes + +## Pod Specs +image: "ghcr.io/p2p-org/cosmos-heighliner" +imageTag: "" +imagePullSecrets: "github-secret" +replicas: 1 +maxUnavailable: "" +storage: "" +storageClassName: "oci-bv" +# Note: Key to be used for node affinity +nodeSelectorKey: "" +# Note: [Optional] Additional matches for node affinity +affinityAdditionalMatches: {} +# Note: [Optional] Label to be used for node selector +nodeSelectorLabel: {} +# Note: [Optional] Enable podAntiAffinity to run only one pod per hostname +podAntiAffinityPerNode: false +volumeRetainPolicy: "Retain" + +resources: {} + +# Note: Optional additional configuration for the pod template +initContainers: [] +cosmosNodeLabels: {} +cosmosNodeAnnotations: {} +priorityClassName: "" + +# Note: Optional additional configuration for the services +service: + maxP2PExternalAddresses: 1 + p2pTemplate: + metadata: + labels: {} + annotations: {} + type: ClusterIP + +## Chain Specs +blch: + # NOTE: Whether the node is a full or archive node. Options are "full" or "archive" + nodeType: "" + id: "" + network: "" + binary: "" + skipInvariants: true + # NOTE: Provide either a genesisURL or snapshotURL for the syncing process + genesisURL: "" + snapshotURL: "" + minGasPrice: "" + appOverrides: "" + # NOTE: Specify an addr book url to download the peers from, if not available, you can add the peers under config.peers + addrbookURL: "" + # NOTE: Optional additional configuration for the network + config: + peers: "" + seeds: "" + overrides: "" + additionalStartArgs: "" + homeDir: "" + # Note: Optional pruning configuration, by default archive nodes are set to nothing, and full nodes are set to keep 100 recent blocks + pruning: + strategy: "" + interval: 0 + keepEvery: 0 + keepRecent: 0 + +# Monitoring configuration +monitoring: + enabled: true + publicRpcEndpoint: "" + alerts: + enabled: true + growingBlockHeightDifference: 25 + maximumBlockHeightDifference: 100 + maximumPeerDropPercentage: 25 + txSuccessRateThreshold: 95 + +## Ingress Specs +# Note: Endpoints can be configured as a map, each representing an endpoint, you can define as many endpoints as needed, following the below structure: +# enabled: A boolean value to enable or disable the RPC service. +# servicePort: The port number for the RPC service. This is defined by the cosmos-operator and created as part of CosmosFullNode. +# path: (Optional) The path to set for the endpoints, default to `/` if not set. +# ingressName: (Optional) The name of the ingress resource. +# host: (Optional) The host for the ingress. +# tlsHost: (Optional) The TLS host for the ingress. +# tlsSecretName: (Optional) The name of the TLS secret. +# additionalIngressAnnotations: (Optional) Additional annotations for the ingress. For example, you can specify timeouts and cors. +# Note that some endpoints might need additional overrides to work properly, you can define them as appOverrides under the blch specs. +endpoints: + rpc: + enabled: false + servicePort: 26657 + path: "/" + ingressName: "" + host: "" + tlsHost: "" + tlsSecretName: "" + additionalIngressAnnotations: {} + grpc: + enabled: false + servicePort: 9090 + path: "/" + ingressName: "" + host: "" + tlsHost: "" + tlsSecretName: "" + additionalIngressAnnotations: {} + ws: + enabled: false + servicePort: 8546 + path: "/" + ingressName: "" + host: "" + tlsHost: "" + tlsSecretName: "" + additionalIngressAnnotations: {} + ws-rpc: + enabled: false + servicePort: 26657 + path: "/websocket" + ingressName: "" + host: "" + tlsHost: "" + tlsSecretName: "" + additionalIngressAnnotations: {} + rest: + enabled: false + servicePort: 1317 + path: "/" + ingressName: "" + host: "" + tlsHost: "" + tlsSecretName: "" + additionalIngressAnnotations: {} diff --git a/docs/images/logo.png b/docs/images/logo.png new file mode 100644 index 0000000..be0f0c6 Binary files /dev/null and b/docs/images/logo.png differ diff --git a/docs/index.html.template b/docs/index.html.template new file mode 100644 index 0000000..8e93a4a --- /dev/null +++ b/docs/index.html.template @@ -0,0 +1,80 @@ + + + + + + P2P Cosmos Helm Charts + + + + +
+ + + +
+

P2P Cosmos Helm Charts

+

This repository contains Helm charts for P2P Cosmos projects. These charts are used for deploying and managing various components of the Cosmos ecosystem.

+ +

Usage

+

To use these Helm charts, add this repository to your Helm installation:

+
helm repo add p2p-cosmos https://{{GITHUB_REPOSITORY_OWNER}}.github.io/cosmos-helm-charts/
+helm repo update
+

You can then install any of the available charts. For example:

+
helm install my-release p2p-cosmos/chart-name
+ +

Available Charts

+ {{AVAILABLE_CHARTS}} + +

Contributing

+

Contributions are welcome! Please feel free to submit a Pull Request.

+ +

License

+

This project is licensed under the MIT License - see the LICENSE file for details.

+ +

For Helm users: index.yaml

+ +