Kubernetes equivalent of Terraform modules and variables

11/8/2019

Does Kubernetes have a way of reusing manifests without copying and paste them? Something akin to Terraform templates.

Is there a way of passing values between manifests?

I am looking to deploy the same service to multiple environments and wanted a way to call the necessary manifest and pass in the environment specific values.

I'd also like to do something like:

Generic-service.yaml

Name={variablename}

Foo-service.yaml

Use=General-service.yaml
variablename=foo-service-api

Any guidance is appreciated.

-- Confounder
containers
deployment
kubernetes
terraform

1 Answer

11/8/2019

Kustomize, now part of kubectl apply -k is a way to parameterize your Kubernetes manifests files.

With Kustomize, you have a base manifest file (e.g. of Deployment) and then multiple overlay directories for parameters e.g. for test, qa and prod environment.

I would recommend to have a look at Introduction to kustomize.

Before Kustomize it was common to use Helm for this.

-- Jonas
Source: StackOverflow