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

Je 63662 #9

Open
wants to merge 17 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
5 changes: 3 additions & 2 deletions build-cluster.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@auth
//@req(nodeGroup, volumePath)
//@req(nodeGroup, volumePath, port)

var envName = '${env.envName}',
nodes = jelastic.env.control.GetEnvInfo(envName, session).nodes,
Expand All @@ -15,7 +15,8 @@ if (servers.length == 1) servers[0] = volumePath;

for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeGroup != nodeGroup) continue;
resp.push(jelastic.env.control.SetDockerRunCmd(envName, session, nodes[i].id, "server " + servers.join(' ') + " --address :$PORT"));
resp.push(jelastic.env.file.ReplaceInBody(envName, session, '/etc/default/minio', '^MINIO_VOLUMES=.*', "MINIO_VOLUMES=\"" + servers.join(' ') + "\"", 1, null, null, false, nodes[i].id ));
resp.push(jelastic.env.file.ReplaceInBody(envName, session, '/etc/default/minio', '^MINIO_OPTS=.*', "MINIO_OPTS=\" --address :" + port + " --console-address :" + consolePort + "\"", 1, null, null, false, nodes[i].id ));
}

return {
Expand Down
106 changes: 92 additions & 14 deletions manifest.jps
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ description:
globals:
accessKey: ${fn.password}
secretKey: ${fn.password}
port: 80
consolePort: 4949
exportPath: /export
DEPLOY_HOOK: /root/deployLE.sh
UNDEPLOY_HOOK: /root/undeployLE.sh
DEPLOY_HOOK_JS: ${baseUrl}/scripts/deployHook.js

onBeforeInit: |
var settings = jps.settings;
var fields = settings.fields;
if ("${quota.environment.externalip.enabled}" == 0) {
settings.fields = fields.filter(function(item) { return item.name != "le-addon" });
}
return { result: 0, settings: settings };

settings:
fields:
Expand All @@ -33,33 +47,97 @@ settings:
16: 16 nodes
default: 4
required: true

- type: checkbox
name: le-addon
caption: Install Let's Encrypt Certificates and Custom Domains Addon. Public IP is required.
value: false

nodes:
count: ${settings.nodes}
cloudlets: 16
nodeGroup: cp
image: minio/minio:RELEASE.2020-12-03T05-49-24Z
env:
MINIO_ACCESS_KEY: ${globals.accessKey}
MINIO_SECRET_KEY: ${globals.secretKey}
PORT: 80
cmd: --help
volumes:
- /export/

ssl: true
image: jelastic/minio:RELEASE.2023-02-27T18-10-45Z
password: ${globals.secretKey}
skipNodeEmails: true
validation:
maxCount: ${settings.nodes}
minCount: ${settings.nodes}

onAfterChangeTopology:
- if (${event.response.response.env.sslstate}):
cmd[cp]: iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 4949
- else:
cmd[cp]: iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 4949

onInstall:
- cmd[cp]: |-
jem passwd set -p ${globals.secretKey} -u ${globals.accessKey}
jem service stop
rm -rf /${globals.exportPath}/.minio.sys
user: root
- cmd[cp]: |-
echo "MINIO_SERVER_URL=${env.protocol}://${env.domain}" >> /etc/default/minio
echo "MINIO_BROWSER_REDIRECT_URL=${env.protocol}://${env.domain}:4949" >> /etc/default/minio
- build-cluster
- if (!${settings.le-addon:false}):
- installAddon:
id: letsencrypt-ssl-addon
nodeGroup: cp
- if (${settings.le-addon:false}):
- install-LE:
skipEnvs: true
- setGlobals:
PROTOCOL: https
- restartContainers [cp]

actions:
build-cluster:
script: build-cluster.js
params:
nodeGroup: cp
volumePath: /export

volumePath: ${globals.exportPath}
port: ${globals.port}
consolePort: ${globals.consolePort}

install-LE:
- cmd[cp]: |-
printf '#!/bin/bash
mkdir -p /export/.minio/certs/
cp /var/lib/jelastic/keys/privkey.pem /export/.minio/certs/private.key
cp /var/lib/jelastic/keys/fullchain.pem /export/.minio/certs/public.crt
sed -i "s|MINIO_SERVER_URL=http://|MINIO_SERVER_URL=https://|g" /etc/default/minio
sed -i "s|MINIO_BROWSER_REDIRECT_URL=http://|MINIO_BROWSER_REDIRECT_URL=https://|g" /etc/default/minio
sed -i "s|MINIO_OPTS=.*|MINIO_OPTS=\\" --address :443 --console-address :4949 --certs-dir /export/.minio/certs\\"|g" /etc/default/minio
service minio restart' > ${globals.DEPLOY_HOOK}

printf '#!/bin/bash
sed -i "s|MINIO_SERVER_URL=https://|MINIO_SERVER_URL=http://|g" /etc/default/minio
sed -i "s|MINIO_BROWSER_REDIRECT_URL=https://|MINIO_BROWSER_REDIRECT_URL=http://|g" /etc/default/minio
sed -i "s|MINIO_OPTS=.*|MINIO_OPTS=\\" --address :80 --console-address :4949\\"|g" /etc/default/minio
service minio restart' > ${globals.UNDEPLOY_HOOK}
- install:
jps: https://raw.githubusercontent.com/jelastic-jps/lets-encrypt/master/manifest.jps?_r=${fn.random}
nodeGroup: cp
settings:
deployHook: ${globals.DEPLOY_HOOK_JS}
deployHookType: js
undeployHook: ${globals.DEPLOY_HOOK_JS}
undeployHookType: js
customDomains: ${env.domain}

addons:
- id: letsencrypt-ssl-addon
name: Let's Encrypt + Custom Domains
description: Press "Install" button to initiate installation procedure
globals:
HTTPS_PORT: 443
buttons:
- caption: Install
action: install-LE
loadingText: Installing...
confirmText: Do you want to install Let's Encrypt addon?
successText: Let's Encrypt addon has been successfully installed!

success:
text: /text/success.md
email: /text/success.md
10 changes: 10 additions & 0 deletions scripts/deployHook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
envName = getParam('envName');
envDomain = getParam('envDomain');
scriptName = getParam('action') == 'uninstall' ? 'undeployLE.sh' : 'deployLE.sh';

//getting first custom domain
customDomains = (getParam('customDomains') || "").replace(/^\s+|\s+$/gm , "").split(/\s*[;,\s]\s*/).shift();
domain = customDomains || envDomain;

//executing custom deployment hook script on master node
return api.env.control.ExecCmdById(envName, session, getParam('nodeId'), toJSON([{ command:'/bin/bash /root/' + scriptName}]), true);
2 changes: 1 addition & 1 deletion text/success.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Admin Panel: [${env.url}](${env.url})
Admin Panel: [${globals.PROTOCOL:http}://${env.domain}/](${globals.PROTOCOL:http}://${env.domain}/)
Access Key: ${globals.accessKey}
Secret Key: ${globals.secretKey}

Expand Down