Skip to content

Commit

Permalink
Also make juice-shop labels consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
J12934 committed Oct 27, 2022
1 parent c2ecf82 commit bd3f933
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cleaner/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function main() {
undefined,
undefined,
undefined,
'app=juice-shop'
'app.kubernetes.io/name=juice-shop'
);

console.log(`Found ${instances.body.items.length} instances. Checking their activity.`);
Expand Down
4 changes: 2 additions & 2 deletions helm/multi-juicer/templates/juice-shop/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ spec:
- team
selector:
matchLabels:
app: juice-shop
deployment-context: {{ .Release.Name | quote }}
app.kubernetes.io/name: 'juice-shop'
app.kubernetes.io/managed-by: {{ .Release.Name | quote }}
endpoints:
- targetPort: 3000
{{- end }}
43 changes: 31 additions & 12 deletions juice-balancer/src/kubernetes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ const createDeploymentForTeam = async ({ team, passcodeHash }) => {
metadata: {
name: `t-${team}-juiceshop`,
labels: {
app: 'juice-shop',
team,
'deployment-context': get('deploymentContext'),
'app.kubernetes.io/version': get('juiceShop.tag'),
'app.kubernetes.io/component': 'vulnerable-app',
'app.kubernetes.io/managed-by': get('deploymentContext'),
'app.kubernetes.io/name': 'juice-shop',
'app.kubernetes.io/instance': `juice-shop-${get('deploymentContext')}`,
'app.kubernetes.io/part-of': 'multi-juicer',
},
annotations: {
'multi-juicer.iteratec.dev/lastRequest': `${new Date().getTime()}`,
Expand All @@ -38,17 +42,21 @@ const createDeploymentForTeam = async ({ team, passcodeHash }) => {
spec: {
selector: {
matchLabels: {
app: 'juice-shop',
team,
'deployment-context': get('deploymentContext'),
'app.kubernetes.io/name': 'juice-shop',
'app.kubernetes.io/managed-by': get('deploymentContext'),
},
},
template: {
metadata: {
labels: {
app: 'juice-shop',
team,
'deployment-context': get('deploymentContext'),
'app.kubernetes.io/version': get('juiceShop.tag'),
'app.kubernetes.io/name': 'juice-shop',
'app.kubernetes.io/managed-by': get('deploymentContext'),
'app.kubernetes.io/component': 'vulnerable-app',
'app.kubernetes.io/instance': `juice-shop-${get('deploymentContext')}`,
'app.kubernetes.io/part-of': 'multi-juicer',
},
},
spec: {
Expand Down Expand Up @@ -142,17 +150,21 @@ const createServiceForTeam = async (teamname) =>
metadata: {
name: `t-${teamname}-juiceshop`,
labels: {
app: 'juice-shop',
team: teamname,
'deployment-context': get('deploymentContext'),
'app.kubernetes.io/version': get('juiceShop.tag'),
'app.kubernetes.io/name': 'juice-shop',
'app.kubernetes.io/managed-by': get('deploymentContext'),
'app.kubernetes.io/component': 'vulnerable-app',
'app.kubernetes.io/instance': `juice-shop-${get('deploymentContext')}`,
'app.kubernetes.io/part-of': 'multi-juicer',
},
...(await getOwnerReference()),
},
spec: {
selector: {
app: 'juice-shop',
team: teamname,
'deployment-context': get('deploymentContext'),
'app.kubernetes.io/name': 'juice-shop',
'app.kubernetes.io/managed-by': get('deploymentContext'),
},
ports: [
{
Expand Down Expand Up @@ -192,7 +204,10 @@ const getJuiceShopInstances = () =>
undefined,
undefined,
undefined,
`app=juice-shop,deployment-context=${get('deploymentContext')}`
[
`app.kubernetes.io/name=juice-shop`,
`app.kubernetes.io/managed-by=${get('deploymentContext')}`,
].join(',')
)
.catch((error) => {
throw new Error(error.response.body.message);
Expand Down Expand Up @@ -224,7 +239,11 @@ const deletePodForTeam = async (team) => {
undefined,
undefined,
undefined,
`app=juice-shop,team=${team},deployment-context=${get('deploymentContext')}`
[
`team=${team}`,
`app.kubernetes.io/name=juice-shop`,
`app.kubernetes.io/managed-by=${get('deploymentContext')}`,
].join(',')
);

const pods = res.body.items;
Expand Down

0 comments on commit bd3f933

Please sign in to comment.