From d6b185b6fc579f55d90b4fb77db9856ebeb3acd0 Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Mon, 24 Jun 2024 21:26:24 +0300 Subject: [PATCH] add support for generic ephemeral volume --- charts/node/README.md | 8 ++-- charts/node/templates/statefulset.yaml | 64 ++++++++++++++++++++++++-- charts/node/values.yaml | 14 ++++-- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/charts/node/README.md b/charts/node/README.md index f4bd3bef..f895a48e 100644 --- a/charts/node/README.md +++ b/charts/node/README.md @@ -343,7 +343,7 @@ If you're running a collator node: | jaegerAgent.ports.samplingPort | HTTP | `5778` | serve configs, sampling strategies | | jaegerAgent.resources | object | `{}` | Resource limits & requests | | nameOverride | string | `""` | Provide a name in place of node for `app:` labels | -| node | object | `{"allowUnsafeRpcMethods":false,"chain":"polkadot","chainData":{"annotations":{},"chainPath":null,"chainSnapshot":{"enabled":false,"filelistName":"files.txt","method":"gcs","url":""},"database":"rocksdb","emptyDir":{"enabled":false},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"pruning":1000,"storageClass":"","volumeSize":"100Gi"},"chainKeystore":{"accessModes":["ReadWriteOnce"],"annotations":{},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"mountInMemory":{"enabled":false,"sizeLimit":null},"storageClass":"","volumeSize":"10Mi"},"collatorExternalRelayChain":{"enabled":false,"relayChainRpcUrls":[]},"collatorLightClient":{"enabled":false,"relayChain":"","relayChainCustomChainspec":false,"relayChainCustomChainspecPath":"/chain-data/relay_chain_chainspec.json","relayChainCustomChainspecUrl":null},"collatorRelayChain":{"chain":"polkadot","chainData":{"annotations":{},"chainPath":"","chainSnapshot":{"enabled":false,"filelistName":"files.txt","method":"gcs","url":""},"database":"rocksdb","emptyDir":{"enabled":false},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"pruning":1000,"storageClass":"","volumeSize":"100Gi"},"chainKeystore":{"accessModes":["ReadWriteOnce"],"annotations":{},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"mountInMemory":{"enabled":false,"sizeLimit":null},"storageClass":"","volumeSize":"10Mi"},"customChainspec":false,"customChainspecPath":"/relaychain-data/relay_chain_chainspec.json","customChainspecUrl":null,"flags":[],"prometheus":{"enabled":false,"port":9625}},"command":"polkadot","customChainspec":false,"customChainspecPath":"/chain-data/chainspec.json","customChainspecUrl":null,"customNodeKey":[],"enableOffchainIndexing":false,"enableSidecarLivenessProbe":false,"enableSidecarReadinessProbe":false,"enableStartupProbe":true,"existingSecrets":{"keys":[],"nodeKey":{}},"extraConfigmapMounts":[],"extraEnvVars":[],"extraSecretMounts":[],"flags":[],"forceDownloadChainspec":false,"isParachain":false,"keys":{},"legacyRpcFlags":false,"logLevels":[],"perNodeServices":{"apiService":{"annotations":{},"enabled":true,"externalDns":{"customPrefix":"","enabled":false,"hostname":"example.com","ttl":300},"externalTrafficPolicy":"Cluster","extraPorts":[],"httpPort":9933,"prometheusPort":9615,"relayChainPrometheusPort":9625,"rpcPort":9944,"type":"ClusterIP","wsPort":9955},"paraP2pService":{"annotations":{},"enabled":false,"externalDns":{"customPrefix":"","enabled":false,"hostname":"example.com","ttl":300},"externalTrafficPolicy":"Cluster","extraPorts":[],"port":30334,"publishUnreadyAddresses":true,"type":"NodePort","ws":{"enabled":false,"port":30335}},"relayP2pService":{"annotations":{},"enabled":false,"externalDns":{"customPrefix":"","enabled":false,"hostname":"example.com","ttl":300},"externalTrafficPolicy":"Cluster","extraPorts":[],"port":30333,"publishUnreadyAddresses":true,"type":"NodePort","ws":{"enabled":false,"port":30334}},"setPublicAddressToExternalIp":{"autodiscoveryFix":false,"enabled":false,"ipRetrievalServiceUrl":"https://ifconfig.io"}},"persistGeneratedNodeKey":false,"persistentVolumeClaimRetentionPolicy":null,"podManagementPolicy":null,"prometheus":{"enabled":true,"port":9615},"replicas":1,"resources":{},"role":"full","serviceAnnotations":{},"serviceExtraPorts":[],"serviceMonitor":{"enabled":false,"interval":"30s","metricRelabelings":[],"namespace":null,"relabelings":[],"scrapeTimeout":"10s","targetLabels":["node"]},"startupProbeFailureThreshold":30,"substrateApiSidecar":{"enabled":false},"telemetryUrls":[],"tracing":{"enabled":false},"updateStrategy":{"enabled":false,"maxUnavailable":1,"type":"RollingUpdate"},"vault":{"authConfigServiceAccount":null,"authConfigType":null,"authPath":null,"authRole":null,"authType":null,"keys":{},"nodeKey":{}},"wasmRuntimeOverridesPath":"/chain-data/runtimes","wasmRuntimeUrl":""}` | Deploy a substrate node. ref: https://docs.substrate.io/tutorials/v3/private-network/ | +| node | object | `{"allowUnsafeRpcMethods":false,"chain":"polkadot","chainData":{"annotations":{},"chainPath":null,"chainSnapshot":{"enabled":false,"filelistName":"files.txt","method":"gcs","url":""},"database":"rocksdb","ephemeral":{"enabled":false,"type":"emptyDir"},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"pruning":1000,"storageClass":"","volumeSize":"100Gi"},"chainKeystore":{"accessModes":["ReadWriteOnce"],"annotations":{},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"mountInMemory":{"enabled":false,"sizeLimit":null},"storageClass":"","volumeSize":"10Mi"},"collatorExternalRelayChain":{"enabled":false,"relayChainRpcUrls":[]},"collatorLightClient":{"enabled":false,"relayChain":"","relayChainCustomChainspec":false,"relayChainCustomChainspecPath":"/chain-data/relay_chain_chainspec.json","relayChainCustomChainspecUrl":null},"collatorRelayChain":{"chain":"polkadot","chainData":{"annotations":{},"chainPath":"","chainSnapshot":{"enabled":false,"filelistName":"files.txt","method":"gcs","url":""},"database":"rocksdb","ephemeral":{"enabled":false,"type":"emptyDir"},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"pruning":1000,"storageClass":"","volumeSize":"100Gi"},"chainKeystore":{"accessModes":["ReadWriteOnce"],"annotations":{},"kubernetesVolumeSnapshot":null,"kubernetesVolumeToClone":null,"mountInMemory":{"enabled":false,"sizeLimit":null},"storageClass":"","volumeSize":"10Mi"},"customChainspec":false,"customChainspecPath":"/relaychain-data/relay_chain_chainspec.json","customChainspecUrl":null,"flags":[],"prometheus":{"enabled":false,"port":9625}},"command":"polkadot","customChainspec":false,"customChainspecPath":"/chain-data/chainspec.json","customChainspecUrl":null,"customNodeKey":[],"enableOffchainIndexing":false,"enableSidecarLivenessProbe":false,"enableSidecarReadinessProbe":false,"enableStartupProbe":true,"existingSecrets":{"keys":[],"nodeKey":{}},"extraConfigmapMounts":[],"extraEnvVars":[],"extraSecretMounts":[],"flags":[],"forceDownloadChainspec":false,"isParachain":false,"keys":{},"legacyRpcFlags":false,"logLevels":[],"perNodeServices":{"apiService":{"annotations":{},"enabled":true,"externalDns":{"customPrefix":"","enabled":false,"hostname":"example.com","ttl":300},"externalTrafficPolicy":"Cluster","extraPorts":[],"httpPort":9933,"prometheusPort":9615,"relayChainPrometheusPort":9625,"rpcPort":9944,"type":"ClusterIP","wsPort":9955},"paraP2pService":{"annotations":{},"enabled":false,"externalDns":{"customPrefix":"","enabled":false,"hostname":"example.com","ttl":300},"externalTrafficPolicy":"Cluster","extraPorts":[],"port":30334,"publishUnreadyAddresses":true,"type":"NodePort","ws":{"enabled":false,"port":30335}},"relayP2pService":{"annotations":{},"enabled":false,"externalDns":{"customPrefix":"","enabled":false,"hostname":"example.com","ttl":300},"externalTrafficPolicy":"Cluster","extraPorts":[],"port":30333,"publishUnreadyAddresses":true,"type":"NodePort","ws":{"enabled":false,"port":30334}},"setPublicAddressToExternalIp":{"autodiscoveryFix":false,"enabled":false,"ipRetrievalServiceUrl":"https://ifconfig.io"}},"persistGeneratedNodeKey":false,"persistentVolumeClaimRetentionPolicy":null,"podManagementPolicy":null,"prometheus":{"enabled":true,"port":9615},"replicas":1,"resources":{},"role":"full","serviceAnnotations":{},"serviceExtraPorts":[],"serviceMonitor":{"enabled":false,"interval":"30s","metricRelabelings":[],"namespace":null,"relabelings":[],"scrapeTimeout":"10s","targetLabels":["node"]},"startupProbeFailureThreshold":30,"substrateApiSidecar":{"enabled":false},"telemetryUrls":[],"tracing":{"enabled":false},"updateStrategy":{"enabled":false,"maxUnavailable":1,"type":"RollingUpdate"},"vault":{"authConfigServiceAccount":null,"authConfigType":null,"authPath":null,"authRole":null,"authType":null,"keys":{},"nodeKey":{}},"wasmRuntimeOverridesPath":"/chain-data/runtimes","wasmRuntimeUrl":""}` | Deploy a substrate node. ref: https://docs.substrate.io/tutorials/v3/private-network/ | | node.allowUnsafeRpcMethods | bool | `false` | Allow executing unsafe RPC methods | | node.chain | string | `"polkadot"` | Name of the chain | | node.chainData.annotations | object | `{}` | Annotations to add to the volumeClaimTemplates | @@ -354,7 +354,8 @@ If you're running a collator node: | node.chainData.chainSnapshot.method | string | `"gcs"` | Restoration method. One of: gcs, s3, http-single-tar, http-single-tar-lz4, http-filelist | | node.chainData.chainSnapshot.url | string | `""` | A URL to download chain backup | | node.chainData.database | string | `"rocksdb"` | Database backend engine to use | -| node.chainData.emptyDir | object | `{"enabled":false}` | Mount chain-data volume using an emptyDir volume | +| node.chainData.ephemeral | object | `{"enabled":false,"type":"emptyDir"}` | Mount chain-data volume using an ephemeral volume ref: https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#types-of-ephemeral-volumes | +| node.chainData.ephemeral.type | string | `"emptyDir"` | Type supports emptyDir, generic | | node.chainData.kubernetesVolumeSnapshot | string | `nil` | If set, create a clone of the volume (using volumeClaimTemplates.dataSource.VolumeSnapshot) and use it to store chain data | | node.chainData.kubernetesVolumeToClone | string | `nil` | If set, create a clone of the volume (using volumeClaimTemplates.dataSource.PersistentVolumeClaim) and use it to store chain data | | node.chainData.pruning | int | `1000` | Set the amount of blocks to retain. If set to 0 archive node will be run. If deprecated `--pruning` flags is used in `node.flags`, set this to `false`. | @@ -388,7 +389,8 @@ If you're running a collator node: | node.collatorRelayChain.chainData.chainSnapshot.method | string | `"gcs"` | Restoration method. One of: gcs, s3, http-single-tar, http-single-tar-lz4, http-filelist | | node.collatorRelayChain.chainData.chainSnapshot.url | string | `""` | A URL to download chain backup | | node.collatorRelayChain.chainData.database | string | `"rocksdb"` | Database backend engine to use for the collator relay-chain database | -| node.collatorRelayChain.chainData.emptyDir | object | `{"enabled":false}` | Mount relaychain-data volume using an emptyDir volume | +| node.collatorRelayChain.chainData.ephemeral | object | `{"enabled":false,"type":"emptyDir"}` | Mount relaychain-data volume using an ephemeral volume ref: https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#types-of-ephemeral-volumes | +| node.collatorRelayChain.chainData.ephemeral.type | string | `"emptyDir"` | Type supports emptyDir, generic | | node.collatorRelayChain.chainData.kubernetesVolumeSnapshot | string | `nil` | If set, create a clone of the volume (using volumeClaimTemplates.dataSource.VolumeSnapshot) and use it to store relay-chain data | | node.collatorRelayChain.chainData.kubernetesVolumeToClone | string | `nil` | If set, create a clone of the volume (using volumeClaimTemplates.dataSource.PersistentVolumeClaim) and use it to store relay-chain data | | node.collatorRelayChain.chainData.pruning | int | `1000` | Set the amount of blocks to retain for the collator relay-chain database. If set to 0 archive node will be run. If deprecated `--pruning` flags is used in `node.collatorRelayChain.flags`, set this to `false`. | diff --git a/charts/node/templates/statefulset.yaml b/charts/node/templates/statefulset.yaml index 29d63069..2b5c9023 100644 --- a/charts/node/templates/statefulset.yaml +++ b/charts/node/templates/statefulset.yaml @@ -919,19 +919,75 @@ spec: secretName: {{ $keys }} defaultMode: 0400 {{- end }} - {{- if .Values.node.chainData.emptyDir.enabled }} + {{- if .Values.node.chainData.ephemeral.enabled }} - name: chain-data + {{- if eq .Values.node.chainData.ephemeral.type "emptyDir" }} emptyDir: {{- if and (.Values.node.chainData.volumeSize) (semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion) }} sizeLimit: {{ .Values.node.chainData.volumeSize }} {{- end }} + {{- end }} + {{- if eq .Values.node.chainData.ephemeral.type "generic" }} + ephemeral: + volumeClaimTemplate: + metadata: + name: chain-data + {{- with .Values.node.chainData.annotations }} + annotations: {{ toYaml . | nindent 10 }} + {{- end }} + spec: + accessModes: [ "ReadWriteOnce" ] + {{- if or .Values.node.chainData.kubernetesVolumeSnapshot .Values.node.chainData.kubernetesVolumeToClone }} + dataSource: + {{- if .Values.node.chainData.kubernetesVolumeSnapshot }} + name: {{ .Values.node.chainData.kubernetesVolumeSnapshot }} + kind: VolumeSnapshot + apiGroup: snapshot.storage.k8s.io + {{- else }} + name: {{ .Values.node.chainData.kubernetesVolumeToClone }} + kind: PersistentVolumeClaim + {{- end }} + {{- end }} + storageClassName: {{ .Values.node.chainData.storageClass }} + resources: + requests: + storage: {{ .Values.node.chainData.volumeSize }} + {{- end }} {{- end }} - {{- if and (include "node.hasCollatorRelaychain" .) .Values.node.collatorRelayChain.chainData.emptyDir.enabled }} + {{- if and (include "node.hasCollatorRelaychain" .) .Values.node.collatorRelayChain.chainData.ephemeral.enabled }} - name: relaychain-data + {{- if eq .Values.node.chainData.ephemeral.type "emptyDir" }} emptyDir: {{- if and (.Values.node.collatorRelayChain.chainData.volumeSize) (semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion) }} sizeLimit: {{ .Values.node.collatorRelayChain.chainData.volumeSize }} {{- end }} + {{- end }} + {{- if eq .Values.node.chainData.ephemeral.type "generic" }} + ephemeral: + volumeClaimTemplate: + metadata: + name: relaychain-data + {{- with .Values.node.collatorRelayChain.chainData.annotations }} + annotations: {{ toYaml . | nindent 10 }} + {{- end }} + spec: + accessModes: [ "ReadWriteOnce" ] + {{- if or .Values.node.collatorRelayChain.chainData.kubernetesVolumeSnapshot .Values.node.collatorRelayChain.chainData.kubernetesVolumeToClone }} + dataSource: + {{- if .Values.node.collatorRelayChain.chainData.kubernetesVolumeSnapshot }} + name: {{ .Values.node.collatorRelayChain.chainData.kubernetesVolumeSnapshot }} + kind: VolumeSnapshot + apiGroup: snapshot.storage.k8s.io + {{- else }} + name: {{ .Values.node.collatorRelayChain.chainData.kubernetesVolumeToClone }} + kind: PersistentVolumeClaim + {{- end }} + {{- end }} + storageClassName: {{ .Values.node.collatorRelayChain.chainData.storageClass }} + resources: + requests: + storage: {{ .Values.node.collatorRelayChain.chainData.volumeSize }} + {{- end }} {{- end }} {{- if .Values.node.chainKeystore.mountInMemory.enabled }} - name: chain-keystore @@ -950,7 +1006,7 @@ spec: {{- end }} {{- end }} volumeClaimTemplates: - {{- if not .Values.node.chainData.emptyDir.enabled }} + {{- if not .Values.node.chainData.ephemeral.enabled }} - apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -1002,7 +1058,7 @@ spec: requests: storage: {{ .Values.node.chainKeystore.volumeSize }} {{- end }} - {{- if and (include "node.hasCollatorRelaychain" .) ( not .Values.node.collatorRelayChain.chainData.emptyDir.enabled ) }} + {{- if and (include "node.hasCollatorRelaychain" .) ( not .Values.node.collatorRelayChain.chainData.ephemeral.enabled ) }} - apiVersion: v1 kind: PersistentVolumeClaim metadata: diff --git a/charts/node/values.yaml b/charts/node/values.yaml index 93d1afc2..132eae28 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -195,9 +195,12 @@ node: chainPath: # -- Storage class to use for persistent volume storageClass: "" - # -- Mount chain-data volume using an emptyDir volume - emptyDir: + # -- Mount chain-data volume using an ephemeral volume + # ref: https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#types-of-ephemeral-volumes + ephemeral: enabled: false + # -- Type supports emptyDir, generic + type: emptyDir # -- Size of the volume for chain data volumeSize: 100Gi # -- Annotations to add to the volumeClaimTemplates @@ -296,9 +299,12 @@ node: chainPath: "" # -- Storage class to use for persistent volume storageClass: "" - # -- Mount relaychain-data volume using an emptyDir volume - emptyDir: + # -- Mount relaychain-data volume using an ephemeral volume + # ref: https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#types-of-ephemeral-volumes + ephemeral: enabled: false + # -- Type supports emptyDir, generic + type: emptyDir # -- Size of the volume volumeSize: 100Gi # -- Annotations to add to the volumeClaimTemplates