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:16 UTC
[08/26] stratos git commit: Kubernetes complex-app sample application
Kubernetes complex-app sample application
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3e0eec32
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3e0eec32
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3e0eec32
Branch: refs/heads/master
Commit: 3e0eec32b7bcfe37342c19226fd334e68d265a1e
Parents: efb8724
Author: Vishanth <vi...@gmail.com>
Authored: Mon Jan 19 12:09:18 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Jan 19 22:17:16 2015 +0530
----------------------------------------------------------------------
.../artifacts/application_definition.json | 128 +++++++++++++++++++
.../kubernetes/artifacts/autoscale-policy.json | 14 ++
.../kubernetes/artifacts/deployment-policy.json | 72 +++++++++++
.../kubernetes/artifacts/group6c.json | 21 +++
.../kubernetes/artifacts/group8c.json | 21 +++
.../artifacts/kubernetes-cluster.json | 55 ++++++++
.../kubernetes/artifacts/tomcat.json | 34 +++++
.../kubernetes/artifacts/tomcat1.json | 34 +++++
.../kubernetes/artifacts/tomcat2.json | 34 +++++
samples/complex-app/kubernetes/deploy.sh | 35 +++++
10 files changed, 448 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/application_definition.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/application_definition.json b/samples/complex-app/kubernetes/artifacts/application_definition.json
new file mode 100644
index 0000000..942132d
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/application_definition.json
@@ -0,0 +1,128 @@
+{
+ "applicationId": "app_boo",
+ "alias": "app_boo_r2",
+ "components": {
+ "groups": [
+ {
+ "name": "group6",
+ "alias": "mygroup6",
+ "groupMinInstances": 1,
+ "groupMaxInstances": 1,
+ "groups": [
+ {
+ "name": "group7",
+ "alias": "mygroup7",
+ "groupMinInstances": 1,
+ "groupMaxInstances": 1,
+ "cartridges": [
+ {
+ "type": "tomcat1",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "group7tom",
+ "autoscalingPolicy": "autoscale_policy_1"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-tomcat1-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "cartridges": [
+ {
+ "type": "tomcat2",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "group6tom",
+ "autoscalingPolicy": "autoscale_policy_1"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-tomcat2-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "group8",
+ "alias": "mygroup8",
+ "groupMinInstances": 1,
+ "groupMaxInstances": 1,
+ "groups": [
+ {
+ "name": "group9",
+ "alias": "mygroup9",
+ "groupMinInstances": 1,
+ "groupMaxInstances": 1,
+ "cartridges": [
+ {
+ "type": "tomcat1",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "group9tom",
+ "autoscalingPolicy": "autoscale_policy_1"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-tomcat1-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "cartridges": [
+ {
+ "type": "tomcat2",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "group8tom",
+ "autoscalingPolicy": "autoscale_policy_1"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-tomcat2-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "cartridges": [
+ {
+ "type": "tomcat",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "mytomcat",
+ "autoscalingPolicy": "autoscale_policy_1"
+ "artifactRepository":{
+ "privateRepo":false,
+ "repoUrl":"https://github.com/imesh/stratos-tomcat-applications.git",
+ "repoUsername":"",
+ "repoPassword":""
+ }
+ }
+ }
+ ],
+ "dependencies": {
+ "startupOrders": [
+ "group.group8,cartridge.tomcat,group.group6"
+ ],
+ "terminationBehaviour": "terminate-all"
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/autoscale-policy.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/autoscale-policy.json b/samples/complex-app/kubernetes/artifacts/autoscale-policy.json
new file mode 100755
index 0000000..9e9ad99
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/autoscale-policy.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscale_policy_1",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 80
+ },
+ "memoryConsumption": {
+ "threshold": 90
+ },
+ "loadAverage": {
+ "threshold": 50
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/deployment-policy.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/deployment-policy.json b/samples/complex-app/kubernetes/artifacts/deployment-policy.json
new file mode 100644
index 0000000..82a3b40
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/deployment-policy.json
@@ -0,0 +1,72 @@
+{
+ "applicationId": "app_boo",
+ "applicationPolicy": {
+ "networkPartition": [
+ {
+ "id":"network-p1",
+ "kubernetesClusterId":"kubernetes-cluster-1",
+ "activeByDefault": "true",
+ "partitions": [
+ {
+ "id": "P1",
+ "provider": "mock",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "childPolicies": [
+ {
+ "alias": "mytomcat",
+ "networkPartition": [
+ {
+ "id": "network-p1",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "P1",
+ "max": 5
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "alias": "mygroup6",
+ "networkPartition": [
+ {
+ "id": "network-p1",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "P1",
+ "max": 5
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "alias": "mygroup8",
+ "networkPartition": [
+ {
+ "id": "network-p1",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "P1",
+ "max": 5
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/group6c.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/group6c.json b/samples/complex-app/kubernetes/artifacts/group6c.json
new file mode 100755
index 0000000..74fea79
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/group6c.json
@@ -0,0 +1,21 @@
+{
+ "name": "group6",
+ "groups": [
+ {
+ "name": "group7",
+ "cartridges": [
+ "tomcat1"
+ ]
+ }
+ ],
+ "cartridges": [
+ "tomcat2"
+ ],
+ "dependencies": {
+ "startupOrders": [
+ "group.group7,cartridge.tomcat2"
+ ],
+ "terminationBehaviour": "terminate-all"
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/group8c.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/group8c.json b/samples/complex-app/kubernetes/artifacts/group8c.json
new file mode 100755
index 0000000..fac2096
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/group8c.json
@@ -0,0 +1,21 @@
+{
+ "name": "group8",
+ "groups": [
+ {
+ "name": "group9",
+ "cartridges": [
+ "tomcat1"
+ ]
+ }
+ ],
+ "cartridges": [
+ "tomcat2"
+ ],
+ "dependencies": {
+ "startupOrders": [
+ "group.group9,cartridge.tomcat2"
+ ],
+ "terminationBehaviour": "terminate-all"
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/kubernetes-cluster.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/kubernetes-cluster.json b/samples/complex-app/kubernetes/artifacts/kubernetes-cluster.json
new file mode 100644
index 0000000..228eeb3
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/kubernetes-cluster.json
@@ -0,0 +1,55 @@
+{
+ "clusterId": "kubernetes-cluster-1",
+ "description": "Kubernetes CoreOS cluster",
+ "kubernetesMaster": {
+ "hostId" : "KubHostMaster1",
+ "hostname" : "master.dev.kubernetes.example.org",
+ "hostIpAddress" : "172.17.8.100",
+ "property" : [
+ ]
+ },
+
+ "portRange" : {
+ "upper": "5000",
+ "lower": "4500"
+ },
+
+ "kubernetesHosts": [
+ {
+ "hostId" : "KubHostSlave1",
+ "hostname" : "slave1.dev.kubernetes.example.org",
+ "hostIpAddress" : "172.17.8.101",
+ "property" : [
+ ]
+ },
+ {
+ "hostId" : "KubHostSlave2",
+ "hostname" : "slave2.dev.kubernetes.example.org",
+ "hostIpAddress" : "172.17.8.102",
+ "property" : [
+ ]
+ }
+ ],
+ "property":[
+ {
+ "name":"payload_parameter.MB_IP",
+ "value":"172.17.8.1"
+ },
+ {
+ "name":"payload_parameter.MB_PORT",
+ "value":"1883"
+ },
+ {
+ "name":"payload_parameter.CEP_IP",
+ "value":"172.17.8.1"
+ },
+ {
+ "name":"payload_parameter.CEP_PORT",
+ "value":"7711"
+ },
+ {
+ "name":"payload_parameter.LOG_LEVEL",
+ "value":"DEBUG"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/tomcat.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/tomcat.json b/samples/complex-app/kubernetes/artifacts/tomcat.json
new file mode 100755
index 0000000..e24a4f6
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/tomcat.json
@@ -0,0 +1,34 @@
+{
+ "type": "tomcat",
+ "provider": "apache",
+ "host": "isuruh.lk",
+ "category": "data",
+ "displayName": "tomcat",
+ "description": "tomcat Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/php:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ],
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/tomcat1.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/tomcat1.json b/samples/complex-app/kubernetes/artifacts/tomcat1.json
new file mode 100755
index 0000000..a308a0e
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/tomcat1.json
@@ -0,0 +1,34 @@
+{
+ "type": "tomcat1",
+ "provider": "apache",
+ "category": "data",
+ "host": "isuruh.lk",
+ "displayName": "tomcat1",
+ "description": "tomcat1 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/php:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ],
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/artifacts/tomcat2.json
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/artifacts/tomcat2.json b/samples/complex-app/kubernetes/artifacts/tomcat2.json
new file mode 100755
index 0000000..25fefb6
--- /dev/null
+++ b/samples/complex-app/kubernetes/artifacts/tomcat2.json
@@ -0,0 +1,34 @@
+{
+ "type": "tomcat2",
+ "provider": "apache",
+ "category": "data",
+ "host": "isuruh.lk",
+ "displayName": "tomcat2",
+ "description": "tomcat2 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment":{
+ "baseDir":"/var/www"
+ },
+ "iaasProvider":[
+ {
+ "type":"kubernetes",
+ "imageId":"stratos/php:4.1.0-alpha",
+ "networkInterfaces":[
+ {
+ "name":"network-non-routable",
+ "networkUuid":""
+ }
+ ],
+ "property":[
+ ]
+ }
+ ],
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3e0eec32/samples/complex-app/kubernetes/deploy.sh
----------------------------------------------------------------------
diff --git a/samples/complex-app/kubernetes/deploy.sh b/samples/complex-app/kubernetes/deploy.sh
new file mode 100755
index 0000000..0743c7f
--- /dev/null
+++ b/samples/complex-app/kubernetes/deploy.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Create autoscale policy
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/autoscale-policy.json' -k -v -u admin:admin https://localhost:9443/api/autoscalingPolicies
+
+# Create tomcat cartridge
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/tomcat.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy tomcat1 cartride
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/tomcat1.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy tomcat2 cartride
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/tomcat2.json' -k -v -u admin:admin https://localhost:9443/api/cartridges
+
+# Deploy group
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/group6c.json' -k -v -u admin:admin https://localhost:9443/api/cartridgeGroups
+
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/group8c.json' -k -v -u admin:admin https://localhost:9443/api/cartridgeGroups
+
+# GET group
+#curl -X GET -H "Content-Type: application/json" -k -v -u admin:admin https://localhost:9443/api/cartridgeGroups/group6
+
+
+sleep 5
+# Create application
+curl -X POST -H "Content-Type: application/json" -d @'artifacts/application_definition.json' -k -v -u admin:admin https://localhost:9443/api/applications
+
+sleep 5
+# GET application
+# curl -X GET -H "Content-Type: application/json" -k -v -u admin:admin https://localhost:9443/api/applications/myapp1265
+
+# Deploy application
+
+sleep 3
+curl -X POST -H "Content-Type: application/json" -d@'artifacts/deployment-policy.json' -k -v -u admin:admin https://localhost:9443/api/applications/app_boo/deploy