Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split data into more than one file #820

Closed
maudrid opened this issue Mar 29, 2023 · 2 comments
Closed

Split data into more than one file #820

maudrid opened this issue Mar 29, 2023 · 2 comments
Assignees

Comments

@maudrid
Copy link

maudrid commented Mar 29, 2023

Hi. I'm very new to ytt and I hope someone can point me in the right direction.
I'm trying to do something seemingly simple, but I'm not able to get it to work.
I have created a config.yml and I have a data1.yml.
I can then use #@ load("@ytt:data", "data") and reference the values ex: attribute1: #@ data.values.att1 and this works.
Some of the values that I have this the data1.yml, I want to place in a different file for maintenance purposes, now I have 3 files:
config.yml

#@ load("@ytt:data", "data")

attribute1: #@ data.values.att1
attribute2: #@ data.values.att2

data1.yml

#@data/values
---
att1: "value1"

data2.yml

#@data/values
---
att2: "value2"

This produces the following error:

Overlaying data values (in following order: data1.yml, data2.yml): Document on line data2.yml:2: Map item (key 'att2') on line data2.yml:3: Expected number of matched nodes to be 1, but was 0

I understand that it is trying to overlay the 2 data files, but that is not what I want.
I can add att2 to the data1.yml file to remove this error, but that defeats what I set out to do.

That being said, maybe I'm using this all wrong in the firs place.
Here is a real example of why I'm trying to do this:
config.yml

 grafana:
    image: gitlab.company.com:4567/myProject/grafana:#@ data.values.branch or "1.9"
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 400m
    #@ if data.values.swarm:
      placement:
        constraints:
          - "node.labels.appserver==true"
      labels: #@ data.values.grafana_labels
    #@ else:
    labels: #@ data.values.grafana_labels
    #@ end

labels.yml

#@data/values
---
grafana_labels:
  - traefik.enable=true
  - traefik.http.routers.grafana.entrypoints=web

settings.yml

#@data/values
---
swarm: true
branch: "master"

So I would not want to mix the values from the labels and the settings files. Since the settings will change all the time and the labels are static. But by using labels as data, I can maintain one copy of labels.

@maudrid maudrid added the carvel triage This issue has not yet been triaged for relevance label Mar 29, 2023
@vmunishwar vmunishwar self-assigned this Apr 6, 2023
@vmunishwar
Copy link
Contributor

vmunishwar commented Apr 8, 2023

Hi @maudrid, thanks for reaching out.
This can be solved by using an overlay/match annotation #@overlay/match missing_ok=True above each new value in the settings.yml file. For your reference, I am attaching screenshots of these examples ran in ytt playground as well. Please let us know if this helps. We have Carvel’s slack channel too if you would like to join #carvel in Kubernetes

Also, Here are some docs using overlays and playground example to help you get started.

Screenshot 2023-04-07 at 11 46 32 PM

Screenshot 2023-04-05 at 5 33 21 PM

@maudrid
Copy link
Author

maudrid commented Apr 14, 2023

Thanks very much for the help.

@maudrid maudrid closed this as completed Apr 14, 2023
@github-actions github-actions bot removed the carvel triage This issue has not yet been triaged for relevance label Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants