From 704c75fe3a105984062d011b65119acaedab00d1 Mon Sep 17 00:00:00 2001 From: amitza Date: Wed, 4 Sep 2024 20:35:35 +0300 Subject: [PATCH] provider deployment --- charts/cache/Chart.yaml | 2 +- charts/cache/README.md | 2 +- charts/consumer/Chart.yaml | 2 +- charts/consumer/README.md | 2 +- charts/provider/Chart.yaml | 2 +- charts/provider/README.md | 8 +- charts/provider/templates/deployment.yaml | 173 +++++++++++++++++++++ charts/provider/templates/statefulset.yaml | 6 +- charts/provider/values.yaml | 45 +++--- 9 files changed, 212 insertions(+), 30 deletions(-) create mode 100644 charts/provider/templates/deployment.yaml diff --git a/charts/cache/Chart.yaml b/charts/cache/Chart.yaml index 8746bfe..784399f 100644 --- a/charts/cache/Chart.yaml +++ b/charts/cache/Chart.yaml @@ -6,7 +6,7 @@ icon: https://github.com/lavanet/helm-charts/blob/main/docs/logo/logo.png?raw=tr sources: - https://github.com/lavanet/helm-charts type: application -version: 0.5.15 +version: 0.5.16 appVersion: "v2.5.0" kubeVersion: ">=1.25.0-0" home: https://lavanet.xyz diff --git a/charts/cache/README.md b/charts/cache/README.md index 52d4de7..f3d4e8c 100644 --- a/charts/cache/README.md +++ b/charts/cache/README.md @@ -2,7 +2,7 @@ Lava helm chart for the cache service -![Version: 0.5.15](https://img.shields.io/badge/Version-0.5.15-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.0](https://img.shields.io/badge/AppVersion-v2.5.0-informational?style=flat-square) +![Version: 0.5.16](https://img.shields.io/badge/Version-0.5.16-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.0](https://img.shields.io/badge/AppVersion-v2.5.0-informational?style=flat-square) ## Lavanet Cache Helm Chart diff --git a/charts/consumer/Chart.yaml b/charts/consumer/Chart.yaml index 20402da..0c5b237 100644 --- a/charts/consumer/Chart.yaml +++ b/charts/consumer/Chart.yaml @@ -6,7 +6,7 @@ icon: https://github.com/lavanet/helm-charts/blob/main/docs/logo/logo.png?raw=tr sources: - https://github.com/lavanet/helm-charts type: application -version: 0.5.15 +version: 0.5.16 appVersion: "v2.5.0" kubeVersion: ">=1.25.0-0" home: https://lavanet.xyz diff --git a/charts/consumer/README.md b/charts/consumer/README.md index d4aaf2a..3b6d78f 100644 --- a/charts/consumer/README.md +++ b/charts/consumer/README.md @@ -2,7 +2,7 @@ Lava helm chart for the consumer service -![Version: 0.5.15](https://img.shields.io/badge/Version-0.5.15-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.0](https://img.shields.io/badge/AppVersion-v2.5.0-informational?style=flat-square) +![Version: 0.5.16](https://img.shields.io/badge/Version-0.5.16-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.0](https://img.shields.io/badge/AppVersion-v2.5.0-informational?style=flat-square) ## Lavanet Consumer Helm Chart diff --git a/charts/provider/Chart.yaml b/charts/provider/Chart.yaml index 305b67b..e9b7590 100644 --- a/charts/provider/Chart.yaml +++ b/charts/provider/Chart.yaml @@ -6,7 +6,7 @@ icon: https://github.com/lavanet/helm-charts/blob/main/docs/logo/logo.png?raw=tr sources: - https://github.com/lavanet/helm-charts type: application -version: 0.5.15 +version: 0.5.16 appVersion: "v2.5.0" kubeVersion: ">=1.25.0-0" home: https://lavanet.xyz diff --git a/charts/provider/README.md b/charts/provider/README.md index 2805b90..36d2ad0 100644 --- a/charts/provider/README.md +++ b/charts/provider/README.md @@ -2,7 +2,7 @@ Lava helm chart for the provider service -![Version: 0.5.15](https://img.shields.io/badge/Version-0.5.15-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.0](https://img.shields.io/badge/AppVersion-v2.5.0-informational?style=flat-square) +![Version: 0.5.16](https://img.shields.io/badge/Version-0.5.16-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.0](https://img.shields.io/badge/AppVersion-v2.5.0-informational?style=flat-square) ## Lavanet Provider Helm Chart @@ -204,6 +204,9 @@ Kubernetes: `>=1.25.0-0` | certificate.secretTemplateAnnotations | object | `{}` | Annotations that allow the certificate to be composed from data residing in existing Kubernetes Resources | | certificate.usages | list | `[]` | Usages for the certificate ## Ref: | | chainId | string | `"lava-testnet-2"` | Lava chain id | +| deploymentUpdate.maxSurge | string | `"100%"` | | +| deploymentUpdate.maxUnavailable | int | `0` | | +| deploymentUpdate.type | string | `"RollingUpdate"` | | | fullnameOverride | string | `""` | String to fully override `"provider.fullname"` | | geolocation | string | `"2"` | Provider geo-location can be one of the [geolocations](https://docs.lavanet.xyz/provider-setup#geolocations) | | global.domain | string | `"my-provider.local"` | Default domain used by all components # Used for ingresses, certificates, etc. | @@ -248,7 +251,6 @@ Kubernetes: `>=1.25.0-0` | node | string | `"https://testnet2-rpc.lavapro.xyz:443"` | Lava node to connect to | | nodeSelector | object | `{}` | [Node selector] | | podAnnotations | object | `{}` | Annotations for the all deployed pods | -| podManagementPolicy | string | `"Parallel"` | Pod Management Policy for StatefulSets | | podSecurityContext | object | `{}` | | | readinessProbe.failureThreshold | int | `3` | Minimum consecutive failures for the [probe] to be considered failed after having succeeded | | readinessProbe.initialDelaySeconds | int | `10` | Number of seconds after the container has started before [probe] is initiated | @@ -264,8 +266,8 @@ Kubernetes: `>=1.25.0-0` | serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| statefulSetUpdate.updateStrategy | string | `"RollingUpdate"` | | | tolerations | list | `[]` | [Tolerations] for use with node taints | -| updateStrategy | string | `"RollingUpdate"` | Update strategy for StatefulSets | | wallet | string | `"test"` | Wallet name | ---------------------------------------------- diff --git a/charts/provider/templates/deployment.yaml b/charts/provider/templates/deployment.yaml new file mode 100644 index 0000000..6cc317a --- /dev/null +++ b/charts/provider/templates/deployment.yaml @@ -0,0 +1,173 @@ +{{- range $chain := $.Values.chains }} +{{- if or (not $chain.persistence) (not $chain.persistence.enabled) }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $chain.name | lower }}-{{ include "provider.fullname" $ }} + labels: + {{- include "provider.labels" $ | nindent 4 }} + app.lavanet.io/chain: {{ $chain.name | lower }} +spec: + strategy: + type: {{ $.Values.deploymentUpdate.type }} + {{- if eq $.Values.deploymentUpdate.type "RollingUpdate" }} + rollingUpdate: + maxSurge: {{ $.Values.deploymentUpdate.maxSurge }} + maxUnavailable: {{ $.Values.deploymentUpdate.maxUnavailable }} + {{- end }} + replicas: {{ $.Values.replicaCount }} + selector: + matchLabels: + {{- include "provider.selectorLabels" $ | nindent 6 }} + app.lavanet.io/chain: {{ $chain.id | lower }} + template: + metadata: + annotations: + {{- with $.Values.podAnnotations }} + {{- toYaml $ | nindent 8 }} + {{- end }} + {{- if not $chain.existingConfigSecret }} + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") $ | sha256sum }} + {{- end }} + labels: + {{- include "provider.selectorLabels" $ | nindent 8 }} + app.lavanet.io/chain: {{ $chain.id | lower }} + spec: + {{- with $.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml $ | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "provider.serviceAccountName" $ }} + securityContext: + {{- toYaml $.Values.podSecurityContext | nindent 8 }} + initContainers: + - name: import-keys + image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + command: ["sh", "-c"] + args: + - | + if [ -f /lava/.key-{{ $.Values.wallet }}.imported ]; then + echo "Key {{ $.Values.wallet }} has already been exported, exiting..." + exit 0 + fi + + echo $KEY_PASSWORD | lavap keys \ + import {{ $.Values.wallet }} /tmp/keyfile/{{ $.Values.key.secretKey }} \ + --keyring-backend {{ $.Values.keyringBackend }} + + touch /lava/.key-{{ $.Values.wallet }}.imported + env: + - name: KEY_PASSWORD + valueFrom: + secretKeyRef: + name: {{ $.Values.key.passwordSecretName }} + key: {{ $.Values.key.passwordSecretKey }} + volumeMounts: + - name: "private-key-volume" + mountPath: /tmp/keyfile/{{ $.Values.key.secretKey }} + subPath: {{ $.Values.key.secretKey }} + readOnly: true + - mountPath: "/lava" + name: data + containers: + - name: {{ $.Chart.Name }} + securityContext: + {{- toYaml $.Values.securityContext | nindent 12 }} + image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + args: + - "rpcprovider" + {{- if $chain.existingConfigSecret }} + - {{ $chain.existingConfigSecretKey }} + {{- else }} + - config.yml + {{- end }} + - --node + - {{ $.Values.node }} + - --from + - {{ $.Values.wallet }} + - --keyring-backend + - {{ $.Values.keyringBackend }} + - --chain-id + - {{ $.Values.chainId }} + - --geolocation + - {{ $.Values.geolocation | quote }} + {{- if $.Values.cache.enabled }} + - --cache-be + - {{ $.Values.cache.address }} + {{- end }} + - --log_level + - {{ $.Values.log.level }} + - --log_format + - {{ $.Values.log.format }} + {{- range $i, $val := $.Values.additionalArgs }} + - {{ $val | quote }} + {{- end }} + ports: + - name: grpc + containerPort: {{ $.Values.service.port }} + protocol: TCP + {{- if $.Values.metrics.enabled }} + - name: metrics + containerPort: {{ $.Values.metrics.port }} + protocol: TCP + {{- end }} + livenessProbe: + httpGet: + path: /lava/health + port: grpc + scheme: {{ $.Values.livenessProbe.scheme }} + initialDelaySeconds: {{ $.Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ $.Values.livenessProbe.timeoutSeconds }} + successThreshold: {{ $.Values.livenessProbe.successThreshold }} + failureThreshold: {{ $.Values.livenessProbe.failureThreshold }} + readinessProbe: + httpGet: + path: /lava/health + port: grpc + scheme: {{ $.Values.livenessProbe.scheme }} + initialDelaySeconds: {{ $.Values.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ $.Values.readinessProbe.timeoutSeconds }} + successThreshold: {{ $.Values.readinessProbe.successThreshold }} + failureThreshold: {{ $.Values.readinessProbe.failureThreshold }} + volumeMounts: + - mountPath: "/lava" + name: data + - mountPath: "/lava/config/config.yml" + subPath: config.yml + name: {{ $chain.name | lower }}-config + readOnly: true + resources: + {{- toYaml $.Values.resources | nindent 12 }} + volumes: + - name: {{ $chain.name | lower }}-config + secret: + {{- if $chain.existingConfigSecret }} + secretName: {{ $chain.existingConfigSecret }} + {{- else }} + secretName: {{ $chain.name | lower }}-{{ include "provider.fullname" $ }} + {{- end }} + - name: "private-key-volume" + secret: + secretName: {{ $.Values.key.secretName }} + optional: false + - name: data + emptyDir: {} + {{- with $.Values.nodeSelector }} + nodeSelector: + {{- toYaml $ | nindent 8 }} + {{- end }} + {{- with $.Values.affinity }} + affinity: + {{- toYaml $ | nindent 8 }} + {{- end }} + {{- with $.Values.tolerations }} + tolerations: + {{- toYaml $ | nindent 8 }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/provider/templates/statefulset.yaml b/charts/provider/templates/statefulset.yaml index e38afca..c4581bb 100644 --- a/charts/provider/templates/statefulset.yaml +++ b/charts/provider/templates/statefulset.yaml @@ -1,4 +1,5 @@ {{- range $chain := $.Values.chains }} +{{- if and $chain.persistence $chain.persistence.enabled }} --- apiVersion: apps/v1 kind: StatefulSet @@ -11,8 +12,8 @@ spec: replicas: {{ $.Values.replicaCount }} serviceName: {{ $chain.name | lower }}-{{ include "provider.fullname" $ }} updateStrategy: - type: {{ $.Values.updateStrategy }} - podManagementPolicy: {{ $.Values.podManagementPolicy }} + type: {{ $.Values.statefulSetUpdate.updateStrategy }} + podManagementPolicy: "Parallel" selector: matchLabels: {{- include "provider.selectorLabels" $ | nindent 6 }} @@ -180,3 +181,4 @@ spec: {{- toYaml $ | nindent 8 }} {{- end }} {{- end }} +{{- end }} diff --git a/charts/provider/values.yaml b/charts/provider/values.yaml index 4d05e46..11ab3e8 100644 --- a/charts/provider/values.yaml +++ b/charts/provider/values.yaml @@ -22,10 +22,15 @@ nameOverride: "" # -- String to fully override `"provider.fullname"` fullnameOverride: "" -# -- Update strategy for StatefulSets -updateStrategy: "RollingUpdate" -# -- Pod Management Policy for StatefulSets -podManagementPolicy: "Parallel" +## -- Update strategy for StatefulSets +statefulSetUpdate: + updateStrategy: RollingUpdate + +## -- Update strategy for Deployments +deploymentUpdate: + type: RollingUpdate + maxUnavailable: 0 + maxSurge: 100% serviceAccount: # -- Specifies whether a service account should be created @@ -243,22 +248,22 @@ additionalArgs: [] # @ignored chains: - # - id: lav1 - # name: my-lav1 - # persistence: - # enabled: true - # accessModes: - # - "ReadWriteOnce" - # size: "100Mi" - # interfaces: - # - interface: rest - # disableTLS: true - # nodes: - # - endpoint: rest.example.com - # type: full - # - endpoint: rest.archive.example.com - # type: archive - # skipVerifications: pruning + - id: lav1 + name: my-lav1 + persistence: + enabled: true + accessModes: + - "ReadWriteOnce" + size: "100Mi" + interfaces: + - interface: rest + disableTLS: true + nodes: + - endpoint: rest.example.com + type: full + - endpoint: rest.archive.example.com + type: archive + skipVerifications: pruning # - interface: tendermintrpc # nodes: # - endpoint: tendermintrpc.example.com