Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve configurability of deployment template #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions simple/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 13 additions & 0 deletions simple/cluster.py.schema
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 16 additions & 15 deletions simple/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand All @@ -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
15 changes: 15 additions & 0 deletions simple/deployment.py.schema
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 5 additions & 1 deletion simple/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 16 additions & 1 deletion simple/group.py.schema
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions simple/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down