diff --git a/simple/cluster.py b/simple/cluster.py index aaa76f2..349c790 100644 --- a/simple/cluster.py +++ b/simple/cluster.py @@ -25,6 +25,9 @@ def GenerateConfig(context): 'license': context.properties['license'], 'cluster': context.properties['cluster'], 'region': context.properties['region'], + 'network': context.properties['network'], + 'dataRAMQuotaPercent': context.properties['dataRAMQuotaPercent'], + 'indexRAMQuotaPercent': context.properties['indexRAMQuotaPercent'], } for key in group: groupProperties[key] = group[key] diff --git a/simple/cluster.py.schema b/simple/cluster.py.schema index ef36dfc..5b3f63c 100644 --- a/simple/cluster.py.schema +++ b/simple/cluster.py.schema @@ -43,3 +43,16 @@ properties: runtimeconfigName: type: string description: The runtime config resource name. Used for notifying DM about the deployment status. + + network: + type: string + description: GCP VPC network name. + + dataRAMQuotaPercent: + type: integer + description: Memory Quota for Data Service (percent of total memory) + default: 50 + indexRAMQuotaPercent: + type: integer + description: Memory Quota for Index Service (percent of total memory) + default: 15 \ No newline at end of file diff --git a/simple/deployment.py b/simple/deployment.py index 008a4db..902446d 100644 --- a/simple/deployment.py +++ b/simple/deployment.py @@ -29,11 +29,11 @@ def GenerateConfig(context): 'couchbaseUsername': context.properties['couchbaseUsername'], 'couchbasePassword': context.properties['couchbasePassword'], 'license': context.properties['license'], - 'cluster': cluster['cluster'], - 'region': cluster['region'], - 'groups': cluster['groups'], + 'network': context.properties['network'], } } + for key in cluster: + clusterJSON['properties'][key] = cluster[key] config['resources'].append(clusterJSON) for group in cluster['groups']: @@ -47,18 +47,19 @@ def GenerateConfig(context): 'value': '$(ref.%s.text)' % readActionName }) - - firewall = { - 'name': naming.FirewallName(context), - 'type': 'compute.v1.firewall', - 'properties': { - 'sourceRanges': ['0.0.0.0/0'], - 'allowed': [{ - 'IPProtocol': 'tcp', - 'ports': ['8091', '4984', '4985'] - }] + if context.properties['firewall']: + firewall = { + 'name': naming.FirewallName(context), + 'type': 'compute.v1.firewall', + 'properties': { + 'network': 'global/networks/' + context.properties['network'], + 'sourceRanges': context.properties['firewallSourceRanges'], + 'allowed': [{ + 'IPProtocol': 'tcp', + 'ports': ['8091', '4984', '4985'] + }] + } } - } - config['resources'].append(firewall) + config['resources'].append(firewall) return config diff --git a/simple/deployment.py.schema b/simple/deployment.py.schema index e742cf0..ebf6bcf 100644 --- a/simple/deployment.py.schema +++ b/simple/deployment.py.schema @@ -30,3 +30,18 @@ properties: clusters: type: array description: The list of objects, each containing configuration for a single cluster resource. + + network: + type: string + description: GCP VPC network name. + default: default + + firewall: + type: boolean + default: true + + firewallSourceRanges: + type: array + description: Allowed source address ranges for cluster + default: + - "0.0.0.0/0" diff --git a/simple/group.py b/simple/group.py index 783eabc..2b796f8 100644 --- a/simple/group.py +++ b/simple/group.py @@ -104,7 +104,7 @@ def GenerateInstanceTemplateConfig(context, runtimeconfigName): 'properties': { 'machineType': context.properties['nodeType'], 'networkInterfaces': [{ - 'network': URL_BASE + context.env['project'] + '/global/networks/default', + 'network': 'global/networks/' + context.properties['network'], 'accessConfigs': [{ 'name': 'External NAT', 'type': 'ONE_TO_ONE_NAT' @@ -144,6 +144,8 @@ def GenerateInstanceTemplateConfig(context, runtimeconfigName): } } } + if context.properties['subnetwork']: + instanceTemplate['properties']['properties']['networkInterfaces'][0]['subnetwork'] = 'regions/' + context.properties['region'] + '/subnetworks/' + context.properties['subnetwork'] return instanceTemplate def GenerateInstanceGroupManagerConfig(context, instanceTemplateName, instanceGroupTargetSize, externalIpCreateActionName): @@ -222,6 +224,8 @@ def GenerateStartupScript(context): script += 'couchbaseUsername="' + context.properties['couchbaseUsername'] + '"\n' script += 'couchbasePassword="' + context.properties['couchbasePassword'] + '"\n' script += 'nodeCount="' + str(context.properties['clusterNodesCount']) + '"\n' + script += 'dataRAMQuotaPercent="' + str(context.properties['dataRAMQuotaPercent']) + '"\n' + script += 'indexRAMQuotaPercent="' + str(context.properties['indexRAMQuotaPercent']) + '"\n' servicesParameter='' for service in services: diff --git a/simple/group.py.schema b/simple/group.py.schema index b73c1c5..60d8b38 100644 --- a/simple/group.py.schema +++ b/simple/group.py.schema @@ -26,8 +26,11 @@ properties: description: Type of Couchbase license to be supported by the deployment. serverVersion: type: string - default: 5.5.0 + default: 5.5.3 enum: + - 6.0.1 + - 6.0.0 + - 5.5.3 - 5.5.0 - 5.1.0 - 5.0.1 @@ -80,4 +83,16 @@ properties: services: type: array description: A list of Couchbase services to be included in the instance group. + network: + type: string + description: GCP VPC network name. + subnetwork: + type: string + description: GCP VPN subnet name (mandatory if deploying on a network in custom subnet mode). + dataRAMQuotaPercent: + type: integer + description: Memory Quota for Data Service (percent of total memory) + indexRAMQuotaPercent: + type: integer + description: Memory Quota for Index Service (percent of total memory) diff --git a/simple/server.sh b/simple/server.sh index 2732dd2..9cfa6f5 100644 --- a/simple/server.sh +++ b/simple/server.sh @@ -130,8 +130,8 @@ echo "Running couchbase-cli node-init" if [[ $rallyPrivateDNS == $NODE_PRIVATE_DNS ]] then totalRAM=$(grep MemTotal /proc/meminfo | awk '{print $2}') - dataRAM=$((50 * $totalRAM / 100000)) - indexRAM=$((15 * $totalRAM / 100000)) + dataRAM=$(($dataRAMQuotaPercent * $totalRAM / 100000)) + indexRAM=$(($indexRAMQuotaPercent * $totalRAM / 100000)) echo "Running couchbase-cli cluster-init" ./couchbase-cli cluster-init \