You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/01/19 17:48:22 UTC
[14/26] stratos git commit: dependency-scaling group-scaling-v1 -
Kubernetes sample application
dependency-scaling group-scaling-v1 - Kubernetes sample application
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/392e2b1c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/392e2b1c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/392e2b1c
Branch: refs/heads/master
Commit: 392e2b1cde633d56e0e434edbeda1180b7adfa5e
Parents: 1a2170b
Author: Vishanth <vi...@gmail.com>
Authored: Mon Jan 19 13:23:22 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Jan 19 22:17:17 2015 +0530
----------------------------------------------------------------------
.../artifacts/app_deployment_policy.json | 68 ++++++++++++++++++++
.../artifacts/autoscale-policy-c1.json | 14 ++++
.../artifacts/autoscale-policy-c2.json | 14 ++++
.../artifacts/autoscale-policy-c3.json | 14 ++++
.../artifacts/autoscale-policy-c4.json | 14 ++++
.../kubernetes/artifacts/c1.json | 34 ++++++++++
.../kubernetes/artifacts/c2.json | 34 ++++++++++
.../kubernetes/artifacts/c3.json | 34 ++++++++++
.../kubernetes/artifacts/c4.json | 34 ++++++++++
.../artifacts/composite_application.json | 47 ++++++++++++++
.../kubernetes/artifacts/group1.json | 18 ++++++
samples/group-scaling-v1/kubernetes/deploy.sh | 31 +++++++++
12 files changed, 356 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/app_deployment_policy.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/app_deployment_policy.json b/samples/group-scaling-v1/kubernetes/artifacts/app_deployment_policy.json
new file mode 100644
index 0000000..29075a3
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/app_deployment_policy.json
@@ -0,0 +1,68 @@
+{
+ "applicationId": "appscaling",
+ "applicationPolicy": {
+ "networkPartition": [
+ {
+ "id":"network-p1",
+ "kubernetesClusterId":"kubernetes-cluster-1",
+ "activeByDefault": "true",
+ "partitions": [
+ {
+ "id": "P1",
+ "provider": "kubernetes",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "network-p2",
+ "activeByDefault": "false",
+ "partitions": [
+ {
+ "id": "P1",
+ "provider": "kubernetes",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "childPolicies": [
+ {
+ "alias": "mygroup2",
+ "networkPartition": [
+ {
+ "id": "network-p1",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "P1",
+ "max": 2
+ }
+ ]
+ },
+ {
+ "id": "network-p2",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "P1",
+ "max": 2
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c1.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c1.json b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c1.json
new file mode 100755
index 0000000..dacdeeb
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c1.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscale_policy_c1",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 80
+ },
+ "memoryConsumption": {
+ "threshold": 20
+ },
+ "loadAverage": {
+ "threshold": 50
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c2.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c2.json b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c2.json
new file mode 100755
index 0000000..b908013
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c2.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscale_policy_c2",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 90
+ },
+ "memoryConsumption": {
+ "threshold": 5
+ },
+ "loadAverage": {
+ "threshold": 50
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c3.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c3.json b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c3.json
new file mode 100755
index 0000000..f2942a0
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c3.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscale_policy_c3",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 100
+ },
+ "memoryConsumption": {
+ "threshold": 10
+ },
+ "loadAverage": {
+ "threshold": 50
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c4.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c4.json b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c4.json
new file mode 100755
index 0000000..4b6db88
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/autoscale-policy-c4.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscale_policy_c4",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 50
+ },
+ "memoryConsumption": {
+ "threshold": 28
+ },
+ "loadAverage": {
+ "threshold": 75
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/c1.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/c1.json b/samples/group-scaling-v1/kubernetes/artifacts/c1.json
new file mode 100755
index 0000000..d74fca0
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/c1.json
@@ -0,0 +1,34 @@
+{
+ "type": "c1",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c1",
+ "description": "c1 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/cartridge:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/c2.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/c2.json b/samples/group-scaling-v1/kubernetes/artifacts/c2.json
new file mode 100755
index 0000000..d5ba39d
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/c2.json
@@ -0,0 +1,34 @@
+{
+ "type": "c2",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c2",
+ "description": "c2 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/cartridge:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/c3.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/c3.json b/samples/group-scaling-v1/kubernetes/artifacts/c3.json
new file mode 100755
index 0000000..aa46b72
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/c3.json
@@ -0,0 +1,34 @@
+{
+ "type": "c3",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c3",
+ "description": "c3 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/cartridge:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/c4.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/c4.json b/samples/group-scaling-v1/kubernetes/artifacts/c4.json
new file mode 100755
index 0000000..52ffdd1
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/c4.json
@@ -0,0 +1,34 @@
+{
+ "type": "c4",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c4",
+ "description": "c4 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/cartridge:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/composite_application.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/composite_application.json b/samples/group-scaling-v1/kubernetes/artifacts/composite_application.json
new file mode 100644
index 0000000..cee3d52
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/composite_application.json
@@ -0,0 +1,47 @@
+{
+ "applicationId": "appscaling",
+ "alias": "appscaling",
+ "components": {
+ "groups": [
+ {
+ "name": "group2",
+ "alias": "mygroup2",
+ "groupMinInstances": 1,
+ "groupMaxInstances": 2,
+ "cartridges": [
+ {
+ "type": "c2",
+ "cartridgeMin": 2,
+ "cartridgeMax": 4,
+ "subscribableInfo": {
+ "alias": "group2c2",
+ "autoscalingPolicy": "autoscale_policy_c2"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-c2-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ },
+ {
+ "type": "c3",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "group2c3",
+ "autoscalingPolicy": "autoscale_policy_c3"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-c3-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/artifacts/group1.json
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/artifacts/group1.json b/samples/group-scaling-v1/kubernetes/artifacts/group1.json
new file mode 100644
index 0000000..d1d4267
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/artifacts/group1.json
@@ -0,0 +1,18 @@
+{
+ "name": "group2",
+ "groupScalingEnabled": "true",
+ "cartridges": [
+ "c2",
+ "c3"
+ ],
+ "dependencies": {
+ "startupOrders": [
+ "cartridge.c3,cartridge.c2"
+ ],
+ "scalingDependants": [
+ "cartridge.c3, cartridge.c2"
+ ],
+ "terminationBehaviour": "terminate-all"
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/392e2b1c/samples/group-scaling-v1/kubernetes/deploy.sh
----------------------------------------------------------------------
diff --git a/samples/group-scaling-v1/kubernetes/deploy.sh b/samples/group-scaling-v1/kubernetes/deploy.sh
new file mode 100755
index 0000000..019f134
--- /dev/null
+++ b/samples/group-scaling-v1/kubernetes/deploy.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Create autoscale policy
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/autoscale-policy-c1.json' -k -v -u admin:admin https://localhost:9443/api/autoscalingPolicies
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/autoscale-policy-c2.json' -k -v -u admin:admin https://localhost:9443/api/autoscalingPolicies
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/autoscale-policy-c3.json' -k -v -u admin:admin https://localhost:9443/api/autoscalingPolicies
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/autoscale-policy-c4.json' -k -v -u admin:admin https://localhost:9443/api/autoscalingPolicies
+
+# Deploy c3 cartridge
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/c3.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy c4 cartridge
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/c4.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy c1 cartride
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/c1.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy c2 cartride
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/c2.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy group
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/group1.json' -k -v -u admin:admin https://localhost:9443/api/cartridgeGroups
+
+sleep 3
+# Create application
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/composite_application.json' -k -v -u admin:admin https://localhost:9443/api/applications
+
+sleep 3
+# Deploy application
+curl -X POST -H "Content-Type: application/json" -d@'artifacts/app_deployment_policy.json' -k -v -u admin:admin https://localhost:9443/api/applications/appscaling/deploy
+