Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an include directive for Kubernetes yaml resource definitions?

Tags:

kubernetes

Consider the following ConfigMap definition, in, say, foo.yml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: foo-data
data:
  foo.json: |-
    {
      "foo": "foo",
      "bar": 42
    }

Is there a way to load the foo.json data from an external file, instead of inlining it in the template? It would be nice if I could put the data in a file foo.json next to foo.yml, reference it somehow, and have K8s figure it out when I apply the template.

Is that possible? How?

If not, is the feature on the roadmap?

like image 607
Tomas Aschan Avatar asked Feb 26 '18 17:02

Tomas Aschan


People also ask

Which of the following field in Kubernetes YAML file is used to define the type of object being used?

In the . yaml file for the Kubernetes object you want to create, you'll need to set values for the following fields: apiVersion - Which version of the Kubernetes API you're using to create this object. kind - What kind of object you want to create.

Where do I put Kubernetes YAML files?

As mentioned above, using the YAML field allows you to declaratively manage your Kubernetes applications. These YAML files can be stored in a common directory and may all be applied using kubectl apply -f <directory>.

How do I create a pod definition YAML file?

To create a Kubernetes pod with YAML, you first create an empty file, assign it the necessary access permissions, and then define the necessary key-value pairs. The important ones are the apiVersion, the kind (pod), name, and the containers within the pod.


1 Answers

Afaik there is no build-in templating as for now but you can use ansible templating capabilities with k8s yaml files saute or together with e.g. k8s plugin.

Works like a charm :)

like image 186
bazeusz Avatar answered Sep 19 '22 03:09

bazeusz