Skip to content

Commit

Permalink
feat(shared): simplify Storage Class Generation with a Shared Helm Chart
Browse files Browse the repository at this point in the history
Simplifies the process of generating storage classes by utilizing a shared Helm chart. The four platforms that have been modified to make them compatible with the shared "storage_class" Helm Chart are:
 • Hyperledger-Fabric
 • R3-corda-Ent
 • Hyperledger-Besu
 • Quorum

The following changes have been implemented:
 • Updated variables to align with the shared Helm chart.
 • Introduced common variables to streamline the configuration of storage classes across different platforms.
 • Updated the HR file responsible for configuring the shared storage_class Helm chart.

These changes will simplify the generation of various storage classes by utilizing a single template file. Additionally, they will improve compatibility with the shared "storage_class" Helm chart across multiple platforms.

fixes #2306

Signed-off-by: saurabhkumarkardam <[email protected]>
  • Loading branch information
saurabhkumarkardam committed Jul 17, 2023
1 parent bb23f6b commit 28b764d
Show file tree
Hide file tree
Showing 70 changed files with 255 additions and 236 deletions.
29 changes: 15 additions & 14 deletions platforms/hyperledger-besu/configuration/deploy-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@
include_role:
name: create/storageclass
vars:
storageclass_name: "{{ organizationItem.cloud_provider }}storageclass"
git_dir: "{{ organizationItem.gitops.release_dir }}"
org: "{{ organizationItem }}"
kubernetes: "{{ organizationItem.k8s }}"
cloudProvider: "{{ organizationItem.cloud_provider }}"
cloudProvider_info: "{{ organizationItem[cloudProvider] }}"
org: "{{ org }}"
org_name: "{{ org.name | lower }}"
cloudProvider: "{{ org.cloud_provider | lower }}"
sc_name: "{{ org_name }}-{{ cloudProvider }}-storageclass"
kubernetes: "{{ org.k8s }}"
region: "{{ org.k8s.region | default('eu-west-1') }}"
git_dir: "{{ org.gitops.release_dir }}"
charts_dir: "platforms/shared/charts"
org_name: "{{ organizationItem.name | lower }}"
platform_suffix: "bes"
loop: "{{ network['organizations'] }}"
loop_control:
loop_var: organizationItem
loop_var: org

#Create Vault scrit as configmap for Vault CURD operations
- name: setup vault script
include_role:
Expand All @@ -71,9 +72,9 @@
policy_type: "besu"
name: "{{ organizationItem.name | lower }}"
component_ns: "{{ organizationItem.name | lower }}-bes"
component_name: "{{ organizationItem.name | lower }}-vaultk8s-job"
component_name: "{{ organizationItem.name | lower }}-bes"
component_auth: "besu{{ organizationItem.name | lower }}"
component_type: "organization"
component_type: "{{ organizationItem.type | lower }}"
kubernetes: "{{ organizationItem.k8s }}"
vault: "{{ organizationItem.vault }}"
gitops: "{{ organizationItem.gitops }}"
Expand Down Expand Up @@ -139,7 +140,7 @@
component_ns: "{{ item.name | lower }}-bes"
name: "{{ item.name | lower }}"
peers: "{{ item.services.validators}}"
storageclass_name: "{{ item.cloud_provider }}storageclass"
sc_name: "{{ name }}-{{ item.cloud_provider | lower }}-storageclass"
external_url: "{{ item.external_url_suffix }}"
vault: "{{ item.vault }}"
git_url: "{{ item.gitops.git_url }}"
Expand Down Expand Up @@ -211,7 +212,7 @@
vars:
build_path: "{{ playbook_dir }}/build"
component_ns: "{{ org.name }}-bes"
storageclass_name: "{{ org.cloud_provider }}storageclass"
sc_name: "{{ org.name | lower }}-{{ org.cloud_provider | lower }}-storageclass"
external_url: "{{ org.external_url_suffix }}"
kubernetes: "{{ org.k8s }}"
vault: "{{ org.vault }}"
Expand All @@ -236,7 +237,7 @@
component_ns: "{{ item.name | lower }}-bes"
name: "{{ item.name | lower }}"
peers: "{{ item.services.peers }}"
storageclass_name: "{{ item.cloud_provider }}storageclass"
sc_name: "{{ name }}-{{ item.cloud_provider | lower }}-storageclass"
external_url: "{{ item.external_url_suffix }}"
vault: "{{ item.vault }}"
git_url: "{{ item.gitops.git_url }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
name: create/helm_component
vars:
component_type: "crypto"
type: "crypto_tessera"
type: "besu_crypto_tessera"
name: "{{ org.name | lower }}"
component_name: "{{ peer.name }}-tessera-job"
loop: "{{ org.services.peers }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ spec:
{% endif %}

storage:
storageclassname: {{ storageclass_name }}
storageclassname: {{ sc_name }}
storagesize: 1Gi

vault:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ spec:
clientport: {{ peer.tm_clientport.port }}

storage:
storageclassname: {{ storageclass_name }}
storageclassname: {{ sc_name }}
storagesize: 1Gi

vault:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ spec:
portTM: {{ peer.tm_nodeport.port }}
{% endif %}
storage:
storageclassname: {{ storageclass_name }}
storageclassname: {{ sc_name }}
storagesize: 1Gi
dbstorage: 1Gi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
enabled: {{ network.permissioning.enabled | default(false)}}

storage:
storageclassname: {{ storageclass_name }}
storageclassname: {{ sc_name }}
storagesize: 1Gi

vault:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ helm_templates:
node_orion: node_orion.tpl
validator: validator.tpl
crypto_orion: crypto_orion.tpl
crypto_tessera: crypto_tessera.tpl
besu_crypto_tessera: crypto_tessera.tpl
tessera: tessera.tpl
node_besu: node_besu.tpl
node_key_mgmt: node_key_mgmt.tpl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: {{ component_name }}
namespace: {{ org_name }}-bes
name: {{ sc_name }}
namespace: {{ org_name }}-{{ platform_suffix }}
annotations:
flux.weave.works/automated: "false"
spec:
releaseName: {{ component_name }}
releaseName: {{ sc_name }}
interval: 1m
chart:
spec:
Expand All @@ -17,13 +17,13 @@ spec:
namespace: flux-{{ network.env.type }}
values:
metadata:
name: {{ component_name }}
name: {{ sc_name }}
cloud_provider: {{ cloudProvider }}
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- "{{ cloudProvider_info.region }}a"
- "{{ cloudProvider_info.region }}b"
- "{{ region }}a"
- "{{ region }}b"
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
# This role creates value files for storage class
#############################################################################################
# Check storageclass exists already
- name: "Checking if the storage class {{ storageclass_name }} already exists"
- name: "Checking if the storage class {{ sc_name }} already exists"
include_role:
name: "{{ playbook_dir }}/../../shared/configuration/roles/check/k8_component"
vars:
component_type: "StorageClass"
component_name: "{{ storageclass_name }}"
component_name: "{{ sc_name }}"
type: "no_retry"

#set variable storageclass_state
Expand All @@ -25,10 +25,10 @@
include_role:
name: create/k8_component
vars:
component_type: "{{ org.cloud_provider}}-storageclass"
component_name: "{{ storageclass_name }}"
component_type: "{{ cloudProvider }}-storageclass"
component_name: "{{ org_name }}"
helm_lint: "false"
release_dir: "{{ playbook_dir }}/../../../{{ org.gitops.release_dir }}/{{ org_name }}"
release_dir: "{{ playbook_dir }}/../../../{{ org.gitops.release_dir }}"
when: storageclass_state.resources|length == 0

# Push the deployment files to repository
Expand All @@ -43,11 +43,11 @@
when: storageclass_state.resources|length == 0

#Wait for the creation of storage class
- name: "Waiting for the creation of {{ storageclass_name }} storage class for {{ component_name }}"
- name: "Waiting for the creation of {{ sc_name }} storage class for {{ component_name }}"
include_role:
name: "{{ playbook_dir }}/../../shared/configuration/roles/check/k8_component"
vars:
component_type: "StorageClass"
component_name: "{{ storageclass_name }}"
component_name: "{{ sc_name }}"
type: "retry"
when: storageclass_state.resources|length == 0
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@
include_role:
name: "create/storageclass"
vars:
sc_name: "{{ item.name | lower}}sc"
component_type: "{{ item.type | lower}}"
org_name: "{{ item.name | lower }}"
cloudProvider: "{{ item.cloud_provider | lower }}"
sc_name: "{{ org_name }}-{{ cloudProvider }}-storageclass"
component_type: "{{ item.type | lower }}"
region: "{{ item.k8s.region | default('eu-west-1') }}"
kubernetes: "{{ item.k8s }}"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
platform_suffix: "net"
charts_dir: "platforms/shared/charts"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ org_name }}"
loop: "{{ network['organizations'] }}"
when: item.org_status == 'new'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@
- include_role:
name: "create/storageclass"
vars:
sc_name: "{{ item.name | lower}}sc"
org_name: "{{ item.name | lower }}"
cloudProvider: "{{ item.cloud_provider | lower }}"
sc_name: "{{ org_name }}-{{ cloudProvider }}-storageclass"
region: "{{ item.k8s.region | default('eu-west-1') }}"
component_type: "{{ item.type | lower}}"
kubernetes: "{{ item.k8s }}"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
platform_suffix: "net"
charts_dir: "platforms/shared/charts"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ org_name }}"
loop: "{{ network['organizations'] }}"
when: item.org_status == 'new'

Expand Down
9 changes: 7 additions & 2 deletions platforms/hyperledger-fabric/configuration/add-peer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@
- include_role:
name: "create/storageclass"
vars:
sc_name: "{{ item.name | lower}}sc"
org_name: "{{ item.name | lower }}"
cloudProvider: "{{ item.cloud_provider | lower }}"
sc_name: "{{ org_name }}-{{ cloudProvider }}-storageclass"
component_type: "{{ item.type | lower}}"
region: "{{ item.k8s.region | default('eu-west-1') }}"
kubernetes: "{{ item.k8s }}"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
platform_suffix: "net"
charts_dir: "platforms/shared/charts"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ org_name }}"
loop: "{{ network['organizations'] }}"

# Create Organization crypto materials for new organization
Expand Down
14 changes: 11 additions & 3 deletions platforms/hyperledger-fabric/configuration/deploy-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@
include_role:
name: "create/storageclass"
vars:
sc_name: "{{ item.name | lower}}sc"
component_type: "{{ item.type | lower}}"
org_name: "{{ item.name | lower }}"
cloudProvider: "{{ item.cloud_provider | lower }}"
sc_name: "{{ org_name }}-{{ cloudProvider }}-storageclass"
component_type: "{{ item.type | lower }}"
region: "{{ item.k8s.region | default('eu-west-1') }}"
kubernetes: "{{ item.k8s }}"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ item.name | lower }}"
charts_dir: "platforms/shared/charts"
platform_suffix: "net"
release_dir: "{{playbook_dir}}/../../../{{item.gitops.release_dir}}/{{ org_name }}"
loop: "{{ network['organizations'] }}"

# Create CA Server helm-value files and check-in
Expand All @@ -75,6 +80,7 @@
component: "{{ item.name | lower}}"
component_type: "{{ item.type | lower}}"
component_services: "{{ item.services }}"
sc_name: "{{ component }}-{{ item.cloud_provider }}-storageclass"
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
ca: "{{ item.services.ca }}"
Expand Down Expand Up @@ -108,6 +114,7 @@
component: "{{ item.name | lower}}"
component_type: "{{ item.type | lower}}"
component_services: "{{ item.services }}"
sc_name: "{{ component }}-{{ item.cloud_provider | lower }}-storageclass"
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
ca: "{{ item.services.ca }}"
Expand All @@ -126,6 +133,7 @@
component_type: "{{ item.type | lower}}"
component_services: "{{ item.services }}"
orderer_org: "{{ item.orderer_org | lower }}"
sc_name: "{{ component }}-{{ item.cloud_provider | lower }}-storageclass"
kubernetes: "{{ item.k8s }}"
vault: "{{ item.vault }}"
ca: "{{ item.services.ca }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
charts_dir: "{{ org.gitops.chart_source }}"
vault: "{{ org.vault }}"
fabrictools_image: "hyperledger/fabric-tools:{{ network.version }}"
storage_class: "{{ org.name | lower }}sc"
sc_name: "{{ org.name | lower }}-{{ org.cloud_provider | lower }}-storageclass"
values_dir: "{{playbook_dir}}/../../../{{org.gitops.release_dir}}/{{ org.name | lower }}"
type: "cli"
external_url_suffix: "{{ org.external_url_suffix }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
vars:
name: "{{ item.name | lower }}"
type: "operations_console"
sc_name: "{{ name }}-{{ item.cloud_provider | lower }}-storageclass"
component_name: operations_console

#Git Push : Pushes the above generated files to git directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
vars:
name: "orderer"
org_name: "{{ item.name | lower }}"
sc_name: "{{ org_name }}-{{ item.cloud_provider | lower}}-storageclass"
kafka_image: "hyperledger/fabric-kafka:{{ kafka_image_version[network.version] }}"
zookeeper_image: "hyperledger/fabric-zookeeper:{{ zookeeper_image_version[network.version] }}"
component_name: "zkkafka"
Expand All @@ -64,6 +65,7 @@
vars:
name: "orderer"
org_name: "{{ item.name | lower }}"
sc_name: "{{ org_name }}-{{ item.cloud_provider | lower}}-storageclass"
component_name: "{{ orderer.name }}-{{ org_name }}"
orderer_image: "hyperledger/fabric-orderer:{{ network.version }}"
alpine_image: "{{ docker_url }}/alpine-utils:1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
name: helm_component
vars:
name: "{{ item.name | lower }}"
sc_name: "{{ name }}-{{ item.cloud_provider | lower}}-storageclass"
type: "value_peer"
component_name: values-{{ peer.name }}
couchdb_image: "{{ couchdb_image_version[network.version] }}"
Expand All @@ -39,6 +40,7 @@
name: helm_component
vars:
name: "{{ item.name | lower }}"
sc_name: "{{ name }}-{{ item.cloud_provider | lower}}-storageclass"
type: "value_peer"
component_name: values-{{ peer.name }}
couchdb_image: "{{ couchdb_image_version[network.version] }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
src: "{{ sc_templates[type] }}"
dest: "{{ values_file }}"
vars:
type: "{{item.cloud_provider}}-orderer"
type: "{{ cloudProvider }}-orderer"
values_file: "{{ release_dir }}/{{ component_type }}/{{ sc_name }}.yaml"
when: component_type == 'orderer' and get_sc.resources|length == 0

Expand All @@ -48,7 +48,7 @@
src: "{{ sc_templates[type] }}"
dest: "{{ values_file }}"
vars:
type: "{{item.cloud_provider}}-peer"
type: "{{ cloudProvider }}-peer"
values_file: "{{ release_dir }}/{{ component_type }}/{{ sc_name }}.yaml"
when: component_type == 'peer' and get_sc.resources|length == 0

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 28b764d

Please sign in to comment.