GNU Utility: Envsubst
Recently, I learnt about a new command: envsubst which is present by default. It substitutes the values of environment variables. This means, instead of using helm, we can use plain k8s manifest and define environment specific variables and let envsubst replace them.
❯ cat foobar
PWD: ${PWD}
❯ envsubst < foobar
PWD: /Users/pradeep
Many a time, you may want to only substitue the values of envvars partly but not of all.
❯ cat foobar
foo: $FOO
bar: $BAR
❯ export FOO=foo
❯ export BAR=bar
Let say in above file, you only want to replace FOO’s value but don’t want to replace BAR’s value. You can achieve it:
❯ envsubst '$FOO' < foobar
foo: foo
bar: $BAR