How would i populate kubernetes with random environment variables?

6/16/2017

I recently dived into containers and kubernetes

I am trying to set an environment variable so that it will randomly or selectively choose from a list of words...

so say I have 1 pod which returns "hello world"

If I set a custom variable as RETURN_THIS = ["world", "kubernetes", "universe"]

if i scale to 3, then the second pod will return "hello kubernetes" and the third will return "hello, universe"

if I add another.. it would return "hello world"

and so forth

Any ideas on how I might be able to do this?

-- Nokdu
kubernetes

1 Answer

7/14/2017

Use the $RANDOM bash function

size=${#RETURN_THIS[@]}
HELLO=RETURN_THIS$(( $RANDOM % $size ))
-- Lindsay Landry
Source: StackOverflow