some improvements...

This commit is contained in:
luckysideburn
2024-08-29 20:57:46 +00:00
parent 61fc298184
commit 61e04d12a4
14 changed files with 224 additions and 147 deletions
+1
View File
@@ -1,3 +1,4 @@
develop.tar
utils
dev-tools/*.tgz
.vagrant
+6
View File
File diff suppressed because one or more lines are too long
+34 -25
View File
@@ -74,39 +74,43 @@ function addPostUploadFile(selectedValue) {
function chaosReportHttpEndpointAdd() {
$("#addSiteAreaChaosReport").html(`
<div class="row">
<div class="col col-xl-10" sytle="margin-top: 2%;">
<label for="chaosReportCheckSiteURL">Ingress Host List</label>
<select id="ingressHostList" class="form-select" aria-label="Ingress Host List" onchange="setChaosReportURL(this)">
</select>
<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" onchange="setChaosReportURL(this)">
</select>
</div>
</div>
<div class="row" style="margin-top: 2%;">
</div>
<div class="row" style="margin-top: 2%;">
<div class="col col-xl-10">
<label for="chaosReportCheckSiteURL">URL</label>
<input type='text' class='input-lg' id='chaosReportCheckSiteURL' value='' style='margin-top: 1%; width: 80%'>
<label for="chaosReportCheckSiteURL">URL</label>
<input type="text" class="form-control input-lg" id="chaosReportCheckSiteURL" value="" style="margin-top: 1%; width: 80%;">
</div>
</div>
<div class="row">
</div>
<div class="row" style="margin-top: 2%;">
<div class="col col-xl-10">
<label for="chaosReportCheckSiteURLMethod" style='margin-top: 1%;'>method</label>
<select id="chaosReportCheckSiteURLMethod" class="input-sm" aria-label="method" onChange="addPostUploadFile(this.options[this.selectedIndex].value)">
<option value="GET">GET</option>
<option value="POST">POST</option>
</select>
<label for="chaosReportCheckSiteURLMethod" style="margin-top: 1%;">Method</label>
<select id="chaosReportCheckSiteURLMethod" class="form-select input-sm" aria-label="Method" onchange="addPostUploadFile(this.value)">
<option value="GET">GET</option>
<option value="POST">POST</option>
</select>
</div>
</div>
<div class="row">
</div>
<div class="row" style="margin-top: 2%;">
<div class="col col-xl-10">
<div id="chaosReportUploadFileDiv"></div>
<div id="chaosReportUploadFileDiv"></div>
</div>
</div>
<div class="row">
</div>
<div class="row" style="margin-top: 2%;">
<div class="col col-xl-10">
<label for="chaosReportCheckSiteURLHeaders">HEADERS</label>
<input type='text' class='input-sm' id='chaosReportCheckSiteURLHeaders' value='{"Content-Type": "application/json; charset=utf-8"}' style='margin-top: 1%; margin-bottom: 1%; width: 80%;'><br>
<label for="chaosReportCheckSiteURLHeaders">Headers</label>
<input type="text" class="form-control input-sm" id="chaosReportCheckSiteURLHeaders" value='{"Content-Type": "application/json; charset=utf-8"}' style="margin-top: 1%; margin-bottom: 1%; width: 80%;">
</div>
</div>
</div>
`);
if (is_demo_mode()) {
@@ -330,6 +334,11 @@ function updateStatusCodePieChart(projectName) {
name: '404',
itemStyle: { color: 'yellow' },
},
{
value: chart_status_code_dict["405"],
name: '405',
itemStyle: { color: 'yellow' },
},
{
value: chart_status_code_dict["Connection Error"],
name: 'Connection Error',
@@ -444,7 +453,7 @@ option = {
type: 'line',
smooth: true,
itemStyle: {
color: 'green'
color: 'white'
}
}
]
+41
View File
@@ -0,0 +1,41 @@
/*
Name: dracula
Author: Michael Kaminsky (http://github.com/mkaminsky11)
Original dracula color scheme by Zeno Rocha (https://github.com/zenorocha/dracula-theme)
*/
.cm-s-dracula.CodeMirror, .cm-s-dracula .CodeMirror-gutters {
background-color: #282a36 !important;
color: #f8f8f2 !important;
border: none;
}
.cm-s-dracula .CodeMirror-gutters { color: #282a36; }
.cm-s-dracula .CodeMirror-cursor { border-left: solid thin #f8f8f0; }
.cm-s-dracula .CodeMirror-linenumber { color: #6D8A88; }
.cm-s-dracula .CodeMirror-selected { background: rgba(255, 255, 255, 0.10); }
.cm-s-dracula .CodeMirror-line::selection, .cm-s-dracula .CodeMirror-line > span::selection, .cm-s-dracula .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
.cm-s-dracula .CodeMirror-line::-moz-selection, .cm-s-dracula .CodeMirror-line > span::-moz-selection, .cm-s-dracula .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
.cm-s-dracula span.cm-comment { color: #6272a4; }
.cm-s-dracula span.cm-string, .cm-s-dracula span.cm-string-2 { color: #f1fa8c; }
.cm-s-dracula span.cm-number { color: #bd93f9; }
.cm-s-dracula span.cm-variable { color: #50fa7b; }
.cm-s-dracula span.cm-variable-2 { color: white; }
.cm-s-dracula span.cm-def { color: #50fa7b; }
.cm-s-dracula span.cm-operator { color: #ff79c6; }
.cm-s-dracula span.cm-keyword { color: #ff79c6; }
.cm-s-dracula span.cm-atom { color: #bd93f9; }
.cm-s-dracula span.cm-meta { color: #f8f8f2; }
.cm-s-dracula span.cm-tag { color: #ff79c6; }
.cm-s-dracula span.cm-attribute { color: #50fa7b; }
.cm-s-dracula span.cm-qualifier { color: #50fa7b; }
.cm-s-dracula span.cm-property { color: #66d9ef; }
.cm-s-dracula span.cm-builtin { color: #50fa7b; }
.cm-s-dracula span.cm-variable-3, .cm-s-dracula span.cm-type { color: #ffb86c; }
.cm-s-dracula .CodeMirror-activeline-background { background: rgba(255,255,255,0.1); }
.cm-s-dracula .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
+45 -49
View File
@@ -7,8 +7,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./bootstrap-5.0.0-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="./all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="./codemirror.css">
<link rel="stylesheet" href="./dracula.css">
<script src="./codemirror.js"></script>
<style>
@@ -105,22 +107,21 @@
<div class="sidebar" id="sidebar">
<a id="gameModeButton" onclick="startGameMode()">Game Mode</a>
<a id="programmingModeButton" onclick="startProgrammingMode()">Programming Mode</a>
<a href="#" onclick="showSetCurrentChaosContainer()">Chaos Container Editor</a>
<a href="#" onclick="showSpecialKeys()">Show Special Keys</a>
<a href="#" onclick="showCurrentChaosContainer()">Show Current Chaos Container for nodes</a>
<a href="#" onclick="showSetCurrentChaosContainer()">Set Custom Chaos Container for nodes</a>
</div>
<!-- Main content -->
<div class="main-content">
<!-- Navbar -->
<span style="color:white" class="toggler-icon" onclick="toggleSidebar()">
<i class="fas fa-bars"></i>
</span>
<span style="color:white" class="toggler-icon" onclick="toggleSidebar()">
<i class="fas fa-bars"></i>
</span>
<div id="main-game-div" style="display: block;">
<!-- Modal -->
<div class="modal fade" id="currentChaosContainerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal fade id="currentChaosContainerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
@@ -147,22 +148,18 @@
<!-- Modal -->
<div class="modal fade" id="setChaosContainerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">Set Chaos Container Definition (Click on the code editor if you don't see anything.) - This job defines the chaos experiment that are executed when you target Kubernetes nodes in game mode</h6>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="exampleFormControlTextarea1" style="margin-bottom: 3%;">Chaos Container Definition</label>
<textarea class="form-control" id="currentChaosContainerJsonTextArea" rows="20"></textarea>
</div>
<div class="form-group">
<p id="alert_placeholder2" style="color: #161616; font-family: 'Courier New', Courier, monospace; margin-top: 3%;"></p>
</div>
<div class="modal-footer">
<button type="button" id="saveButton" class="btn btn-light" onclick="setChaosContainer()">Save</button>
<button type="button" id="closeButton3" class="btn btn-dark" data-dismiss="modal" onclick="closeSetChaosContainerModal()">Close</button>
</div>
</form>
<textarea id="currentChaosContainerJsonTextArea"></textarea>
<p id="alert_placeholder2" style="color: #161616; font-family: 'Courier New', Courier, monospace; margin-top: 3%;"></p>
<div class="modal-footer">
<button type="button" id="saveButton" class="btn btn-light" onclick="setChaosContainer()">Save</button>
<button type="button" id="closeButton3" class="btn btn-dark" data-dismiss="modal" onclick="closeSetChaosContainerModal()">Close</button>
</div>
</div>
</div>
</div>
@@ -232,7 +229,7 @@
</div> -->
<div class="row">
<div class="col col-xl-10">
<label for="chaosReportHttpEndpointButton" style="margin-top: 1%;">add an http endpoint to be analyzed during the chaos engineering session</label>
<label for="chaosReportHttpEndpointButton" style="margin-top: 1%;">Add an HTTP endpoint to be analyzed during the chaos engineering session</label>
</div>
</div>
<!-- <div class="row">
@@ -299,31 +296,30 @@
</h2>
<div id="guide-collapseThree" class="accordion-collapse collapse" aria-labelledby="headingThree" data-bs-parent="#accordionExample">
<div class="accordion-body">
Dear user, thank you for installing kubeinvaders!<br>
<br>
This is a chaos engineering tool written by luckysideburn and friends from https://platformengineering.it for the community of kubernetes users, software developers, and admins.<br>
It was born in 2019 as a gamified chaos engineering tool, and we are evolving it into a more serious instrument :d <br>
here's how it works<br>
For reports, bugs, ideas you can open issue on the project github repo https://github.com/lucky-sideburn/kubeinvaders or write to luckysideburn [at] gmail [dot] com <br>
<br>
<font color="blue">[[game mode button]]</font><br>
Enabling the game console allows you to kill pods and launch workloads to stress cluster nodes (check "show keys and options" to understand how to do it). You can also jump between namespace and many other things.<br>
<br>
<font color="blue">[[add http check & chaos report checkbox]]</font><br>
Use it to activate the monitoring of an ingress and generate real-time reporting. it's very useful to know what happens to your applications during chaos sessions. for now, we monitor the elapsed time of http calls and status codes. also, you have some very useful default metrics:<br>
<br>
<font color="gren">Selected namespace</font> => indicates the current namespace focused on by the tool. you can jump between selected namespaces during installation.<br>
<br>
<font color="gren">Deleted pods total</font> => total number of killed pods.<br>
<br>
<font color="gren">Current chaos pods</font> => when the node stress test mode is activated, this metric indicates the number of jobs stressing your cluster.<br>
<br>
<font color="gren">Current replicas state delay</font> => a very important metric, indicates how long your cluster takes to return to the desired state that was before the chaos engineering session.<br>
<br>
<font color="blue">[[enable prog. mode button (under development)]]</font><br>
Through yaml programming, you can define your own chaos engineering experiments and execute them. we have preloaded some presets for various open-source tools to stress test (this feature is still in development, so contributions are welcome).<br>
Thank you for installing Kubeinvaders!
This is a chaos engineering tool developed by Luckysideburn and contributors from <a href="https://platformengineering.it">platformengineering.it</a> for the Kubernetes community, including software developers and admins.<br><br>
Kubeinvaders started in 2019 as a gamified chaos engineering tool, and we are continually evolving it into a more sophisticated instrument :D<br><br>
Heres how it works:<br><br>
For reports, bugs, or ideas, feel free to open an issue on the project's <a href="https://github.com/lucky-sideburn/kubeinvaders">GitHub repository</a> or contact Luckysideburn at <a href="mailto:luckysideburn@gmail.com">luckysideburn@gmail.com</a>.<br><br>
<font color="blue">Game Mode</font><br>
Enabling the game console allows you to kill pods and launch workloads to stress cluster nodes (check “Show keys and options” to learn how). You can also switch between namespaces and perform many other tasks.<br><br>
<font color="blue">Check HTTP</font><br>
Use this to monitor an ingress and generate real-time reports. Its very useful for understanding what happens to your applications during chaos sessions. Currently, we monitor HTTP call durations and status codes. Additionally, youll find some very useful default metrics:<br><br>
<font color="green">Selected Namespace</font> => Indicates the current namespace focused on by the tool. You can switch between selected namespaces during installation.<br><br>
<font color="green">Deleted Pods Total</font> => The total number of killed pods.<br><br>
<font color="green">Current Chaos Pods</font> => When the node stress test mode is activated, this metric shows the number of jobs stressing your cluster.<br><br>
<font color="green">Current Replicas State Delay</font> => An important metric that shows how long your cluster takes to return to the desired state after a chaos engineering session.<br><br>
<font color="blue">Programming Mode (Under Development)</font><br>
Using YAML programming, you can define your own chaos engineering experiments and execute them. We have preloaded some presets for various open-source tools to stress test. This feature is still in development, so contributions are welcome.
</div>
</div>
</div>
@@ -361,7 +357,7 @@
<div class="col text-center" style="margin-bottom: 0%;">
<input class="form-check-input" type="checkbox" value="" id="flagChaosReport" onclick="wrapShowPrepareChaosReportModal(this)">
<label class="form-check-label text-kinv" for="flexCheckDefault">
Add HTTP check & Chaos Report
Check HTTP
</label>
</div>
</div>
@@ -451,7 +447,7 @@
<!-- <button type="button" id="loadVault" class="btn btn-light btn-md" onclick="loadPreset('vault', 'python')">Vault</button> -->
</div>
</div>
<div class="row">
<div class="row" hidden="true">
<div class="btn-group" id="loadChaosProgramButtonGroup" role="group" aria-label="Basic example" style="overflow-x: scroll; width: 100%; padding-bottom: 2.0%; padding-top: 0.5%; scrollbar-color: dark;">
</div>
</div>
@@ -539,7 +535,7 @@ k8s_jobs:
<td><p id="chaosReportSessionTimeDiv" class="text-kinv"></p></td>
</tr>
<tr>
<td class="td-grey">Checked URL</td>
<td class="td-grey">Check HTTP URL</td>
<td><p id="chaosReportCheckSiteURLDiv" class="text-kinv"></p></td>
</tr>
</tr>
+20 -21
View File
@@ -10,8 +10,8 @@ var spaceshipWidth = 60;
var spaceshipX = (canvas.width-spaceshipWidth)/2;
var spaceshipY = (canvas.height-spaceshipHeight)/2;
var clu_endpoint = "endpoint_placeholder";
var clu_insicure = "insecure_endpoint_placeholder";
var demo_mode = "platform_engineering_demo_mode_placeholder"
var clu_insecure = insecure_endpoint_placeholder;
var demo_mode = demo_mode_placeholder;
var k8s_url = "";
var chaos_report_post_data = "";
@@ -19,12 +19,14 @@ var chaos_report_post_data = "";
var maxAliensPerRow = 20;
var startYforHelp = 700;
if (clu_insicure == "true") {
if (clu_insecure) {
k8s_url = "http://" + clu_endpoint;
}
else {
k8s_url = "https://" + clu_endpoint;
}
console.log("[K-INV STARTUP] k8s_url is " + k8s_url);
console.log("[K-INV STARTUP] platformengineering.it demo_mode is " + String(demo_mode));
var namespaces = [];
var namespaces_index = 0;
@@ -53,6 +55,12 @@ var change_codename = false;
var latest_sent_chaos_program = "";
var editor = null;
var editor_chaos_container_definition = CodeMirror.fromTextArea(currentChaosContainerJsonTextArea, {
lineNumbers: true,
theme: "dracula",
mode: "javascript"
});
// nodes list from kubernetes
var nodes = [];
@@ -127,10 +135,15 @@ var chart_status_code_dict = {
"401": 1,
"403": 1,
"404": 1,
"405": 1,
"Connection Error": 1,
"Other": 1
};
function currentChaosContainerJsonTextAreaVal() {
return editor_chaos_container_definition.getValue();
}
function getCodeName() {
const prefixes = ['astro', 'cosmo', 'space', 'star', 'nova', 'nebula', 'galaxy', 'super', 'hyper', 'quantum'];
const suffixes = ['nova', 'tron', 'wave', 'core', 'pulse', 'jump', 'drive', 'ship', 'gate', 'hole'];
@@ -142,21 +155,6 @@ function getCodeName() {
codename = prefix + suffix;
return codename;
}
// function getCodeName() {
// var oReq = new XMLHttpRequest();
// oReq.onreadystatechange = function () {
// if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
// codename = this.responseText.trim();
// if (codename == "") {
// $('#alert_placeholder').replaceWith(alert_div + 'Error getting codename from backend. </div>');
// codename = "error_fix_getcodename_from_backend";
// }
// }
// };;
// oReq.open("GET", k8s_url + "/codename");
// oReq.send();
// }
function setCodeNameToTextInput(elementId) {
var oReq = new XMLHttpRequest();
@@ -347,7 +345,8 @@ function getCurrentChaosContainer() {
oReq.onload = function () {
job_parsed = JSON.stringify(JSON.parse(this.responseText), null, 4);
$('#currentChaosContainerYaml').text(job_parsed);
$('#currentChaosContainerJsonTextArea').val(job_parsed);
editor_chaos_container_definition.setValue(job_parsed);
editor_chaos_container_definition.refresh();
};;
oReq.open("GET", k8s_url + "/kube/chaos/containers?action=container_definition");
oReq.send();
@@ -394,7 +393,7 @@ function setLogRegex() {
}
function setChaosContainer() {
if (!IsJsonString($('#currentChaosContainerJsonTextArea').val())) {
if (!IsJsonString(currentChaosContainerJsonTextAreaVal())) {
$('#alert_placeholder2').text('JSON syntax not valid.');
}
else {
@@ -407,7 +406,7 @@ function setChaosContainer() {
}
};;
oReq.setRequestHeader("Content-Type", "application/json");
oReq.send($('#currentChaosContainerJsonTextArea').val());
oReq.send(currentChaosContainerJsonTextAreaVal());
}
}
+1 -1
View File
@@ -54,7 +54,7 @@ function wrapShowPrepareChaosReportModal(checkbox) {
function showPrepareChaosReportModal(checkbox) {
if(checkbox.checked){
$('#prepareChaosReportModal').modal('show');
$("#chaosReportHeader").text("Configuration of Chaos Report for namespace: " + namespace);
$("#chaosReportHeader").text("Select Ingress - Namespace:" + namespace);
setCodeNameToTextInput("chaosReportAuthor");
setCodeNameToTextInput("chaosReportProject");
setModalState(true);
+8 -6
View File
@@ -67,10 +67,12 @@ function startProgrammingMode() {
game_buttons.style.display = "none";
game_screen.style.display = "none";
editor = CodeMirror.fromTextArea(chaosProgramTextArea, {
lineNumbers: true,
theme: "dracula"
});
editor.setSize("100%", "100%");
if (editor == null) {
editor = CodeMirror.fromTextArea(chaosProgramTextArea, {
lineNumbers: true,
theme: "dracula",
mode: "javascript"
});
editor.setSize("100%", "100%");
}
}
+1 -18
View File
@@ -4,11 +4,8 @@ function replaceDivWithContent(divId, content) {
function getChaosProgTextAreaValue() {
return editor.getValue();
// const chaosProgramTextArea = document.getElementById('chaosProgramTextArea');
// const textValue = chaosProgramTextArea.value;
// console.log("[GET-CHAOS-PROGRAM-TEXT-AREA-VALUE] " + textValue);
// return textValue;
}
/* Programming Mode Functions */
function IsJsonString(str) {
try {
@@ -65,21 +62,7 @@ function loadPreset(tool, lang) {
function runChaosProgram() {
// if (chaosProgramWithCodename != $('#chaosProgramTextArea').text()) {
// random_code = (Math.random() + 1).toString(36).substring(7);
// codename = getCodeName();
// console.log("[RUN-CHAOS-PROGRAM] Running chaos program with codename: " + codename);
// }
//chaosProgramWithCodename = chaosProgram.replace(codename_regex, "chaos-codename: " + codename);
// $('#chaosProgramTextArea').val(chaosProgramWithCodename);
// $('#chaosProgramTextArea').text(chaosProgramWithCodename);
//codename_configured = true;
// Regex per estrarre il valore dopo "chaos-codename:"
//random_code = (Math.random() + 1).toString(36).substring(7);
chaosProgram = getChaosProgTextAreaValue();
const regex = /^chaos-codename:\s+(.*)$/m;
const match = chaosProgram.match(regex);
+2 -5
View File
@@ -41,13 +41,10 @@ function convertStringToArrayWithSeparator(str, separator) {
}
function demo_mode_alert() {
alert("This is a demo mode, some features are disabled");
alert("This is a demo mode installed into the k8s cluster of platformengineering.it, some features are disabled.");
}
function is_demo_mode() {
if (demo_mode == "true") {
return true;
}
return false;
return demo_mode;
}
+44
View File
@@ -0,0 +1,44 @@
function build() {
journalctl --vacuum-size=1M
rm -rf /var/lib/containers/storage/*
rm -rf /run/containers/storage/*
podman system reset -f
/bin/cp Dockerfile_full Dockerfile
podman build /usr/local/src/kubeinvaders -t 10.10.10.3:5000/local/kubeinvaders:develop
for i in $(podman ps -a | grep -v CONTAINER | awk '{ print $1}'); do podman rm $i -f ; done
podman tag 10.10.10.3:5000/local/kubeinvaders:develop 10.10.10.3:5000/local/kubeinvaders_base:develop
podman push 10.10.10.3:5000/local/kubeinvaders_base:develop
}
function build_redux() {
journalctl --vacuum-size=1M
/bin/cp Dockerfile_redux Dockerfile
for i in $(podman ps -a | grep -v CONTAINER | awk '{ print $1}'); do podman rm $i -f ; done
podman build /usr/local/src/kubeinvaders -t 10.10.10.3:5000/local/kubeinvaders:develop
}
function run(){
podman run -p 8080:8080 \
--env K8S_TOKEN=eyJhbGciOiJSUzI1NiIsImtpZCI6ImlrbVNQMWg5QUVCLVhjQl9uT0V4aVpQY0RNdTR2aVVHTzdJeXBZSXNnZkkifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlaW52YWRlcnMiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlY3JldC5uYW1lIjoia3ViZWludmFkZXJzLXRva2VuLWo1Y3hzIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Imt1YmVpbnZhZGVycyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImYxOTViODI4LWRhZTYtNGM1ZC05YzliLTVlOGQwYTI0NTEzZiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlaW52YWRlcnM6a3ViZWludmFkZXJzIn0.NqVdsSw3cs3jMevheokUNPfb9WmlQe7g6CrAytcApq9Z9FFFomXib5kb1fgdKYVJn4vb0a6H3kHB8hKJo0UcPu24wVCAYwxsfCTuK13tsCJxrycs2TxyoTWsXALMbBMgDJthCal14RwikWFpW4EyHryqkEAAn-U5goBdaabCSHhWCiR4ulbmuKy8xep8yppRw66505hq4Rdc6gMcj4_bgTDLKSh_g1lySHdHiiTo1v5X71_BD5QEKIEj2Ak4mslpAy-aQUOso4HicIIvd7I1NLDfis1Scj9IjhL8jdRXrOSk9KUbFBJCOMCye2pSYK3eqRDsjVe7BKPZB53WtMW7ew \
--env ENDPOINT=localhost:8080 \
--env KUBERNETES_SERVICE_HOST=10.10.10.4 \
--env KUBERNETES_SERVICE_PORT_HTTPS=6443 \
--env INSECURE_ENDPOINT=true \
--env NAMESPACE=namespace1,namespace2 \
10.10.10.3:5000/local/kubeinvaders:develop
}
if [ "$1" == "build" ]; then
build
elif [ "$1" == "run" ]; then
run
elif [ "$1" == "all" ]; then
build
run
elif [ "$1" == "allredux" ]; then
build_redux
run
else
echo "Usage: $0 [build|run]"
fi
+10 -12
View File
@@ -10,22 +10,20 @@ server {
}
set_by_lua_block $insecure_endpoint {
return os.getenv("INSECURE_ENDPOINT")
}
set_by_lua_block $platform_engineering_demo_mode {
if (os.getenv("PLATFORM_ENGINEERING_DEMO_MODE") == nil) then
local env_var = os.getenv("INSECURE_ENDPOINT")
if env_var then
return env_var
else
return "false"
else
return os.getenv("PLATFORM_ENGINEERING_DEMO_MODE")
end
}
set_by_lua_block $platform_engineering_demo_mode {
if (os.getenv("PLATFORM_ENGINEERING_STATS") == nil) then
set_by_lua_block $demo_mode {
local env_var = os.getenv("PLATFORM_ENGINEERING_DEMO_MODE")
if env_var then
return env_var
else
return "false"
else
return os.getenv("PLATFORM_ENGINEERING_STATS")
end
}
@@ -40,9 +38,9 @@ server {
expires off;
etag off;
sub_filter_types "*";
sub_filter demo_mode_placeholder $demo_mode;
sub_filter endpoint_placeholder $endpoint;
sub_filter insecure_endpoint_placeholder $insecure_endpoint;
sub_filter platform_engineering_demo_mode_placeholder $platform_engineering_demo_mode;
}
location /kube/ingress/get {
+1
View File
@@ -128,6 +128,7 @@ while True:
r.set(check_url_status_code_key, "Connection Error")
r.set(check_url_elapsed_time_key, 0)
else:
#logging.info(f"[k-inv][metrics_loop][chaos_report] Status code {response.status_code} while checking {chaos_report_program['chaosReportCheckSiteURL']}")
r.set(check_url_status_code_key, response.status_code)
r.set(check_url_elapsed_time_key, float(response.elapsed.total_seconds()))
try:
+10 -10
View File
@@ -76,8 +76,8 @@ else
end
--ngx.log(ngx.INFO, "token: " .. token)
ngx.log(ngx.INFO, "url: " .. url)
ngx.log(ngx.INFO, "namespace: " .. namespace)
-- ngx.log(ngx.INFO, "url: " .. url)
-- ngx.log(ngx.INFO, "namespace: " .. namespace)
local headers = {
["Accept"] = "application/json",
@@ -94,10 +94,10 @@ local ok, statusCode, headers, statusText = https.request{
sink = ltn12.sink.table(resp)
}
ngx.log(ngx.INFO, "REQUEST LOGS...")
ngx.log(ngx.INFO, ok)
ngx.log(ngx.INFO, statusCode)
ngx.log(ngx.INFO, statusText)
-- ngx.log(ngx.INFO, "REQUEST LOGS...")
-- ngx.log(ngx.INFO, ok)
-- ngx.log(ngx.INFO, statusCode)
-- ngx.log(ngx.INFO, statusText)
if action == "list" then
local i = 1
@@ -108,7 +108,7 @@ if action == "list" then
if decoded["kind"] == "PodList" then
for k2,v2 in ipairs(decoded["items"]) do
if v2["status"]["phase"] == "Running" and v2["metadata"]["labels"]["chaos-controller"] ~= "kubeinvaders" then
ngx.log(ngx.INFO, "found pod " .. v2["metadata"]["name"])
-- ngx.log(ngx.INFO, "found pod " .. v2["metadata"]["name"])
local status = "pending"
for _, c in ipairs(v2["status"]["conditions"]) do
if c["type"] == "ContainersReady" and c["status"] == "True" then
@@ -120,12 +120,12 @@ if action == "list" then
i = i + 1
pods_not_found = false;
elseif v2["status"]["phase"] == "ContainerCreating" and v2["metadata"]["labels"]["chaos-controller"] ~= "kubeinvaders" then
ngx.log(ngx.INFO, "found pod " .. v2["metadata"]["name"])
-- ngx.log(ngx.INFO, "found pod " .. v2["metadata"]["name"])
pods["items"][i] = { name = v2["metadata"]["name"], status = "pending" }
i = i + 1
pods_not_found = false;
elseif v2["status"]["phase"] == "Terminating" and v2["metadata"]["labels"]["chaos-controller"] ~= "kubeinvaders" then
ngx.log(ngx.INFO, "found pod " .. v2["metadata"]["name"])
-- ngx.log(ngx.INFO, "found pod " .. v2["metadata"]["name"])
pods["items"][i] = { name = v2["metadata"]["name"], status = "killed" }
i = i + 1
pods_not_found = false;
@@ -147,7 +147,7 @@ if action == "list" then
local latest_fewer_replicas_seconds, err = red:get("latest_fewer_replicas_seconds")
local fewer_replicas_time, err = red:get("fewer_replicas_time")
ngx.log(ngx.INFO, "[METRICS] pods_not_running_on=" .. pods_not_running_on)
-- ngx.log(ngx.INFO, "[METRICS] pods_not_running_on=" .. pods_not_running_on)
if fewer_replicas_seconds == ngx.null then
red:set("fewer_replicas_seconds", 0)