Skip to content

Commit 4ae4d77

Browse files
authored
Merge pull request #63 from commjoen/hardening
Fix identation and add documentation, metrics server for eks
2 parents 749189b + f33be94 commit 4ae4d77

File tree

7 files changed

+81
-12
lines changed

7 files changed

+81
-12
lines changed

aws/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ Are you done playing? Please run `terraform destroy` twice to clean up.
5757
### Test it
5858
When you have completed the installation steps, you can do `kubectl port-forward service/wrongsecrets-balancer 3000:3000` and then go to [http://localhost:3000](http://localhost:3000).
5959

60+
Want to know how well your cluster is holding up? Check with
61+
62+
```sh
63+
kubectl top nodes
64+
kubectl top pods
65+
```
66+
6067
### Clean it up
6168

6269
When you're done:

aws/build-an-deploy-aws.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ aws secretsmanager put-secret-value --secret-id wrongsecret-2 --secret-string "$
103103
echo "Generate Parameter store challenge secret"
104104
aws ssm put-parameter --name wrongsecretvalue --overwrite --type SecureString --value "$(openssl rand -base64 24)" --region $AWS_REGION --output json --no-cli-pager
105105

106+
echo "Installing metrics api-server"
107+
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
106108

107109
wait
108110

109111
DEFAULT_PASSWORD=thankyou
110112
#TODO: REWRITE ABOVE, REWRITE THE HARDCODED DEPLOYMENT VALS INTO VALUES AND OVERRIDE THEM HERE!
111113
echo "default password is ${DEFAULT_PASSWORD}"
112-
helm upgrade --install mj ../helm/wrongsecrets-ctf-party --set="imagePullPolicy=Always" --set="balancer.env.K8S_ENV=aws" --set"balancer.env.IRSA_ROLE=arn:aws:iam::${ACCOUNT_ID}:role/wrongsecrets-secret-manager" --set="balancer.env.REACT_APP_ACCESS_PASSWORD=${DEFAULT_PASSWORD}" --set="balancer.cookie.cookieParserSecret=thisisanewrandomvaluesowecanworkatit" --set="balancer.repository=jeroenwillemsen/wrongsecrets-balancer" --set="balancer.tag=0.89aws" --set="balancer.replicas=4" --set="wrongsecretsCleanup.repository=jeroenwillemsen/wrongsecrets-ctf-cleaner" --set="wrongsecretsCleanup.tag=0.2"
114+
helm upgrade --install mj ../helm/wrongsecrets-ctf-party --set="imagePullPolicy=Always" --set="balancer.env.K8S_ENV=aws" --set"balancer.env.IRSA_ROLE=arn:aws:iam::${ACCOUNT_ID}:role/wrongsecrets-secret-manager" --set="balancer.env.REACT_APP_ACCESS_PASSWORD=${DEFAULT_PASSWORD}" --set="balancer.cookie.cookieParserSecret=thisisanewrandomvaluesowecanworkatit" --set="balancer.repository=jeroenwillemsen/wrongsecrets-balancer" --set="balancer.tag=0.92aws" --set="balancer.replicas=4" --set="wrongsecretsCleanup.repository=jeroenwillemsen/wrongsecrets-ctf-cleaner" --set="wrongsecretsCleanup.tag=0.2"

helm/wrongsecrets-ctf-party/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ balancer:
3535
# -- Set this to a fixed random alpa-numeric string (recommended length 24 chars). If not set this get randomly generated with every helm upgrade, each rotation invalidates all active cookies / sessions requirering users to login again.
3636
cookieParserSecret: null
3737
repository: jeroenwillemsen/wrongsecrets-balancer
38-
tag: 0.89aws
38+
tag: 0.92aws
3939
# -- Number of replicas of the wrongsecrets-balancer deployment
4040
replicas: 1
4141
service:
@@ -198,7 +198,7 @@ virtualdesktop:
198198
maxInstances: 500
199199
# -- Juice Shop Image to use
200200
image: jeroenwillemsen/wrongsecrets-desktop
201-
tag: latest
201+
tag: test2
202202
repository: commjoenie/wrongSecrets
203203
resources:
204204
request:

readme.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Note that we:
99
- A working admin interface which can restart both or delete both (by deleting the full namespace)
1010
- Do not support any progress watchdog as you will have access to it, we therefore disabled it.
1111

12-
1312
## Special thanks
1413
Special thanks to Madhu Akula, Ben de Haan, and Mike Woudenberg for making this port a reality!
1514

@@ -20,8 +19,11 @@ This environment uses a webtop and an instance of wrongsecrets per user. This me
2019
- 3.5 GB RAM (min 2.5GB, limit = 3.5GB)
2120
- 8GB HD (min 3 GB, limit = 8GB)
2221

23-
A 6 contestant game can be played on a local minikube with updated cpu & memory settings.
24-
A 100 contestant game can be played on the AWS setup, which will require at least 200 CPUs, 3500 GB Ram, and 800 GB of storage available in the cluster.
22+
### Running this on minikube
23+
A 3-6 contestant game can be played on a local minikube with updated cpu & memory settings (e.g. 6 CPUs, 9 GB ram).
24+
25+
### Running this on AWS EKS with larger groups
26+
A 100 contestant game can be played on the AWS setup, which will require around 200 (100-250) CPUs, 300 (250-350) GB Ram, and 800 GB of storage available in the cluster. Note that we have configured everything based on autoscaling in AWS. This means that you can often start with a cluster about 20% of the size of the "limit" numbers and then see how things evolve. If you see heavy under-utilization as players are not very actively engaged: you can often scale down the amount of nodes required.
2527

2628
## Status
2729

@@ -49,6 +51,13 @@ eval $(minikube docker-env)
4951
./build-an-deploy.sh
5052
kubectl port-forward service/wrongsecrets-balancer 3000:3000
5153

54+
```
55+
Want to know whether your system is holding up? use
56+
57+
```shell
58+
minikube addons enable metrics-server
59+
kubectl top nodes
60+
kubectl top pods
5261
```
5362

5463
### Action with AWS EKSS:

wrongsecrets-balancer/src/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if (get('metrics.enabled')) {
5050
const teamRoutes = require('./teams/teams');
5151
const adminRoutes = require('./admin/admin');
5252
const proxyRoutes = require('./proxy/proxy');
53-
const scoreBoard = require('./score-board/score-board');
53+
//const scoreBoard = require('./score-board/score-board');
5454

5555
app.get('/balancer/dynamics', (req, res) => {
5656
const accessPassword = process.env['REACT_APP_ACCESS_PASSWORD'];
@@ -108,7 +108,7 @@ app.get('/balancer/admin', (req, res) => {
108108
res.sendFile(indexFile);
109109
});
110110
app.use('/balancer/admin', adminRoutes);
111-
app.use('/balancer/score-board', scoreBoard);
111+
//app.use('/balancer/score-board', scoreBoard);
112112

113113
app.use(proxyRoutes);
114114

wrongsecrets-balancer/src/kubernetes.js

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,10 @@ const createAWSDeploymentForTeam = async ({ team, passcodeHash }) => {
419419
name: 'K8S_ENV',
420420
value: 'aws',
421421
},
422+
{
423+
name: 'APP_VERSION',
424+
value: `${wrongSecretsContainterTag}-ctf`,
425+
},
422426
{
423427
name: 'CTF_SERVER_ADDRESS',
424428
value: `${heroku_wrongsecret_ctf_url}`,
@@ -1092,18 +1096,18 @@ const createDesktopDeploymentForTeam = async ({ team, passcodeHash }) => {
10921096
{
10931097
name: 'virtualdesktop',
10941098
//TODO REPLACE HARDCODED BELOW WITH PROPPER GETS: image: `${get('wrongsecrets.image')}:${get('wrongsecrets.tag')}`,
1095-
image: 'jeroenwillemsen/wrongsecrets-desktop:1.5.4RC8',
1099+
image: 'jeroenwillemsen/wrongsecrets-desktop:latest',
10961100
imagePullPolicy: get('virtualdesktop.imagePullPolicy'),
10971101
resources: {
10981102
requests: {
10991103
memory: '2G',
11001104
cpu: '800m',
1101-
'ephemeral-storage': '2Gi',
1105+
'ephemeral-storage': '4Gi',
11021106
},
11031107
limits: {
11041108
memory: '3G',
11051109
cpu: '2000m',
1106-
'ephemeral-storage': '4Gi',
1110+
'ephemeral-storage': '8Gi',
11071111
},
11081112
},
11091113
// resources: get('virtualdesktop.resources'),
@@ -1118,6 +1122,28 @@ const createDesktopDeploymentForTeam = async ({ team, passcodeHash }) => {
11181122
containerPort: 3000,
11191123
},
11201124
],
1125+
volumeMounts: [
1126+
// {
1127+
// mountPath: '/config',
1128+
// name: 'ephemeral',
1129+
// },
1130+
// {
1131+
// mountPath: '/defaults',
1132+
// name: 'ephemeral-2',
1133+
// },
1134+
// {
1135+
// mountPath: '/etc',
1136+
// name: 'ephemeral-3',
1137+
// },
1138+
// {
1139+
// mountPath: '/app',
1140+
// name: 'ephemeral-4',
1141+
// },
1142+
// {
1143+
// mountPath: '/run',
1144+
// name: 'ephemeral-5',
1145+
// },
1146+
],
11211147
readinessProbe: {
11221148
httpGet: {
11231149
path: '/',
@@ -1137,6 +1163,29 @@ const createDesktopDeploymentForTeam = async ({ team, passcodeHash }) => {
11371163
},
11381164
},
11391165
],
1166+
volumes: [
1167+
// {
1168+
// name: 'ephemeral',
1169+
// emptyDir: {},
1170+
// sizeLimit: '4Gi',
1171+
// },
1172+
// {
1173+
// name: 'ephemeral-2',
1174+
// emptyDir: {},
1175+
// },
1176+
// {
1177+
// name: 'ephemeral-3',
1178+
// emptyDir: {},
1179+
// },
1180+
// {
1181+
// name: 'ephemeral-4',
1182+
// emptyDir: {},
1183+
// },
1184+
// {
1185+
// name: 'ephemeral-5',
1186+
// emptyDir: {},
1187+
// },
1188+
],
11401189
tolerations: get('virtualdesktop.tolerations'),
11411190
affinity: get('virtualdesktop.affinity'),
11421191
runtimeClassName: get('virtualdesktop.runtimeClassName')

wrongsecrets-balancer/src/teams/teams.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ async function resetPasscode(req, res) {
498498
return res.status(404).send({ message: 'No instance to reset the passcode for.' });
499499
}
500500
logger.error(
501-
`Encountered unknown error while resetting passcode hash for deployment: ${JSON.stringify(error)}`
501+
`Encountered unknown error while resetting passcode hash for deployment: ${JSON.stringify(
502+
error
503+
)}`
502504
);
503505
// logger.error(error.message);
504506
return res.status(500).send({ message: 'Unknown error while resetting passcode.' });

0 commit comments

Comments
 (0)