Skip to content

Commit

Permalink
helm best practice: do not specify namespace in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrove-oss committed Dec 19, 2024
1 parent 58b9291 commit 085ac69
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 60 deletions.
9 changes: 6 additions & 3 deletions tools/pytorchjob-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ mlbatch/pytorchjob-generator 1.1.5 v1beta2 An AppWrapper generator f
Create a `settings.yaml` file with the settings for the PyTorch job, for
example:
```yaml
namespace: my-namespace # namespace to deploy to (required)
jobName: my-job # name of the generated AppWrapper and PyTorchJob objects (required)
queueName: default-queue # local queue to submit to (default: default-queue)

Expand All @@ -55,11 +54,15 @@ To learn more about the available settings see [chart/README.md](chart/README.md
## Submitting the Job
All the commands below will target the currently selected OpenShift project.
If your userid has access to multiple projects, either use `oc project <project-name>`
to change your selected project or add `-n <project-name>` to each command.

To submit the Pytorch job to the cluster using the `settings.yaml` file, run:
```sh
helm template -f settings.yaml mlbatch/pytorchjob-generator | oc create -f-
```
+

To optionally capture the generated `AppWrapper` specification as a
`generated.yaml` file, run instead:
```sh
Expand All @@ -69,5 +72,5 @@ helm template -f settings.yaml mlbatch/pytorchjob-generator | tee generated.yaml
To remove the PyTorch job from the cluster, delete the generated `AppWrapper`
object:
```sh
oc delete appwrapper -n my-namespace my-job
oc delete appwrapper my-job
```
1 change: 0 additions & 1 deletion tools/pytorchjob-generator/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ customize the Jobs generated by the tool.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| namespace | string | must be provided by user | The Kubernetes namespace in which the Job will run. |
| jobName | string | must be provided by user | Name of the Job. Will be the name of the AppWrapper and the PyTorchJob. |
| queueName | string | `"default-queue"` | Name of the local queue to which the Job will be submitted. |
| 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...)! |
Expand Down
1 change: 0 additions & 1 deletion tools/pytorchjob-generator/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


{{- define "mlbatch.container.metadata" }}
namespace: {{ .Values.namespace }}
{{- if or .Values.customLabels .Values.autopilotHealthChecks }}
labels:
{{- include "mlbatch.customLabels" . | indent 4 }}
Expand Down
2 changes: 0 additions & 2 deletions tools/pytorchjob-generator/chart/templates/appwrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ apiVersion: workload.codeflare.dev/v1beta2
kind: AppWrapper
metadata:
name: {{ .Values.jobName }}
namespace: {{ required "Please specify a 'namespace' in the user file" .Values.namespace }}
annotations:
workload.codeflare.dev.mlbatch/pytorchGeneratorVersion: "{{ .Chart.Version }}"
{{- if .Values.admissionGracePeriodDuration }}
Expand Down Expand Up @@ -90,7 +89,6 @@ spec:
kind: "PyTorchJob"
metadata:
name: {{ .Values.jobName }}
namespace: {{ .Values.namespace }}
{{- if .Values.customLabels }}
labels:
{{- include "mlbatch.customLabels" . | indent 26 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ Adding Volume Mounts:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -93,8 +90,7 @@ Adding Volume Mounts:
replicas: 3
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -169,23 +165,20 @@ Adding initContainers:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -257,8 +250,7 @@ Adding initContainers:
replicas: 3
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -336,23 +328,20 @@ AppWrapper metadata should match snapshot:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -411,8 +400,7 @@ AppWrapper metadata should match snapshot:
replicas: 3
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -477,23 +465,20 @@ AppWrapper spec should match snapshot:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -552,8 +537,7 @@ AppWrapper spec should match snapshot:
replicas: 3
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -618,23 +602,20 @@ Enabling NVMe:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -708,8 +689,7 @@ Enabling NVMe:
replicas: 3
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -789,15 +769,13 @@ Enabling RoCE GDR:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
Expand All @@ -807,7 +785,6 @@ Enabling RoCE GDR:
metadata:
annotations:
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
namespace: my-namespace
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -883,7 +860,6 @@ Enabling RoCE GDR:
metadata:
annotations:
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
namespace: my-namespace
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -962,15 +938,13 @@ Enabling all advanced features at once:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
Expand All @@ -980,7 +954,6 @@ Enabling all advanced features at once:
metadata:
annotations:
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
namespace: my-namespace
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -1108,7 +1081,6 @@ Enabling all advanced features at once:
metadata:
annotations:
k8s.v1.cni.cncf.io/networks: multi-nic-cni-operator-ipvlanl3
namespace: my-namespace
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -1239,23 +1211,20 @@ Enabling sshGitConfig injects the envvars, volumes, and volumeMounts:
labels:
kueue.x-k8s.io/queue-name: default-queue
name: my-job
namespace: my-namespace
spec:
components:
- template:
apiVersion: kubeflow.org/v1
kind: PyTorchJob
metadata:
name: my-job
namespace: my-namespace
spec:
pytorchReplicaSpecs:
Master:
replicas: 1
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down Expand Up @@ -1328,8 +1297,7 @@ Enabling sshGitConfig injects the envvars, volumes, and volumeMounts:
replicas: 3
restartPolicy: Never
template:
metadata:
namespace: my-namespace
metadata: null
spec:
affinity:
nodeAffinity:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
namespace: my-namespace # namespace to deploy to (required)
jobName: my-job # name of the generated AppWrapper and PyTorchJob objects (required)
queueName: default-queue # local queue to submit to (default: default-queue)

Expand Down
2 changes: 0 additions & 2 deletions tools/pytorchjob-generator/chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
"$schema": "https://json-schema.org/draft/2020-12/schema#",
"type": "object",
"required": [
"namespace",
"jobName",
"containerImage"
],
"additionalProperties": false,
"properties": {
"namespace": { "$ref": "#/$defs/rfc1123Label" },
"jobName": { "type": "string" },
"queueName": { "oneOf": [
{ "type": "null" },
Expand Down
5 changes: 0 additions & 5 deletions tools/pytorchjob-generator/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# Job Metadata
####################

# -- (string) The Kubernetes namespace in which the Job will run.
# @default -- must be provided by user
# @section -- Job Metadata
namespace:

# -- (string) Name of the Job. Will be the name of the AppWrapper and the PyTorchJob.
# @default -- must be provided by user
# @section -- Job Metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
namespace: my-namespace # namespace to deploy to (required)
jobName: my-job # name of the generated AppWrapper and PyTorchJob objects (required)
queueName: default-queue # local queue to submit to (default: default-queue)

Expand Down

0 comments on commit 085ac69

Please sign in to comment.