mirror of https://github.com/kubeflow/examples.git
Made SecretRefs more generic and fixed failed test
This commit is contained in:
parent
f89af01e2c
commit
f85a8e970f
|
|
@ -44,26 +44,7 @@ local trainEnv = [
|
|||
];
|
||||
|
||||
// AWS Access/Secret keys
|
||||
local awsSecretKeyRefs = util.parseSecret(params.secretKeyRefs);
|
||||
local awsAccessKeyId = if std.length(awsSecretKeyRefs) > 0 then awsSecretKeyRefs[0] else "";
|
||||
local awsSecretAccessKey = if std.length(awsSecretKeyRefs) > 1 then awsSecretKeyRefs[1] else "";
|
||||
|
||||
local awsEnv = [
|
||||
{
|
||||
name: "AWS_ACCESS_KEY_ID",
|
||||
valueFrom: {
|
||||
secretKeyRef:
|
||||
awsAccessKeyId
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "AWS_SECRET_ACCESS_KEY",
|
||||
valueFrom: {
|
||||
secretKeyRef:
|
||||
awsSecretAccessKey
|
||||
}
|
||||
}
|
||||
];
|
||||
local trainSecrets = util.parseSecrets(params.secretKeyRefs);
|
||||
|
||||
local secretPieces = std.split(params.secret, "=");
|
||||
local secretName = if std.length(secretPieces) > 0 then secretPieces[0] else "";
|
||||
|
|
@ -76,7 +57,7 @@ local replicaSpec = {
|
|||
"/usr/bin/python",
|
||||
"/opt/model.py",
|
||||
],
|
||||
env: trainEnv + util.parseEnv(params.envVariables) + awsEnv,
|
||||
env: trainEnv + util.parseEnv(params.envVariables) + trainSecrets,
|
||||
image: params.image,
|
||||
name: "tensorflow",
|
||||
volumeMounts: if secretMountPath != "" then
|
||||
|
|
|
|||
|
|
@ -7,11 +7,16 @@
|
|||
value: v[1],
|
||||
},
|
||||
|
||||
// convert a list of two items into a map representing a secret name and key
|
||||
// convert a list of two items into a map representing an env variable referencing k8s secret
|
||||
listToSecretMap:: function(v)
|
||||
{
|
||||
name: v[0],
|
||||
key: v[1],
|
||||
valueFrom: {
|
||||
secretKeyRef: {
|
||||
name: std.split(v[1], ".")[0],
|
||||
key: std.split(v[1], ".")[1],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Function to turn comma separated list of environment variables into a dictionary.
|
||||
|
|
@ -24,12 +29,12 @@
|
|||
)
|
||||
else [],
|
||||
|
||||
// Function to turn comma separated list of secret names and keys into a dictionary.
|
||||
parseSecret:: function(v)
|
||||
// Function to turn comma separated list of env variables referencing secrets into a dictionary.
|
||||
parseSecrets:: function(v)
|
||||
local pieces = std.split(v, ",");
|
||||
if v != "" && std.length(pieces) > 0 then
|
||||
std.map(
|
||||
function(i) $.listToSecretMap(std.split(i, ".")),
|
||||
function(i) $.listToSecretMap(std.split(i, "=")),
|
||||
std.split(v, ",")
|
||||
)
|
||||
else [],
|
||||
|
|
|
|||
Loading…
Reference in New Issue