Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
Substitute environment variable in all files when kubectl apply-ing

Let's say we have a number of Kubernetes configuration files in a folder kubernetes and we want to apply them all:

kubectl apply -f kubernetes -n MyNamespace

Some of these files contain environment variables which need to be substituted first (no templating in Kubernetes). For instance, several of the deployment yamls contain something like:

image: myregistry.com/myrepo:$TAG

For a single yaml file, this can be done e.g. by using envsubst like this:

envsubst < deploy.yml | kubectl apply -f -

What's the best way to do these substitutions for all the yaml files?

(Looping over the files in the folder and calling envsubst as above is one option, but I suspect that it would be preferrable to pass the entire folder to kubectl and not individual files)

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can let envsubst read the content of multiple files from standard input as if it were reading one file < deploy.yaml either using process substitution <(..) feature of bash or using plain ol' cat

envsubst < <(cat *.yaml) | kubectl apply -f -

or

cat *.yaml | envsubst - | kubectl apply -f -
over 4 years ago · Santiago Trujillo Relatório

0

This works:

for f in *.yaml; do envsubst < $f | kubectl apply -f -; done
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda