Skip to content

Commit

Permalink
Add support for using host network for OpenMPI worker pods (#1805)
Browse files Browse the repository at this point in the history
* Add support for using host network for OpenMPI worker pods

* Add TODO to replace custom upper function with std.asciiUpper (#1826)
  • Loading branch information
randomcoww authored and k8s-ci-robot committed Oct 23, 2018
1 parent 6fee47a commit 2e03ae9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions kubeflow/core/util.libsonnet
Expand Up @@ -13,6 +13,7 @@
result:: value,
}.result,

// TODO(https://github.com/kubeflow/kubeflow/issues/1826): Replace with std.asciiUpper once supported by required version of jsonnet
// Convert a string to upper case.
upper:: function(x) {
local cp(c) = std.codepoint(c),
Expand Down
1 change: 1 addition & 0 deletions kubeflow/openmpi/prototypes/openmpi.jsonnet
Expand Up @@ -29,6 +29,7 @@
// @optionalParam supplementalGroups string null Comma-delimited list of supplemental group ids to put the user of the first process of containers in master/worker pods.
// @optionalParam volumes array [] 'volumes' to put master/workers pods.
// @optionalParam volumeMounts array [] 'volumes' to put job containers in master/workers pods.
// @optionalParam useHostNetwork string false Use host network for worker pods.

local k = import "k.libsonnet";
local openmpi = import "kubeflow/openmpi/all.libsonnet";
Expand Down
24 changes: 24 additions & 0 deletions kubeflow/openmpi/util.libsonnet
Expand Up @@ -14,4 +14,28 @@
[std.splitLimit(keyValue, "=", 1)[0]]: std.splitLimit(keyValue, "=", 1)[1]
for keyValue in $.toArray(str)
} else {},

// TODO(https://github.com/kubeflow/kubeflow/issues/1826): Replace with std.asciiUpper once supported by required version of jsonnet
// Convert a string to upper case.
upper:: function(x) {
local cp(c) = std.codepoint(c),
local upLetter(c) = if cp(c) >= 97 && cp(c) < 123 then
std.char(cp(c) - 32)
else c,
result:: std.join("", std.map(upLetter, std.stringChars(x))),
}.result,

// Convert non-boolean types like string,number to a boolean.
// This is primarily intended for dealing with parameters that should be booleans.
toBool:: function(x) {
result::
if std.type(x) == "boolean" then
x
else if std.type(x) == "string" then
$.upper(x) == "TRUE"
else if std.type(x) == "number" then
x != 0
else
false,
}.result,
}
3 changes: 2 additions & 1 deletion kubeflow/openmpi/workloads.libsonnet
Expand Up @@ -41,14 +41,15 @@ local ROLE_WORKER = "worker";
subdomain: service.name(params),
restartPolicy: "Never",
terminationGracePeriodSeconds: 30,
dnsPolicy: "ClusterFirst",
dnsPolicy: "ClusterFirstWithHostNet",
schedulerName: params.schedulerName,
volumes: $.volumes(params),
containers: $.containers(params, role, podName),
imagePullSecrets: [{ name: secret } for secret in util.toArray(params.imagePullSecrets)],
serviceAccountName: serviceaccount.name(params),
nodeSelector: $.nodeSelector(params, role),
securityContext: $.securityContext(params),
hostNetwork: role == ROLE_WORKER && util.toBool(params.useHostNetwork),
},
},

Expand Down
1 change: 1 addition & 0 deletions kubeflow/weaveflux/util.libsonnet
@@ -1,5 +1,6 @@
// Some useful routines.
{
// TODO(https://github.com/kubeflow/kubeflow/issues/1826): Replace with std.asciiUpper once supported by required version of jsonnet
// Convert a string to upper case.
upper:: function(x) {
local cp(c) = std.codepoint(c),
Expand Down

0 comments on commit 2e03ae9

Please sign in to comment.