Skip to content

Commit

Permalink
Adding support for pytorch v1beta1 operator (kubeflow#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnugeorge authored and k8s-ci-robot committed Nov 9, 2018
1 parent 110c6b0 commit 304e701
Showing 1 changed file with 127 additions and 1 deletion.
128 changes: 127 additions & 1 deletion kubeflow/pytorch-job/pytorch-operator.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
$.parts(params, env).operatorRoleBinding(params.deploymentScope, params.deploymentNamespace),
] +

if params.pytorchJobVersion == "v1alpha2" then
if params.pytorchJobVersion == "v1beta1" then
[
$.parts(params, env).crdV1beta1,
$.parts(params, env).pytorchJobDeployV1beta1(params.pytorchJobImage, params.deploymentScope, params.deploymentNamespace),
]
else if params.pytorchJobVersion == "v1alpha2" then
[
$.parts(params, env).crdV1alpha2,
$.parts(params, env).pytorchJobDeployV1alpha2(params.pytorchJobImage, params.deploymentScope, params.deploymentNamespace),
Expand Down Expand Up @@ -84,6 +89,54 @@
},
},

crdV1beta1: {
apiVersion: "apiextensions.k8s.io/v1beta1",
kind: "CustomResourceDefinition",
metadata: {
name: "pytorchjobs.kubeflow.org",
},
spec: {
group: "kubeflow.org",
version: "v1beta1",
names: {
kind: "PyTorchJob",
singular: "pytorchjob",
plural: "pytorchjobs",
},
validation: {
openAPIV3Schema: {
properties: {
spec: {
properties: {
pytorchReplicaSpecs: {
properties: {
Worker: {
properties: {
replicas: {
type: "integer",
minimum: 1,
},
},
},
Master: {
properties: {
replicas: {
type: "integer",
minimum: 1,
maximum: 1,
},
},
},
},
},
},
},
},
},
},
},
},

pytorchJobDeploy(image): {
apiVersion: "extensions/v1beta1",
kind: "Deployment",
Expand Down Expand Up @@ -224,6 +277,79 @@
},
}, // pytorchJobDeployV1alpha2

pytorchJobDeployV1beta1(image, deploymentScope, deploymentNamespace): {
apiVersion: "extensions/v1beta1",
kind: "Deployment",
metadata: {
name: "pytorch-operator",
namespace: namespace,
},
spec: {
replicas: 1,
template: {
metadata: {
labels: {
name: "pytorch-operator",
},
},
spec: {
containers: [
{
command: std.prune([
"/pytorch-operator.v1beta1",
"--alsologtostderr",
"-v=1",
if deploymentScope == "namespace" then ("--namespace=" + deploymentNamespace),
]),
env: std.prune([
{
name: "MY_POD_NAMESPACE",
valueFrom: {
fieldRef: {
fieldPath: "metadata.namespace",
},
},
},
{
name: "MY_POD_NAME",
valueFrom: {
fieldRef: {
fieldPath: "metadata.name",
},
},
},
if deploymentScope == "namespace" then {
name: "KUBEFLOW_NAMESPACE",
valueFrom: {
fieldRef: {
fieldPath: "metadata.namespace",
},
},
},
]),
image: image,
name: "pytorch-operator",
volumeMounts: [
{
mountPath: "/etc/config",
name: "config-volume",
},
],
},
],
serviceAccountName: "pytorch-operator",
volumes: [
{
configMap: {
name: "pytorch-operator-config",
},
name: "config-volume",
},
],
},
},
},
}, // pytorchJobDeployV1beta1

// Default value for
defaultControllerConfig(pytorchDefaultImage):: if pytorchDefaultImage != "" && pytorchDefaultImage != "null" then
Expand Down

0 comments on commit 304e701

Please sign in to comment.