我正在以docker-swarm模式部署服务。所以我有一个管理器和4个节点,这意味着我总共有5个实例。 但我想拆分2个工作节点和2个工作节点,并在不创建另一个实例的情况下向它们部署两个不同的服务。
实际上有可能吗? 喜欢 实例1(经理)-经理服务a,b 实例2(工人)-为a服务 实例3(工人)-服务a 实例4(工人)-服务b 实例4(工人)-服务b
因为我不想让另一个实例只拥有另一个经理..但是在任何地方都找不到任何合理的解决方案
答案 0 :(得分:0)
是的,您可以使用节点标签来实现-
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Plinko</title>
<link rel="icon" href="favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(() => {
$.ajax({
type: "GET",
url: "services/general/checkCacheVersion",
success: (data) => {
console.log(data);
if (data.split(";")[0] === "OK") {
setCookie("cacheVersion", data.split(";")[1] + "", 3650);
}
},
error: (e) => {
console.log(e);
}
});
});
</script>
<main class="main">
<div id="particles-js"></div>
<script src="js/login/particles.min.js"></script>
<script src="js/login/particle-app.js"></script>
<div class="overlay">
<div class="form-div">
<form id="submitForm">
<table>
<tr class="wrong-credentials"><td colspan="2" id="lang-wrong-credentials">Napačni podatki</td></tr>
<tr class="left"><td class="first" colspan="2"></td></tr>
<tr><td colspan="2"><input type="text" name="j_username" id="inputUser" placeholder="Uporabniško ime"></td></tr>
<tr class="left"><td class="first" colspan="2"></td></tr>
<tr><td colspan="2"><input type="password" name="j_password" id="inputPass" placeholder="Geslo"></td></tr>
<tr id="submit-tr"><td colspan="2"><input type="submit" class="button-tool" value="Prijava" id="submitLogin"></tr>
</table>
</form>
</div>
</div>
</main>
</body>
</html>
<script type="text/javascript">
var wrongCredentials = false;
$(document).ready(() => {
$("#submitForm").submit((e) => {
var loginOk = false;
e.preventDefault();
$.ajax({
type: "POST",
url: "j_security_check",
data: {
j_username: $("#inputUser").val(),
j_password: $("#inputPassword").val()
},
success: function(data) {
console.log(data);
if (data === undefined || data.indexOf("<title>Plinko Login Error</title>") === -1)
loginOk = true;
else
loginOk = false;
},
error: function(e) {
console.log(e);
},
complete: function() {
$.ajax({
type: "GET",
url: "services/general/login?username=" + $("#inputUser").val() + "&success=" + loginOk,
complete: function(e) {
console.log(e);
if (loginOk) {
if (wrongCredentials)
location.href = "index.html";
else
location.reload(true);
} else {
$(".wrong-credentials").show();
}
}
});
}
});
});
});
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
</script>
在YAML中-
--constraint 'node.labels.service== myservice1'
您只需要确保正确标记了处于群集模式的节点。
标签更新-https://docs.docker.com/engine/reference/commandline/node_update/