The GSCTL Utility for Persistent Data Using Amazon Volumes
Persisting services is useful in production environments because it allows us to reschedule a node without worrying about data loss.
In this topic you will learn how to deploy a cluster with volumes attached to services, supporting their life cycle.
Prerequisites:
-
ElasticGrid Cloud prerequisites (see Creating a GigaSpaces Cluster in the Cloud).
-
Configuring cluster yaml file
-
Configuring services yaml file
-
The following additional policies, to support two services, grafana and influxdb.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "ec2:DetachVolume", "ec2:AttachVolume", "iam:PassRole" ], "Resource": [ "arn:aws:ec2:*:*:instance/*", "arn:aws:ec2:*:*:volume/*", "arn:aws:iam::*:role/*" ] }, { "Sid": "VisualEditor1", "Effect": "Allow", "Action": [ "iam:ListPolicies", "ec2:DescribeVolumes" ], "Resource": "*" }, { "Sid": "VisualEditor2", "Effect": "Allow", "Action": [ "iam:CreateInstanceProfile", "iam:DeleteInstanceProfile", "iam:GetRole", "iam:GetPolicy", "iam:RemoveRoleFromInstanceProfile", "iam:DeletePolicy", "iam:CreateRole", "iam:DeleteRole", "iam:AttachRolePolicy", "iam:ListInstanceProfiles", "iam:AddRoleToInstanceProfile", "iam:CreatePolicy", "iam:DetachRolePolicy" ], "Resource": [ "arn:aws:iam::*:policy/*", "arn:aws:iam::*:instance-profile/*", "arn:aws:iam::*:role/*" ] } ] }
Configuring cluster yaml file:
1. To use the persistency feature, provide iamInstanceProfileArn with the following policy: set "<auto-generate>" or create a policy with the following rules:
Policy (policyDocument):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
}
Role (assumeRolePolicyDocument):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:DetachVolume",
"ec2:AttachVolume"
],
"Resource": [
"arn:aws:ec2:*:*:instance/*",
"arn:aws:ec2:*:*:volume/*"
]
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"ec2:DescribeVolumeStatus",
"ec2:DescribeInstances",
"ec2:DescribeVolumes",
"ec2:DescribeVolumesModifications",
"ec2:DescribeVolumeAttribute",
"ec2:DescribeInstanceStatus"
],
"Resource": "*"
}
]
}
2. In the volumes section, provide a list of IDs of an EBS volume created earlier. For each volume, provide a name for the gsctl environment.
The volume name must be unique. We will use the name later to reference the volume.
name: mishel
gsManagers: 3
clusterComponents:
- type: "AWS"
name: "AWS_1"
.
.
.
iamInstanceProfileArn: "<auto-generate>"
volumes:
ebs:
- name: "my-grafana"
id: "vol-062ace5b7ac63a939"
- name: "influxdb"
id: "vol-073d1c863cd698702"
Configuring services.yaml file
Now we must choose the service. We want to attach it a volume OR choose the sticky option to persist the data to the machine it runs on.
When using the sticky option, the system will make a best-effort attempt to keep the allocation on the same machine and to ensure that the data will be preserved through the entire life cycle.
Attaching the volume to the service
-
Enable persistency in the constraints section
-
Provide the volume name
Services yaml configuration of persistency with volume example
builtInServices:
grafana:
enabled: true
constraints:
targetComponents:
- "*"
targetProfiles:
- "*"
persistency:
enabled: true
sticky: false
volumes:
- "my-grafana"
properties: {}
Choosing sticky mode instead
-
Enable persistency in the constraints section
-
Enable sticky mode
Services yaml configuration of persistency with sticky example
builtInServices:
grafana:
enabled: true
constraints:
targetComponents:
- "*"
targetProfiles:
- "*"
persistency:
enabled: true
sticky: true
volumes: []
properties: {}
We can also target a profile or component that the service will run on: Choose “*” to allow placement on any profile/component (default).
Sample yaml files for persistent data
An example of the cluster.yaml file for persistent data:
; Cluster yaml file, the definition of a profile name:
name: mishel
gsManagers: 3
clusterComponents:
- type: "AWS"
name: "AWS_1"
.
.
.
masters:
label: "GS Cluster [gs-demo] Master Group"
profiles:
- name: "my-profile-name"
type: "m4.xlarge"
tags: []
count: 2
An example of the services.yaml file for persistent data:
builtInServices:
grafana:
enabled: true
constraints:
targetComponents:
- "*"
targetProfiles:
- "my-profile-name”
persistency:
enabled: true
sticky: true
volumes: []
properties: {}
Considerations
-
Persistency is supported for InfluxDB and Grafana.
-
Constraints are available for all services except MongoDB.
-
The manager service runs only on master nodes. In the example above, there are three manager nodes.