Skip to content

Commit a1f04ee

Browse files
committed
quick fixes for k8s
1 parent 65ce85c commit a1f04ee

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

build-and-deploy-minikube.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ minikube start --cpus=8 --memory=12000MB --network-plugin=cni --cni=calico --dr
88
eval $(minikube docker-env)
99
./build-and-deploy.sh
1010

11-
sleep 15
11+
echo "Waiting for wrongsecrets-balancer pods to be ready..."
12+
kubectl wait --for=condition=ready pod -l app=wrongsecrets-balancer --timeout=2s
1213

1314
echo "let's go!"
1415

cleaner/src/kubernetes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports.getNamespaces = getNamespaces;
3939

4040
const deleteNamespaceForTeam = async (namespaceName) => {
4141
await k8sCoreApi.deleteNamespace(namespaceName).catch((error) => {
42+
logger.info(error);
4243
throw new Error(error.response.body.message);
4344
});
4445
};

cleaner/src/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
getNamespaces,
77
deleteNamespaceForTeam,
88
} = require('./kubernetes');
9+
const { logger } = require('./logger');
910

1011
const MaxInactiveDuration = process.env['MAX_INACTIVE_DURATION'];
1112
const ShouldDelete = process.env['SHOULD_DELETE'];
@@ -55,6 +56,8 @@ async function listOldNamespaces() {
5556
var namespacesNames = [];
5657
// Get all namespaces
5758
const namespaces = await getNamespaces();
59+
logger.info(`Found ${namespaces.body.items.length} namespaces.`);
60+
// Check if there are no namespaces
5861
console.log(`Found ${namespaces.body.items.length} namespaces. Checking their activity.`);
5962
// Loop over all namespaces
6063
for (const namespace of namespaces.body.items) {

wrongsecrets-balancer/src/kubernetes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ const createSealedSecretForTeam = async (team, secretName, secretData) => {
293293

294294
/**
295295
* Create a sealed secret for challenge 33 specific to the team
296+
* TODO: REPLACE WITH CHALLENGE 53 FOR ACTUAL SEALED SECRET
296297
* @param {string} team - The team name
297298
*/
298299
const createSealedChallenge33SecretForTeam = async (team) => {
@@ -471,8 +472,9 @@ const createK8sDeploymentForTeam = async ({ team, passcodeHash }) => {
471472
key: 'answer',
472473
},
473474
},
474-
}, // ADD THIS MISSING COMMA AND CLOSING BRACKET
475-
], // MAKE SURE THIS CLOSES THE env ARRAY PROPERLY
475+
},
476+
...get('wrongsecrets.env', []),
477+
],
476478
envFrom: get('wrongsecrets.envFrom'),
477479
ports: [
478480
{
@@ -535,6 +537,7 @@ const createK8sDeploymentForTeam = async ({ team, passcodeHash }) => {
535537
return k8sAppsApi
536538
.createNamespacedDeployment({namespace:'t-' + team, body: deploymentWrongSecretsConfig})
537539
.catch((error) => {
540+
logger.error(`Failed to create deployment for team ${team}:`, error.body || error.message || error);
538541
throw new Error(error.response.body.message);
539542
});
540543
};

0 commit comments

Comments
 (0)