Skip to content

Commit 085ac69

Browse files
committed
helm best practice: do not specify namespace in templates
1 parent 58b9291 commit 085ac69

File tree

9 files changed

+18
-60
lines changed

9 files changed

+18
-60
lines changed

tools/pytorchjob-generator/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ mlbatch/pytorchjob-generator 1.1.5 v1beta2 An AppWrapper generator f
2828
Create a `settings.yaml` file with the settings for the PyTorch job, for
2929
example:
3030
```yaml
31-
namespace: my-namespace # namespace to deploy to (required)
3231
jobName: my-job # name of the generated AppWrapper and PyTorchJob objects (required)
3332
queueName: default-queue # local queue to submit to (default: default-queue)
3433

@@ -55,11 +54,15 @@ To learn more about the available settings see [chart/README.md](chart/README.md
5554
5655
## Submitting the Job
5756
57+
All the commands below will target the currently selected OpenShift project.
58+
If your userid has access to multiple projects, either use `oc project <project-name>`
59+
to change your selected project or add `-n <project-name>` to each command.
60+
5861
To submit the Pytorch job to the cluster using the `settings.yaml` file, run:
5962
```sh
6063
helm template -f settings.yaml mlbatch/pytorchjob-generator | oc create -f-
6164
```
62-
+
65+
6366
To optionally capture the generated `AppWrapper` specification as a
6467
`generated.yaml` file, run instead:
6568
```sh
@@ -69,5 +72,5 @@ helm template -f settings.yaml mlbatch/pytorchjob-generator | tee generated.yaml
6972
To remove the PyTorch job from the cluster, delete the generated `AppWrapper`
7073
object:
7174
```sh
72-
oc delete appwrapper -n my-namespace my-job
75+
oc delete appwrapper my-job
7376
```

tools/pytorchjob-generator/chart/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ customize the Jobs generated by the tool.
1515

1616
| Key | Type | Default | Description |
1717
|-----|------|---------|-------------|
18-
| namespace | string | must be provided by user | The Kubernetes namespace in which the Job will run. |
1918
| jobName | string | must be provided by user | Name of the Job. Will be the name of the AppWrapper and the PyTorchJob. |
2019
| queueName | string | `"default-queue"` | Name of the local queue to which the Job will be submitted. |
2120
| priority | string | `"default-priority"` | Type of priority for the job (choose from: "default-priority", "low-priority" or "high-priority"). WARNING: "high-priority" jobs need to be approved (We're watching you...)! |

tools/pytorchjob-generator/chart/templates/_helpers.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
{{- define "mlbatch.container.metadata" }}
13-
namespace: {{ .Values.namespace }}
1413
{{- if or .Values.customLabels .Values.autopilotHealthChecks }}
1514
labels:
1615
{{- include "mlbatch.customLabels" . | indent 4 }}

tools/pytorchjob-generator/chart/templates/appwrapper.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ apiVersion: workload.codeflare.dev/v1beta2
5252
kind: AppWrapper
5353
metadata:
5454
name: {{ .Values.jobName }}
55-
namespace: {{ required "Please specify a 'namespace' in the user file" .Values.namespace }}
5655
annotations:
5756
workload.codeflare.dev.mlbatch/pytorchGeneratorVersion: "{{ .Chart.Version }}"
5857
{{- if .Values.admissionGracePeriodDuration }}
@@ -90,7 +89,6 @@ spec:
9089
kind: "PyTorchJob"
9190
metadata:
9291
name: {{ .Values.jobName }}
93-
namespace: {{ .Values.namespace }}
9492
{{- if .Values.customLabels }}
9593
labels:
9694
{{- include "mlbatch.customLabels" . | indent 26 }}

tools/pytorchjob-generator/chart/tests/__snapshot__/helloworld_test.yaml.snap

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@ Adding Volume Mounts:
88
labels:
99
kueue.x-k8s.io/queue-name: default-queue
1010
name: my-job
11-
namespace: my-namespace
1211
spec:
1312
components:
1413
- template:
1514
apiVersion: kubeflow.org/v1
1615
kind: PyTorchJob
1716
metadata:
1817
name: my-job
19-
namespace: my-namespace
2018
spec:
2119
pytorchReplicaSpecs:
2220
Master:
2321
replicas: 1
2422
restartPolicy: Never
2523
template:
26-
metadata:
27-
namespace: my-namespace
24+
metadata: null
2825
spec:
2926
affinity:
3027
nodeAffinity:
@@ -93,8 +90,7 @@ Adding Volume Mounts:
9390
replicas: 3
9491
restartPolicy: Never
9592
template:
96-
metadata:
97-
namespace: my-namespace
93+
metadata: null
9894
spec:
9995
affinity:
10096
nodeAffinity:
@@ -169,23 +165,20 @@ Adding initContainers:
169165
labels:
170166
kueue.x-k8s.io/queue-name: default-queue
171167
name: my-job
172-
namespace: my-namespace
173168
spec:
174169
components:
175170
- template:
176171
apiVersion: kubeflow.org/v1
177172
kind: PyTorchJob
178173
metadata:
179174
name: my-job
180-
namespace: my-namespace
181175
spec:
182176
pytorchReplicaSpecs:
183177
Master:
184178
replicas: 1
185179
restartPolicy: Never
186180
template:
187-
metadata:
188-
namespace: my-namespace
181+
metadata: null
189182
spec:
190183
affinity:
191184
nodeAffinity:
@@ -257,8 +250,7 @@ Adding initContainers:
257250
replicas: 3
258251
restartPolicy: Never
259252
template:
260-
metadata:
261-
namespace: my-namespace
253+
metadata: null
262254
spec:
263255
affinity:
264256
nodeAffinity:
@@ -336,23 +328,20 @@ AppWrapper metadata should match snapshot:
336328
labels:
337329
kueue.x-k8s.io/queue-name: default-queue
338330
name: my-job
339-
namespace: my-namespace
340331
spec:
341332
components:
342333
- template:
343334
apiVersion: kubeflow.org/v1
344335
kind: PyTorchJob
345336
metadata:
346337
name: my-job
347-
namespace: my-namespace
348338
spec:
349339
pytorchReplicaSpecs:
350340
Master:
351341
replicas: 1
352342
restartPolicy: Never
353343
template:
354-
metadata:
355-
namespace: my-namespace
344+
metadata: null
356345
spec:
357346
affinity:
358347
nodeAffinity:
@@ -411,8 +400,7 @@ AppWrapper metadata should match snapshot:
411400
replicas: 3
412401
restartPolicy: Never
413402
template:
414-
metadata:
415-
namespace: my-namespace
403+
metadata: null
416404
spec:
417405
affinity:
418406
nodeAffinity:
@@ -477,23 +465,20 @@ AppWrapper spec should match snapshot:
477465
labels:
478466
kueue.x-k8s.io/queue-name: default-queue
479467
name: my-job
480-
namespace: my-namespace
481468
spec:
482469
components:
483470
- template:
484471
apiVersion: kubeflow.org/v1
485472
kind: PyTorchJob
486473
metadata:
487474
name: my-job
488-
namespace: my-namespace
489475
spec:
490476
pytorchReplicaSpecs:
491477
Master:
492478
replicas: 1
493479
restartPolicy: Never
494480
template:
495-
metadata:
496-
namespace: my-namespace
481+
metadata: null
497482
spec:
498483
affinity:
499484
nodeAffinity:
@@ -552,8 +537,7 @@ AppWrapper spec should match snapshot:
552537
replicas: 3
553538
restartPolicy: Never
554539
template:
555-
metadata:
556-
namespace: my-namespace
540+
metadata: null
557541
spec:
558542
affinity:
559543
nodeAffinity:
@@ -618,23 +602,20 @@ Enabling NVMe:
618602
labels:
619603
kueue.x-k8s.io/queue-name: default-queue
620604
name: my-job
621-
namespace: my-namespace
622605
spec:
623606
components:
624607
- template:
625608
apiVersion: kubeflow.org/v1
626609
kind: PyTorchJob
627610
metadata:
628611
name: my-job
629-
namespace: my-namespace
630612
spec:
631613
pytorchReplicaSpecs:
632614
Master:
633615
replicas: 1
634616
restartPolicy: Never
635617
template:
636-
metadata:
637-
namespace: my-namespace
618+
metadata: null
638619
spec:
639620
affinity:
640621
nodeAffinity:
@@ -708,8 +689,7 @@ Enabling NVMe:
708689
replicas: 3
709690
restartPolicy: Never
710691
template:
711-
metadata:
712-
namespace: my-namespace
692+
metadata: null
713693
spec:
714694
affinity:
715695
nodeAffinity:
@@ -789,15 +769,13 @@ Enabling RoCE GDR:
789769
labels:
790770
kueue.x-k8s.io/queue-name: default-queue
791771
name: my-job
792-
namespace: my-namespace
793772
spec:
794773
components:
795774
- template:
796775
apiVersion: kubeflow.org/v1
797776
kind: PyTorchJob
798777
metadata:
799778
name: my-job
800-
namespace: my-namespace
801779
spec:
802780
pytorchReplicaSpecs:
803781
Master:
@@ -807,7 +785,6 @@ Enabling RoCE GDR:
807785
metadata:
808786
annotations:
809787
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
810-
namespace: my-namespace
811788
spec:
812789
affinity:
813790
nodeAffinity:
@@ -883,7 +860,6 @@ Enabling RoCE GDR:
883860
metadata:
884861
annotations:
885862
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
886-
namespace: my-namespace
887863
spec:
888864
affinity:
889865
nodeAffinity:
@@ -962,15 +938,13 @@ Enabling all advanced features at once:
962938
labels:
963939
kueue.x-k8s.io/queue-name: default-queue
964940
name: my-job
965-
namespace: my-namespace
966941
spec:
967942
components:
968943
- template:
969944
apiVersion: kubeflow.org/v1
970945
kind: PyTorchJob
971946
metadata:
972947
name: my-job
973-
namespace: my-namespace
974948
spec:
975949
pytorchReplicaSpecs:
976950
Master:
@@ -980,7 +954,6 @@ Enabling all advanced features at once:
980954
metadata:
981955
annotations:
982956
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
983-
namespace: my-namespace
984957
spec:
985958
affinity:
986959
nodeAffinity:
@@ -1108,7 +1081,6 @@ Enabling all advanced features at once:
11081081
metadata:
11091082
annotations:
11101083
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
1111-
namespace: my-namespace
11121084
spec:
11131085
affinity:
11141086
nodeAffinity:
@@ -1239,23 +1211,20 @@ Enabling sshGitConfig injects the envvars, volumes, and volumeMounts:
12391211
labels:
12401212
kueue.x-k8s.io/queue-name: default-queue
12411213
name: my-job
1242-
namespace: my-namespace
12431214
spec:
12441215
components:
12451216
- template:
12461217
apiVersion: kubeflow.org/v1
12471218
kind: PyTorchJob
12481219
metadata:
12491220
name: my-job
1250-
namespace: my-namespace
12511221
spec:
12521222
pytorchReplicaSpecs:
12531223
Master:
12541224
replicas: 1
12551225
restartPolicy: Never
12561226
template:
1257-
metadata:
1258-
namespace: my-namespace
1227+
metadata: null
12591228
spec:
12601229
affinity:
12611230
nodeAffinity:
@@ -1328,8 +1297,7 @@ Enabling sshGitConfig injects the envvars, volumes, and volumeMounts:
13281297
replicas: 3
13291298
restartPolicy: Never
13301299
template:
1331-
metadata:
1332-
namespace: my-namespace
1300+
metadata: null
13331301
spec:
13341302
affinity:
13351303
nodeAffinity:

tools/pytorchjob-generator/chart/tests/helloworld.settings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
namespace: my-namespace # namespace to deploy to (required)
21
jobName: my-job # name of the generated AppWrapper and PyTorchJob objects (required)
32
queueName: default-queue # local queue to submit to (default: default-queue)
43

tools/pytorchjob-generator/chart/values.schema.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
"$schema": "https://json-schema.org/draft/2020-12/schema#",
33
"type": "object",
44
"required": [
5-
"namespace",
65
"jobName",
76
"containerImage"
87
],
98
"additionalProperties": false,
109
"properties": {
11-
"namespace": { "$ref": "#/$defs/rfc1123Label" },
1210
"jobName": { "type": "string" },
1311
"queueName": { "oneOf": [
1412
{ "type": "null" },

tools/pytorchjob-generator/chart/values.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# Job Metadata
33
####################
44

5-
# -- (string) The Kubernetes namespace in which the Job will run.
6-
# @default -- must be provided by user
7-
# @section -- Job Metadata
8-
namespace:
9-
105
# -- (string) Name of the Job. Will be the name of the AppWrapper and the PyTorchJob.
116
# @default -- must be provided by user
127
# @section -- Job Metadata

tools/pytorchjob-generator/examples/helloworld.settings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
namespace: my-namespace # namespace to deploy to (required)
21
jobName: my-job # name of the generated AppWrapper and PyTorchJob objects (required)
32
queueName: default-queue # local queue to submit to (default: default-queue)
43

0 commit comments

Comments
 (0)