Home > Enterprise >  purpose of PLACEHOLDER entry in kubernetes yaml files
purpose of PLACEHOLDER entry in kubernetes yaml files

Time:01-20

Why write non-secret metadata as PLACEHOLDER in kubernetes yaml files? (from here):

namespace: PLACEHOLDER

Any reason to replace it with a later sed command? why not simply write it inside the yaml file?

CodePudding user response:

Based on my experience, when you see files like this, they might be used in some sort of pipelines to deploy them in multiple clusters. These files, from my prior experience, act like templates when you don't want to go all in with Helm charts for a single ConfigMap or Secret or a different isolated resource. This allows you to replace these placeholders with values corresponding with you cluster, region etc.

Hope this makes sense.

CodePudding user response:

Those values are normally replaced or overridden later, either by sed within a CI/CD pipeline like Jenkins, or (as indicated by the question you linked to) by Helm.

With helm, you can override values within the yamls either with a second yaml, or at the command line using --set switches.

So I could have

helm install nginx --values values.yaml --values values2.yaml

and the placeholder value in values.yaml would get overridden by the value in values2.yaml

Placeholders are often used to deliberately break an install is someone tries to install it without passing in the right values.yaml

For example:

helm install my-chart

Could break because of the placeholder value, but

helm install my-chart --values production.values.yaml

would install because the placeholder values are overridden and the chart can install correctly.

  • Related