Compare commits

..

5 Commits

Author SHA1 Message Date
Simon Belmas
4e619d4364 Update images + remove tsps 2025-03-03 15:26:58 +01:00
Simon Belmas
0b156f5b48 allow to run without checking out a repository 2024-07-29 17:55:15 +02:00
Simon Belmas
9efb2a0a15 Use tsp instad of podaffinity + version optional quotas 2024-07-29 16:19:08 +02:00
Simon Belmas
ea6635f716 Resize reauests and limits 2024-06-28 18:02:10 +02:00
Simon Belmas
6b758e202d enhance stats generation script to ease post processing 2024-06-28 14:22:36 +02:00
6 changed files with 64 additions and 49 deletions

View File

@@ -11,7 +11,7 @@ Ingress fqdn has to be configured by either:
*replicas* and *content-git-repo* in *config* folder can be customized by modifying files or applying kustomize patch
Connntent git will be displayed in an iframe with node name on top.
Content git will be displayed in an iframe with node name on top. If it's empty, it will display a blank page with node name.
Node name is displayed on the top of the page and also in kube-node.json and on kube-node.txt
@@ -24,4 +24,4 @@ analyse.sh {ingress fqdn} [keep_results]
Option *keep_results* does not ovewrite file on startup.
Information is displayed in csv format: date (epoch) | request total time | response http code | page successfully reached (0/1) | response conntent
Information is displayed in csv format: "Date (Epoch)";"Request duration";"HTTP Response code";"App availability";"Event";"Response content"

View File

@@ -2,6 +2,7 @@
# This script asserts that init.sh workload script is left as is.
date_format='+%s'
script_dir=$(dirname $(readlink -f ${0}))
results_file=${script_dir}/analyse_results.csv
@@ -14,13 +15,6 @@ else
analyse_url=${1}
fi
if [[ "${2}" == "keep_results" ]] ; then
keep_results=true
else
keep_results=false
echo '' > ${results_file}
fi
cleanup() {
if [ -e "${tmp_headers_file}" ] ; then
rm -v ${tmp_headers_file}
@@ -28,16 +22,37 @@ cleanup() {
echo Ingress statistics can be viewed in ${results_file}
}
echo Launching test, press CTRL+C to exit
insert_event () {
insert_date=$(date ${date_format})
echo "${insert_date};;;;2;\"Event from SIGUSR1\"" | tee -a ${results_file}
}
# Defining cleannup onn sigint
# Signnals handling
trap cleanup 2
trap insert_event 30
# Explanations
echo Process id to send signal is $$
echo To insert event in log, send SIGUSR1 to $$
echo following command cann be used: kill -s SIGUSR1 $$
echo
echo Launching test, press CTRL+C to exit
echo
# Result file handling
if [[ "${2}" == "keep_results" ]] ; then
keep_results=true
else
keep_results=false
echo '"Date (Epoch)";"Request duration";"HTTP Response code";"App availability";"Event";"Response content"' | tee ${results_file}
fi
# Statistics generation
while true ; do
request_date=$(date '+%s')
request_date=$(date ${date_format})
request_data="$(curl -m 2 -s -w "%output{$tmp_headers_file}%{time_total};%{http_code}" -k "${analyse_url}" | tr -d "\r" |tr -d "\n" | tr -d ";")"
request_headers=$(cat ${tmp_headers_file})
response_success=$( [[ "$(echo ${request_headers} | cut -f2 -d';')" == "200" ]] && echo 1 || echo 0)
echo "${request_date};${request_headers};${response_success};${request_data}" | tee -a ${results_file}
echo "${request_date};${request_headers};${response_success};;\"${request_data}\"" | tee -a ${results_file}
sleep 1
done

View File

@@ -1,19 +1,23 @@
#!/bin/sh
git_retries=20
try=0
export GIT_SSH_COMMAND='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
until timeout 10 git clone --recurse-submodules ${CONTENT_GIT_REPO} /app ; do
echo "Retry git pull after error ($try / $git_retries)"
try=$((try+1))
if [ $try -eq $git_retries ]; then
exit 1
fi
sleep 1
done
if [ -n "${CONTENT_GIT_REPO}" ] ; then
export GIT_SSH_COMMAND='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
until timeout 10 git clone --recurse-submodules ${CONTENT_GIT_REPO} /app ; do
echo "Retry git pull after error ($try / $git_retries)"
try=$((try+1))
if [ $try -eq $git_retries ]; then
exit 1
fi
sleep 1
done
fi
cd /app
if [ -e index.html ] ; then
mv index.html index-embedded.html
fi
cat <<EOF >index.html
<html>
<head>
@@ -24,15 +28,26 @@ cat <<EOF >index.html
From node ${KUBE_NODE_NAME}<br />
as <a href="./kube-node.json">json</a> - <a href="./kube-node.txt">text</a>
</p>
EOF
if [ -n "${CONTENT_GIT_REPO}" ] ; then
cat <<EOF >>index.html
<iframe
id="embeddedcontent"
title="embeddedcontent"
width="100%"
height="90%"
src="./index-embedded.html" />
EOF
fi
cat <<EOF >>index.html
</body>
</html>
EOF
ls -l
cat index.html
echo '{"node": "'${KUBE_NODE_NAME}'"}' > kube-node.json
echo -n ${KUBE_NODE_NAME} > kube-node.txt

View File

@@ -7,25 +7,13 @@ spec:
replicas: 1
template:
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- html-kube-tester
topologyKey: kubernetes.io/hostname
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
initContainers:
- name: content-generator
image: quay.io/simbelmas/alpine-tools:stable
image: quay.io/simbelmas/toolbox:stable
command: ["html-kube-tester-init.sh"]
securityContext:
allowPrivilegeEscalation: false
@@ -61,21 +49,9 @@ spec:
protocol: TCP
resources:
requests:
cpu: 2m
memory: 20Mi
cpu: 10m
limits:
cpu: 100m
memory: 50Mi
livenessProbe: &html-kube-tester-probe
httpGet:
path: /
port: 8080
timeoutSeconds: 5
periodSeconds: 15
failureThreshold: 10
readinessProbe:
<<: *html-kube-tester-probe
periodSeconds: 2
cpu: 40m
volumes:
- name: init
configMap:

View File

@@ -18,6 +18,7 @@ resources:
- deployment.yaml
- service.yaml
- ingress.yaml
#- resourceQuotas.yaml
replacements:
- source:

8
resourceQuotas.yaml Normal file
View File

@@ -0,0 +1,8 @@
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-resources
spec:
hard:
requests.cpu: "100m"
limits.cpu: "50m"