Kops: CoreDNS externalCoreFile Parsing Invalid - Indentation

Created on 21 Nov 2019  路  3Comments  路  Source: kubernetes/kops

1. What kops version are you running? The command kops version, will display
this information.

kops 1.15.0

2. What Kubernetes version are you running? kubectl version will print the
version if a cluster is running or provide the Kubernetes version specified as
a kops flag.

1.15.6

3. What cloud provider are you using?
aws

4. What commands did you run? What is the simplest way to reproduce this issue?
kops update cluster

5. What happened after the commands executed?

error building tasks: error remapping manifest addons/coredns.addons.k8s.io/k8s-1.6.yaml: error parsing yaml: error converting YAML to JSON: yaml: line 10: did not find expected key

6. What did you expect to happen?
kops to update the addon for CoreDNS to use the externalCoreFile value in the kubedns fiel

7. Please provide your cluster manifest. Execute
kops get --name my.example.com -o yaml to display your cluster manifest.
You may want to remove your cluster name and other sensitive information.

Example config:

kubeDNS:
    provider: CoreDNS
    externalCoreFile: |
      .:53 {
          forward . 8.8.8.8:53
          log
      }

8. Please run the commands with most verbose logging by adding the -v 10 flag.
Paste the logs into this report, or in a gist and provide the gist link here.

9. Anything else do we need to know?

It looks like the templating is not setup to properly indent the inline doc, as setup here:
https://github.com/kubernetes/kops/pull/7376

We may need an indent function to make this work.

kinbug

Most helpful comment

Ugh, so sorry about this, didn't have any spare bandwidth until now to look again at what happened. Seems I managed to mess up one of my cleanups of my messy intermediate code attempts and then use the stale binary I'd previously built for checking the functionality before pushing up.

Thanks for catching this, and great job on the super quick fix @rochacon

All 3 comments

Josh and I did quite a bit of testing with this today and struggled to figure out an easily solution.

The issues seems that when the YAML from kubeDNS.externalCoreFile is outputted into the template, any row after row one is not indented properly.

@gjtempleton can you confirm your change works as expected in Kops 1.15.0 or let me know if you have any suggestions, if we're missing something?

Thanks so much!

I've opened the linked PR above with a fix for this. The issue was mainly with the way the externalCoreFile YAML was being injected into the final manifest, losing the proper indentation since the ConfigMap adds a few extra levels that are not possible to represent in the cluster spec file.

The solution was to add an indent function, as @joshbranham mentioned, and use that in the externalCoreFile template use.

Note that a workaround for this could be not using the : | yaml operator and just inlining the entire file into a single string, compensating for the missing indentation (6 spaces must be used):

kubeDNS:
  externalCoreFile: ".:53 {\n      forward . 8.8.8.8:53\n      log\n      }\n"

Ugh, so sorry about this, didn't have any spare bandwidth until now to look again at what happened. Seems I managed to mess up one of my cleanups of my messy intermediate code attempts and then use the stale binary I'd previously built for checking the functionality before pushing up.

Thanks for catching this, and great job on the super quick fix @rochacon

Was this page helpful?
0 / 5 - 0 ratings