mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-08-23 21:46:21 +00:00
update doc
This commit is contained in:
+1
-1
@@ -808,7 +808,7 @@ k8s_jobs:
|
||||
<div id="alert_placeholder" style="margin-top: 3%;"></div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 2%; text-align: center; margin: auto; margin-top: 1%;">
|
||||
<canvas id="myCanvas" width="1200" height="800" class="game-canvas"></canvas>
|
||||
<canvas id="myCanvas" width="1200" height="800" class="game-canvas" style="background-color: #000000;"></canvas>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
|
||||
+70
-13
@@ -18,11 +18,17 @@
|
||||
|
||||
function setChaosReportURL(select) {
|
||||
var selectedValue = select.options[select.selectedIndex].value;
|
||||
if (selectedValue === "No Ingress found") {
|
||||
return;
|
||||
}
|
||||
document.getElementById("chaosReportCheckSiteURL").value = selectedValue;
|
||||
}
|
||||
|
||||
function addElementToSelect(selectId, elementValue) {
|
||||
var select = document.getElementById(selectId);
|
||||
if (!select || !elementValue) {
|
||||
return;
|
||||
}
|
||||
var option = document.createElement("option");
|
||||
option.text = elementValue;
|
||||
option.value = elementValue;
|
||||
@@ -30,17 +36,38 @@ function addElementToSelect(selectId, elementValue) {
|
||||
}
|
||||
|
||||
function parseIngressListJSON(ingressList) {
|
||||
var hostOfIngress = convertStringToArrayWithSeparator(ingressList, ",")
|
||||
|
||||
if (hostOfIngress.length > 0) {
|
||||
document.getElementById("chaosReportCheckSiteURL").value = hostOfIngress[0];
|
||||
var select = document.getElementById("ingressHostList");
|
||||
if (!select) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i in hostOfIngress) {
|
||||
if (hostOfIngress[i] != "No Ingress found") {
|
||||
addElementToSelect("ingressHostList", hostOfIngress[i]);
|
||||
}
|
||||
select.innerHTML = "";
|
||||
|
||||
var hostOfIngress = [];
|
||||
if (Array.isArray(ingressList)) {
|
||||
hostOfIngress = ingressList;
|
||||
} else if (typeof ingressList === "string") {
|
||||
hostOfIngress = convertStringToArrayWithSeparator(ingressList, ",");
|
||||
}
|
||||
|
||||
hostOfIngress = hostOfIngress
|
||||
.map(function (host) {
|
||||
return String(host || "").trim();
|
||||
})
|
||||
.filter(function (host) {
|
||||
return host !== "" && host !== "No Ingress found";
|
||||
});
|
||||
|
||||
if (hostOfIngress.length === 0) {
|
||||
addElementToSelect("ingressHostList", "No Ingress found");
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < hostOfIngress.length; i++) {
|
||||
addElementToSelect("ingressHostList", hostOfIngress[i]);
|
||||
}
|
||||
|
||||
document.getElementById("chaosReportCheckSiteURL").value = hostOfIngress[0];
|
||||
}
|
||||
|
||||
function resizeCharts() {
|
||||
@@ -56,12 +83,42 @@ function resizeCharts() {
|
||||
}
|
||||
|
||||
function getIngressLists() {
|
||||
if (!namespace && configured_namespaces && configured_namespaces.length > 0) {
|
||||
namespace = configured_namespaces[0];
|
||||
}
|
||||
|
||||
if (!namespace) {
|
||||
$('#alert_placeholder').replaceWith(alert_div + 'Set at least one namespace before configuring ingress checks.</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.onreadystatechange = function () {
|
||||
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
|
||||
parseIngressListJSON(JSON.parse(this.responseText));
|
||||
oReq.onload = function () {
|
||||
if (this.status !== 200) {
|
||||
$('#alert_placeholder').replaceWith(alert_div + 'Ingress lookup failed with status ' + this.status + ' on namespace ' + namespace + '.</div>');
|
||||
parseIngressListJSON([]);
|
||||
return;
|
||||
}
|
||||
};;
|
||||
|
||||
var ingressData = [];
|
||||
try {
|
||||
ingressData = JSON.parse(this.responseText);
|
||||
} catch (e) {
|
||||
ingressData = [];
|
||||
}
|
||||
|
||||
parseIngressListJSON(ingressData);
|
||||
|
||||
if (!Array.isArray(ingressData) || ingressData.length === 0) {
|
||||
$('#alert_placeholder').replaceWith(alert_div + 'No ingress hosts found in namespace ' + namespace + '. You can type a URL manually.</div>');
|
||||
}
|
||||
};
|
||||
|
||||
oReq.onerror = function () {
|
||||
$('#alert_placeholder').replaceWith(alert_div + 'Ingress lookup failed due to network or CORS error. You can type a URL manually.</div>');
|
||||
parseIngressListJSON([]);
|
||||
};
|
||||
|
||||
var ingressUrl = appendK8sTargetParam(k8s_url + "/kube/ingresses?namespace=" + namespace);
|
||||
oReq.open("GET", ingressUrl, true);
|
||||
applyK8sConnectionHeaders(oReq);
|
||||
@@ -94,7 +151,7 @@ function chaosReportHttpEndpointAdd() {
|
||||
<div class="row">
|
||||
<div class="col col-xl-10" style="margin-top: 2%;">
|
||||
<label for="ingressHostList">Ingress Host List</label>
|
||||
<select id="ingressHostList" class="form-select" aria-label="Ingress Host List" onclick="setModalState(true)">
|
||||
<select id="ingressHostList" class="form-select" aria-label="Ingress Host List" onclick="setModalState(true)" onchange="setChaosReportURL(this)">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+21
-7
@@ -161,9 +161,14 @@ function setCodeNameToTextInput(elementId) {
|
||||
function getMetrics() {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.onload = function () {
|
||||
if (this.status !== 200) {
|
||||
console.warn('[METRICS] /metrics returned status ' + this.status);
|
||||
return;
|
||||
}
|
||||
var lines = this.responseText.split('\n');
|
||||
for (var i = 0;i < lines.length;i++){
|
||||
metric = lines[i].split(' ');
|
||||
var metric = lines[i].split(' ');
|
||||
if (!metric[0] || metric[0] === '') continue;
|
||||
|
||||
if (metric[0] == "chaos_node_jobs_total") {
|
||||
$('#chaos_jobs_total').text(metric[1]);
|
||||
@@ -189,7 +194,7 @@ function getMetrics() {
|
||||
$('#pods_match_regex').text(metric[1]);
|
||||
}
|
||||
else if (metric[0].match(chaos_job_regex)) {
|
||||
metrics_split = metric[0].split(":");
|
||||
var metrics_split = metric[0].split(":");
|
||||
chaos_jobs_status.set(metrics_split[1] + ":" + metrics_split[2] + ":" + metrics_split[3], metric[1]);
|
||||
}
|
||||
else if (metric[0] == "current_chaos_job_pod") {
|
||||
@@ -197,7 +202,10 @@ function getMetrics() {
|
||||
$('#current_chaos_job_pod').text(metric[1]);
|
||||
}
|
||||
}
|
||||
};;
|
||||
};
|
||||
oReq.onerror = function () {
|
||||
console.error('[METRICS] XHR error fetching /metrics');
|
||||
};
|
||||
oReq.open("GET", k8s_url + "/metrics");
|
||||
oReq.send();
|
||||
}
|
||||
@@ -205,16 +213,21 @@ function getMetrics() {
|
||||
function getChaosJobsPodsPhase() {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.onload = function () {
|
||||
if (this.status !== 200) return;
|
||||
var lines = this.responseText.split('\n');
|
||||
for (var i = 0;i < lines.length;i++){
|
||||
metric = lines[i].split(' ');
|
||||
var metric = lines[i].split(' ');
|
||||
if (!metric[0] || metric[0] === '') continue;
|
||||
|
||||
if (metric[0].match(chaos_job_regex)) {
|
||||
metrics_split = metric[0].split(":");
|
||||
var metrics_split = metric[0].split(":");
|
||||
chaos_jobs_status.set(metrics_split[1] + ":" + metrics_split[2] + ":" + metrics_split[3], metric[1]);
|
||||
}
|
||||
}
|
||||
};;
|
||||
};
|
||||
oReq.onerror = function () {
|
||||
console.error('[METRICS] XHR error fetching /chaos_jobs_pod_phase');
|
||||
};
|
||||
oReq.open("GET", k8s_url + "/chaos_jobs_pod_phase");
|
||||
oReq.send();
|
||||
}
|
||||
@@ -461,8 +474,9 @@ function getPods() {
|
||||
let new_pods = jsonData.items;
|
||||
|
||||
// Pod might just be killed in game, but not terminated in k8s yet.
|
||||
// Only keep "killed" visual if K8s hasn't reported it as fully ready again.
|
||||
for (i=0; i<new_pods.length; i++) {
|
||||
if (aliens.some((alien) => alien.name == new_pods[i].name && alien.status == "killed")) {
|
||||
if (new_pods[i].status !== "ready" && aliens.some((alien) => alien.name == new_pods[i].name && alien.status == "killed")) {
|
||||
new_pods[i].status = "killed";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user