X Tutup
The Wayback Machine - https://web.archive.org/web/20200914053802/https://github.com/github/octodns/issues/477
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

Multiple YAML files or filters #477

Open
thockin opened this issue Jan 24, 2020 · 1 comment
Open

Multiple YAML files or filters #477

thockin opened this issue Jan 24, 2020 · 1 comment

Comments

@thockin
Copy link

@thockin thockin commented Jan 24, 2020

First, thanks for octodns!

Maybe I am going about this all wrong.

We have a zone k8s.io which we sync from YamlProvider to GoogleCloudProvider. Because I do not trust myself not to screw it up, we have a script that first pushes to a canary zone. So I actually have 2 zones - k8s.io and canary.k8s.io. I want to (as much as possible) push the EXACT SAME yaml to the canary, run some tests, then push that yaml to "real".

To do this, we symlinked canary.k8s.io.yaml -> k8s.io.yaml. Now I can use octodns to push either zone, from the same config. Awesome.

So what's the problem?

One of the records in the YAML is the NS that delegates "canary". This means that when I push to canary.k8s.io, I create a record "canary.canary.k8s.io", which has an NS record delegating to yet another zone. That hasn't really been a problem for us, but it turns out that some DNS providers see that as a "lame delegation" and it causes a problem for them.

So I want to fix this. I want to push the yaml to canary and the yaml PLUS the NS record to "real".

Now, I could keep 2 almost identical YAML files, but that seems likely to break eventually. What I really want is some way to join 2 yaml files when pushing. For example, if I had k8s.io._base.yaml and k8s.io._canary_delegation.yaml, the YamlProvider could recognize that they need to be merged. Then canary.k8s.io.yaml -> k8s.io._base.yaml. Canary gets the base, prod gets base+delegation.

Obviously YamlProvider does not support this. Is there a better way to do it? Am I taking crazy pills?

@ross
Copy link
Contributor

@ross ross commented Jan 25, 2020

Hi @thockin. I believe you can get what you're after by using 2 YamlProviders and a little creative structuring of things. Something to the effect of:

---
providers:
    base:
        class: octodns.provider.yaml.YamlProvider
        # In this directory you'd have k8s.io.yaml and the symlinked 
        # canary.k8s.io.yaml without the canary delegate record
        directory: ./config

    delegate:
        class: octodns.provider.yaml.YamlProvider
        # In this directory you'd just have k8s.io.yaml with ONLY the canary 
        # delegate record
        directory: ./delegate

zones:
    k8s.io.:
        sources:
            # Both YamlProviders here, the first will load all the records for the 
            # zone, the second will just add in the canary delegate
            - base
            - delegate
        targets:
            - ...

    canary.k8s.io.:
        # Just the YamlProvider with all the normal records here, so the 
        # sub-zone will be an exact copy (san the canary record.)
        sources:
            - base
        targets:
            - ...

We make extensive use of multiple sources like this internally, but not for exactly this use case. We often combine static configs coming from yaml with dynamic sources (ultimately) coming from systems we run, including k8s 😁

We also just landed #353 a few days ago that added a new flag to the YamlProvider, populate_should_replace that will allow you to change records in subsequent YamlProviders for use cases where things need to be modified by the later sources. Doesn't sound like you need that here, but just in case you run into something where you do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup