This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the 'benchmark/' Directory is a Script called `benchmark.sh`, this Script uses _docker_ and bombardier[^1] to "simulate" a K8s-Cluster on which a hug amount of new Pods/ Containers are getting created. The `*_body` are containing the Request Body of a "Real-World" K8s-Cluster. [^1]: https://github.com/codesenberg/bombardier Signed-off-by: Emanuel Bennici <benniciemanuel78@gmail.com>
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash - | ||
#=============================================================================== | ||
# | ||
# FILE: benchmark.sh | ||
# | ||
# USAGE: ./benchmark.sh | ||
# | ||
# DESCRIPTION: Runs a benchmark against the kubenab-Server | ||
# | ||
# OPTIONS: --- | ||
# REQUIREMENTS: go, docker, openssl | ||
# BUGS: --- | ||
# NOTES: --- | ||
# AUTHOR: Francesco Emanuel Bennici <benniciemanuel78@gmail.com> | ||
# ORGANIZATION: | ||
# CREATED: 28.09.2019 00:32:08 | ||
# REVISION: --- | ||
#=============================================================================== | ||
|
||
set -o nounset # Treat unset variables as an error | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
tmp=$(mktemp -d) | ||
curr=$(pwd) | ||
|
||
## ===> Compile `kubenab` <=== | ||
|
||
echo "[i] Generating Self-Signed Certificates" | ||
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ | ||
-keyout ${tmp}/tls.key -out ${tmp}/tls.crt -extensions san -config \ | ||
<(echo "[req]"; | ||
echo distinguished_name=req; | ||
echo "[san]"; | ||
echo subjectAltName=DNS:localhost,IP:127.0.0.1 | ||
) \ | ||
-subj "/CN=localhost" | ||
|
||
|
||
echo "[i] Compiling kubenab" | ||
cd ${DIR}/../ | ||
docker build -t temp/build:kubenab . | ||
id=$(docker run -p 8443:443 \ | ||
-v ${tmp}:/etc/admission-controller/tls \ | ||
-d --env "DOCKER_REGISTRY_URL=jfrog" --env "REPLACE_REGISTRY_URL=false" \ | ||
temp/build:kubenab) | ||
cd ${curr} | ||
|
||
## ==> Benchmark <==# | ||
|
||
echo "[i] Installing bombardier" | ||
go get -u github.com/codesenberg/bombardier | ||
|
||
echo "###########################" | ||
echo "### Starting bombardier ###" | ||
echo -e "###########################\n" | ||
|
||
echo -e "==> Mutate Webhook\n\n" | ||
bombardier -c 125 -n 10000000 --insecure --latencies \ | ||
--fasthttp --body $(cat ${DIR}/mutate_body) \ | ||
--print 'i,p,r' --method POST https://localhost:8443/mutate | ||
|
||
echo -e "\n\n==> Validate Webhook\n\n" | ||
bombardier -c 125 -n 10000000 --insecure --latencies \ | ||
--fasthttp --body $(cat ${DIR}/validate_body) \ | ||
--print 'i,p,r' --method POST https://localhost:8443/validate | ||
|
||
|
||
## Cleaning Up | ||
docker rm --force --volumes ${id} | ||
rm -rf ${tmp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"kind":"AdmissionReview","apiVersion":"admission.k8s.io/v1beta1","request":{"uid":"eae55fa6-d3f5-41f2-bafe-ecb34af1a2d0","kind":{"group":"","version":"v1","kind":"Pod"},"resource":{"group":"","version":"v1","resource":"pods"},"requestKind":{"group":"","version":"v1","kind":"Pod"},"requestResource":{"group":"","version":"v1","resource":"pods"},"namespace":"nginx","operation":"CREATE","userInfo":{"username":"system:serviceaccount:kube-system:replicaset-controller","uid":"76e1a4a5-f75a-40fe-a7a0-876619472d2f","groups":["system:serviceaccounts","system:serviceaccounts:kube-system","system:authenticated"]},"object":{"kind":"Pod","apiVersion":"v1","metadata":{"generateName":"nginx-69844dfc86-","creationTimestamp":null,"labels":{"pod-template-hash":"69844dfc86","test":"kubenab"},"ownerReferences":[{"apiVersion":"apps/v1","kind":"ReplicaSet","name":"nginx-69844dfc86","uid":"5ddf2df2-66e4-4287-869a-e349b0777966","controller":true,"blockOwnerDeletion":true}]},"spec":{"volumes":[{"name":"default-token-mc7dh","secret":{"secretName":"default-token-mc7dh"}}],"containers":[{"name":"nginx","image":"nginx","resources":{},"volumeMounts":[{"name":"default-token-mc7dh","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","serviceAccountName":"default","serviceAccount":"default","securityContext":{},"schedulerName":"default-scheduler","tolerations":[{"key":"node.kubernetes.io/not-ready","operator":"Exists","effect":"NoExecute","tolerationSeconds":300},{"key":"node.kubernetes.io/unreachable","operator":"Exists","effect":"NoExecute","tolerationSeconds":300}],"priority":0,"enableServiceLinks":true},"status":{}},"oldObject":null,"dryRun":false,"options":{"kind":"CreateOptions","apiVersion":"meta.k8s.io/v1"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"kind":"AdmissionReview","apiVersion":"admission.k8s.io/v1beta1","request":{"uid":"1f19a6d5-949a-4379-a0f9-a34e52faee18","kind":{"group":"","version":"v1","kind":"Pod"},"resource":{"group":"","version":"v1","resource":"pods"},"requestKind":{"group":"","version":"v1","kind":"Pod"},"requestResource":{"group":"","version":"v1","resource":"pods"},"name":"nginx-69844dfc86-n5vbr","namespace":"nginx","operation":"CREATE","userInfo":{"username":"system:serviceaccount:kube-system:replicaset-controller","uid":"76e1a4a5-f75a-40fe-a7a0-876619472d2f","groups":["system:serviceaccounts","system:serviceaccounts:kube-system","system:authenticated"]},"object":{"kind":"Pod","apiVersion":"v1","metadata":{"name":"nginx-69844dfc86-n5vbr","generateName":"nginx-69844dfc86-","namespace":"nginx","uid":"7be27643-cdb7-438b-a32f-47e5844ad7a8","creationTimestamp":"2019-09-27T22:30:55Z","labels":{"pod-template-hash":"69844dfc86","test":"kubenab"},"ownerReferences":[{"apiVersion":"apps/v1","kind":"ReplicaSet","name":"nginx-69844dfc86","uid":"5ddf2df2-66e4-4287-869a-e349b0777966","controller":true,"blockOwnerDeletion":true}]},"spec":{"volumes":[{"name":"default-token-mc7dh","secret":{"secretName":"default-token-mc7dh","defaultMode":420}}],"containers":[{"name":"nginx","image":"kubenab/nginx","resources":{},"volumeMounts":[{"name":"default-token-mc7dh","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","serviceAccountName":"default","serviceAccount":"default","securityContext":{},"imagePullSecrets":[{"name":"regsecret"}],"schedulerName":"default-scheduler","tolerations":[{"key":"node.kubernetes.io/not-ready","operator":"Exists","effect":"NoExecute","tolerationSeconds":300},{"key":"node.kubernetes.io/unreachable","operator":"Exists","effect":"NoExecute","tolerationSeconds":300}],"priority":0,"enableServiceLinks":true},"status":{"phase":"Pending","qosClass":"BestEffort"}},"oldObject":null,"dryRun":false,"options":{"kind":"CreateOptions","apiVersion":"meta.k8s.io/v1"}}} |