Kubernetes Will Solve YAML Headaches with KYAML

4 min read Original article ↗

The data serialization language used to deploy and run Kubernetes has gotten an overhaul.

The upcoming 1.34 release of Kubernetes may come with KYAML, a strict subset of YAML formatted specially for Kubernetes users.

“YAML is the programming language of Kubernetes,” noted Nigel Douglas, head of developer relations at Cloudsmith, a cloud native package management service, in an interview with TNS.

Yet, many users feel frustrated by a number of design quirks in YAML that cause extra work and additional debugging (even as the creator himself is working to make YAML a full-fledged programming language).

The solution to YAML’s woes? Add in a pinch of JSON.

Paging Dr. Null

YAML is used throughout the Kubernetes ecosystem: to create a network policy, for writing a deployment manifest or for Helm deployment files.

One problem: YAML doesn’t digest white spaces well. Particularly, when users come with nested instructions, they must pay close attention to the number of indentations used. Formatting  is a tedious exercise for the cloud native warrior, yet having the wrong number of idents in the code can trip up Helm, for instance.

Likewise, optional quotes in YAML have led to ambiguity, which is always dangerous for a computer. The challenge with quotes is aptly illustrated through “The Norway Problem,” in which the failure to encapsulate a two-letter country abbreviation with a set of quotes may trip up a parser on the lookout for reserved keywords, such as “NO” for Norway.

Or, in another case, Last_Name=Null for someone actually named Richard Null.

As many have noted, JSON could also be used in place of YAML, though it comes with its own limitations in a Kubernetes environment: no comment support and a strict adherence to trailing commas and quoted keys.

Yet Another Markup Language

“The most frustrating part of YAML is that it doesn’t have to be this bad. YAML is a very broad specification. Inside that specification is a reasonable grammar screaming to be let out,” Kubernetes proposal KEP 5295 asserts.

KYAML is that specification, at least for Kubernetes users. KYAML is “built in a way that it’s, like, totally compatible with the existing design around Kubernetes objects,” Douglas said.

KYAML is a strict subset of YAML. All KAYML files are also valid YAML, and they can be used to write manifests and Helm charts, with no additional flags for K8s.

If included in Kubernetes 1.34 (still being finalized), KYAML will work with kubectl Kubernetes command line, which will output in KYAML with a special flag (i.e., kubectl get -o kyaml).

Here are the additional rules for KYAML.

  • Double-quotes are value strings.
  • Keys are unquoted unless potentially ambiguous.
  • Mappings (associative arrays) use braces {}.
  • Lists use brackets [].

These rules mimic JSON, though unlike JSON, KYAML supports comments and trailing commas and doesn’t need quoted keys.

Also, KYAML is not sensitive to white space.

Here is a sample provided by the proposal:

But I Still Hate It

As with any modified data format, the changes will be hotly contested. The developers anticipate this.

“Syntax has always been a magnet for arguments in our industry. We expect this to be no exception. Reasonable people will disagree with our choices, which is fine, but we should hold a strong opinion on this,” the developers warned in the ReadMe file, originally authored by Tim Hockin.

And the reactions are coming in already.

“It’s better than JSON, and I see why this is better than YAML, but I still hate it,” one user on Reddit wrote.

A quick search has shown that at least one programming-language-specific implementation of KYAML has been made for the Go programming language.

Other approaches have been taken, including the stripped-down StrictYAML, though KYAML has a fast track in the new Kubernetes version. Let’s see where else it can be used.

Kubernetes 1.34 is expected to be released in late August. 

Group Created with Sketch.