Skip to content

Commit 07909d2

Browse files
committed
Merge branch 'master' into v1.15.0
2 parents 5bd19bd + eae2a57 commit 07909d2

File tree

4 files changed

+217
-145
lines changed

4 files changed

+217
-145
lines changed

configs/settings.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
fields:
2+
- name: deploy
3+
type: radio-fieldset
4+
values:
5+
cc: Clean cluster with pre-deployed HelloWorld example
6+
cmd: Deploy custom helm or stack via shell command
7+
default: cc
8+
showIf:
9+
cmd:
10+
name: cmd
11+
type: text
12+
height: 65
13+
required: true
14+
hideLabel: true
15+
default: |-
16+
helm repo add ibm-charts https://raw.githubusercontent.com/IBM/charts/master/repo/stable/
17+
helm install --name default --set autoscaling.enabled=true --set autoscaling.minReplicas=2 ibm-charts/ibm-open-liberty --version 1.6.0 --debug
18+
kubectl apply -f https://raw.githubusercontent.com/jelastic-jps/kubernetes/master/addons/openliberty.yaml
19+
20+
- name: label
21+
caption: Topology
22+
type: displayfield
23+
- name: topo
24+
type: radio-fieldset
25+
values:
26+
0-dev: '<b>Development:</b> one master (1) and one scalable worker (1+)'
27+
1-prod: '<b>Production:</b> multi master (3) with API balancers (2+) and scalable workers (2+)'
28+
default: 0-dev
29+
30+
- type: checkbox
31+
name: storage
32+
caption: Attach dedicated NFS Storage with dynamic volume provisioning
33+
value: true
34+
35+
- type: checkbox
36+
name: api
37+
caption: Enable Remote API Access
38+
value: false
39+
40+
- type: string
41+
name: version
42+
inputType: hidden
43+
caption: Kubernetes Version
44+
default: v1.15.0

manifest.jps

Lines changed: 2 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -14,152 +14,9 @@ name: Kubernetes Cluster
1414
targetRegions:
1515
type: vz7
1616

17-
settings:
18-
fields:
19-
- name: deploy
20-
type: radio-fieldset
21-
values:
22-
cc: Clean cluster with pre-deployed HelloWorld example
23-
cmd: Deploy custom helm or stack via shell command
24-
default: cc
25-
showIf:
26-
cmd:
27-
name: cmd
28-
type: text
29-
height: 65
30-
required: true
31-
hideLabel: true
32-
default: |-
33-
helm repo add ibm-charts https://raw.githubusercontent.com/IBM/charts/master/repo/stable/
34-
helm install --name default --set autoscaling.enabled=true --set autoscaling.minReplicas=2 ibm-charts/ibm-open-liberty --version 1.6.0 --debug
35-
kubectl apply -f https://raw.githubusercontent.com/jelastic-jps/kubernetes/master/addons/openliberty.yaml
36-
37-
- name: label
38-
caption: Topology
39-
type: displayfield
40-
- name: topo
41-
type: radio-fieldset
42-
values:
43-
0-dev: '<b>Development:</b> one master (1) and one scalable worker (1+)'
44-
1-prod: '<b>Production:</b> multi master (3) with API balancers (2+) and scalable workers (2+)'
45-
default: 0-dev
46-
47-
- type: checkbox
48-
name: storage
49-
caption: Attach dedicated NFS Storage with dynamic volume provisioning
50-
value: true
51-
52-
- type: checkbox
53-
name: api
54-
caption: Enable Remote API Access
55-
value: false
56-
57-
- type: list
58-
name: version
59-
inputType: hidden
60-
caption: Kubernetes Version
61-
values:
62-
v1.14.0: v1.14.0
63-
v1.14.1: v1.14.1
64-
v1.14.2: v1.14.2
65-
v1.14.3: v1.14.3
66-
v1.15.0: v1.15.0
67-
v1.15.1: v1.15.1
68-
default: v1.15.0
69-
7017
ssl: true
71-
72-
onBeforeInstall: |
73-
var k8smCount = '${settings.topo}' == '0-dev' ? 1 : 3,
74-
workerCount = k8smCount > 1 ? 2 : 1,
75-
tag = "${settings.version}";
76-
var resp = {
77-
result: 0,
78-
ssl: !!jelastic.billing.account.GetQuotas('environment.jelasticssl.enabled').array[0].value,
79-
nodes: [{
80-
count: k8smCount,
81-
cloudlets: 32,
82-
nodeType: "kubernetes",
83-
tag: tag,
84-
scalingMode: "stateless",
85-
nodeGroup: "k8sm",
86-
displayName: "Master",
87-
extip: false,
88-
env: {
89-
JELASTIC_EXPOSE: false
90-
},
91-
volumes: [
92-
"/var/lib/connect"
93-
],
94-
volumeMounts: {
95-
"/var/lib/connect": {
96-
readOnly: true,
97-
sourcePath: "/var/lib/connect",
98-
sourceNodeGroup: "k8sm"
99-
}
100-
}
101-
}, {
102-
count: workerCount,
103-
nodeGroup: "cp",
104-
nodeType: "kubernetes",
105-
tag: tag,
106-
scalingMode: "stateless",
107-
displayName: "Workers",
108-
cloudlets: 32,
109-
extip: ${settings.extip:false},
110-
env: {
111-
JELASTIC_EXPOSE: false
112-
},
113-
volumes: [
114-
"/var/lib/connect"
115-
],
116-
volumeMounts: {
117-
"/var/lib/connect": {
118-
readOnly: true,
119-
sourcePath: "/var/lib/connect",
120-
sourceNodeGroup: "k8sm"
121-
}
122-
}
123-
}]
124-
}
125-
126-
if (k8smCount > 1) {
127-
resp.nodes.push({
128-
count: 2,
129-
nodeType: "haproxy",
130-
cloudlets: 8,
131-
displayName: "API Balancer",
132-
nodeGroup: "mbl",
133-
env: {
134-
JELASTIC_PORTS: 6443
135-
}
136-
})
137-
}
138-
139-
if (${settings.storage:false}) {
140-
var path = "/data";
141-
resp.nodes.push({
142-
count: 1,
143-
nodeType: "storage",
144-
cloudlets: 8,
145-
displayName: "Storage",
146-
nodeGroup: "storage",
147-
volumes: [
148-
path
149-
]
150-
})
151-
152-
for (var i = 0; i < 2; i++){
153-
var n = resp.nodes[i];
154-
n.volumes.push(path);
155-
n.volumeMounts[path] = {
156-
readOnly: false,
157-
sourcePath: path,
158-
sourceNodeGroup: "storage"
159-
};
160-
}
161-
}
162-
return resp;
18+
onBeforeInit: /scripts/beforeinit.js
19+
onBeforeInstall: /scripts/beforeinstall.js
16320

16421
nodes: definedInOnBeforeInstall
16522

scripts/beforeinit.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//checking quotas
2+
var perEnv = "environment.maxnodescount",
3+
maxEnvs = "environment.maxcount",
4+
perNodeGroup = "environment.maxsamenodescount";
5+
var envsCount = jelastic.env.control.GetEnvs({lazy: true}).infos.length,
6+
nodesPerProdEnv = 8,
7+
nodesPerProdEnvWOStorage = 7,
8+
nodesPerDevEnv = 3,
9+
nodesPerDevEnvWOStorage = 2,
10+
nodesPerMasterNG = 3,
11+
nodesPerWorkerNG = 2,
12+
markup = "", cur = null, text = "used", prod = true, storage = true, dev = true;
13+
14+
var quotas = jelastic.billing.account.GetQuotas(perEnv + ";"+maxEnvs+";" + perNodeGroup).array;
15+
for (var i = 0; i < quotas.length; i++){
16+
var q = quotas[i], n = toNative(q.quota.name);
17+
if (n == maxEnvs && envsCount >= q.value){
18+
err(q, "already used", envsCount, true);
19+
markup = "Maximum allowed environments: " + markup;
20+
prod = dev = storage = false; break;
21+
}
22+
if (n == perEnv && nodesPerProdEnv > q.value){
23+
if (!markup) err(q, "required", nodesPerProdEnv);
24+
prod = false;
25+
if (nodesPerProdEnvWOStorage <= q.value) {
26+
prod = true;
27+
storage = false;
28+
}
29+
}
30+
if (n == perEnv && nodesPerDevEnv > q.value){
31+
err(q, "required", nodesPerDevEnv, true);
32+
dev = false;
33+
if (nodesPerDevEnvWOStorage <= q.value) {
34+
dev = true;
35+
storage = false;
36+
}
37+
}
38+
if (n == perNodeGroup && nodesPerMasterNG > q.value){
39+
if (!markup) err(q, "required", nodesPerMasterNG);
40+
prod = false;
41+
}
42+
if (n == perNodeGroup && nodesPerWorkerNG > q.value){
43+
err(q, "required", nodesPerWorkerNG);
44+
dev = false;
45+
}
46+
}
47+
var resp = {result:0};
48+
var url = "https://raw.githubusercontent.com/sych74/kubernetes/master/configs/settings.yaml";
49+
resp.settings = toNative(new org.yaml.snakeyaml.Yaml().load(new com.hivext.api.core.utils.Transport().get(url)));
50+
if (markup) {
51+
var f = resp.settings.fields;
52+
f.push({
53+
"type": "displayfield",
54+
"cls": "warning",
55+
"height": 30,
56+
"hideLabel": true,
57+
"markup": (!prod && dev ? "Production topology is not available. " : "") + markup + "Please upgrade your account."
58+
});
59+
if (!prod && !dev){
60+
f.push({
61+
"type": "compositefield",
62+
"height" : 0,
63+
"hideLabel": true,
64+
"width": 0,
65+
"items": [{
66+
"height" : 0,
67+
"type": "string",
68+
"required": true,
69+
}]
70+
});
71+
} else {
72+
if (!pod) delete f[2].values["1-prod"];
73+
if (!storage) f.splice(3, 1);
74+
}
75+
}
76+
return resp;
77+
78+
function err(e, text, cur, override){
79+
var m = (e.quota.description || e.quota.name) + " - " + e.value + ", " + text + " - " + cur + ". ";
80+
if (override) markup = m; else markup += m;
81+
}

scripts/beforeinstall.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
var k8smCount = '${settings.topo}' == '0-dev' ? 1 : 3,
2+
workerCount = k8smCount > 1 ? 2 : 1,
3+
tag = "${settings.version}";
4+
var resp = {
5+
result: 0,
6+
ssl: !!jelastic.billing.account.GetQuotas('environment.jelasticssl.enabled').array[0].value,
7+
nodes: [{
8+
count: k8smCount,
9+
cloudlets: 32,
10+
nodeType: "kubernetes",
11+
tag: tag,
12+
scalingMode: "stateless",
13+
nodeGroup: "k8sm",
14+
displayName: "Master",
15+
extip: false,
16+
env: {
17+
JELASTIC_EXPOSE: false
18+
},
19+
volumes: [
20+
"/var/lib/connect"
21+
],
22+
volumeMounts: {
23+
"/var/lib/connect": {
24+
readOnly: true,
25+
sourcePath: "/var/lib/connect",
26+
sourceNodeGroup: "k8sm"
27+
}
28+
}
29+
}, {
30+
count: workerCount,
31+
nodeGroup: "cp",
32+
nodeType: "kubernetes",
33+
tag: tag,
34+
scalingMode: "stateless",
35+
displayName: "Workers",
36+
cloudlets: 32,
37+
extip: ${settings.extip:false},
38+
env: {
39+
JELASTIC_EXPOSE: false
40+
},
41+
volumes: [
42+
"/var/lib/connect"
43+
],
44+
volumeMounts: {
45+
"/var/lib/connect": {
46+
readOnly: true,
47+
sourcePath: "/var/lib/connect",
48+
sourceNodeGroup: "k8sm"
49+
}
50+
}
51+
}]
52+
}
53+
54+
if (k8smCount > 1) {
55+
resp.nodes.push({
56+
count: 2,
57+
nodeType: "haproxy",
58+
cloudlets: 8,
59+
displayName: "API Balancer",
60+
nodeGroup: "mbl",
61+
env: {
62+
JELASTIC_PORTS: 6443
63+
}
64+
})
65+
}
66+
67+
if (${settings.storage:false}) {
68+
var path = "/data";
69+
resp.nodes.push({
70+
count: 1,
71+
nodeType: "storage",
72+
cloudlets: 8,
73+
displayName: "Storage",
74+
nodeGroup: "storage",
75+
volumes: [
76+
path
77+
]
78+
})
79+
80+
for (var i = 0; i < 2; i++){
81+
var n = resp.nodes[i];
82+
n.volumes.push(path);
83+
n.volumeMounts[path] = {
84+
readOnly: false,
85+
sourcePath: path,
86+
sourceNodeGroup: "storage"
87+
};
88+
}
89+
}
90+
return resp;

0 commit comments

Comments
 (0)