Events / News / Technology /

Heptio Comes Out of Stealth Mode with a Kubernetes Configuration Tool, ksonnet

6 Jun 2017 1:00am, by

Deploying the Kubernetes container orchestration is about to get a lot easier, according to Craig McLuckie, the founding member of the Kubernetes open source project. McLuckie, who started the project at Google along with Joe Beda, co-founded Heptio six months ago with Beda to make Kubernetes more accessible. The company popped out of stealth mode at the GlueCon develop conference last month with its launch of the ksonnet Kubernetes configuration tool.

ksonnet was designed to help automate the modeling and management of complex Kubernetes deployments “in a way that is easy to share and reuse,” said Daniel Lopez, CEO and co-founder, Bitnami, which was part of the team collaborating on ksonnet, along with Box, Microsoft, and container software provider Deis (which Microsoft is acquiring).

Beyond Good Engineering

McLuckie explained that Kubernetes was created by system engineers, for system engineers. As such, it has been hard for developers who are not hard-core systems engineers to gain access.

Kubernetes is a platform with a tremendous amount of potential and is still really new, said Sam Ghods, Box services architect and co-founder, and a contributor to ksonnet. “Once you have the platform, you need ways of interacting with that platform. Ksonnet is just the next step forward in working with this platform.”

On his blog, Beda acknowledged that Kubernetes, which is now managed by the Cloud Native Computing Foundation, can be intimidating. “In particular, new users are often faced with a ‘wall of YAML’ when configuring systems running on Kubernetes,” he said.

“We view ksonnet as not just the code that gets deployed,” he explained, “but the entire experience of how I author it, how do I work with it, how do I work across teams.”

The Experience Breakdown

There are two pieces to the ksonnet experience. First, ksonnet offers a configurable, typed templating system for the Kubernetes application developer. “It’s a library of domain-specific helpers for dealing with the Kubernetes API in Jsonnet that gives you building blocks to work with,” Beda explained. Jsonnet is a data templating language for formatting JSON data.

Beda offers an analogy: There is the JavaScript language, then there are frameworks that allow you to use JavaScript in a structured way. The ksonnet library (ksonnetlib) is a way to use Jsonnet in a structured way for building Kubernetes configurations.

The second piece that flew under the radar at Gluecon, but was called out on Twitter is the inclusion of a Visual Studio Code extension for Jsonnet. ksonnet includes a VSCode extension and a simple website for experimentation.

“This gives you all the stuff you expect from a modern development environment like help functions,” said Beda, “to really make it easier to author these things without having to use copy/paste everywhere, as is what is happening how.”

“You can start with a community provided template and quickly edit it to support your needs,” he said, “parameterize out things that change from environment to environment, and tie it back into your favorite package management tool (like Deis Helm).”

The Jsonnet Connection

Jsonnet is “a purely-functional, Turing-complete language that is compatible with JSON,” explained Beda. Dave Cunningham, Google engineer open sourced the Jsonnet project and Beda said there are quite a few people who are using it to manage Kubernetes configurations. They are doing so, he said, with varying degrees of success. Below is an example of code for a whiskey sour in Jsonnet:

{
  cocktails: {
    “Whiskey Sour”: {
      ingredients: [
        { kind: “Bourbon”, qty: 1.5 },
        { kind: “Lemon Juice”, qty: 1 },
        { kind: “Gomme Syrup”, qty: 0.5 },
      ],
      garnish: “Lemon Peel”,
      served: “Straight Up”,
    },
    “Whiskey Sour With Egg”: 
      self[“Whiskey Sour”] + {
        Ingredients: super.ingredients
          + [{ kind: “Egg White”, qty: 0.5 }],
    },
  },
}

Jsonnet was inspired by inspired by Google Configuration Language (GCL), which is how most groups inside Google describe the company’s Borg configurations. GCL is still internal to Google because it has some bugs that haven’t been worked out, Beda explained.

So there’s a parallel between Google’s Borg and Kubernetes and GCL and Jsonnet, he explained. Jsonnet is super useful, but like a lot of languages, you can use it in a structured way or an unstructured way.

If you’re using Jsonnet in an unstructured way, Beda said, you don’t see all the power and composability that you want. Ksonnet helps you use Jsonnet is a useful way. One of the big advantages you get out of using ksonnet is a level of composition that people have had a hard time achieving before.

Combining elements was error prone and took a lot of code, creating what many users have described as “The Wall of YAML.” The ksonnetlib makes it easier to have different teams describe different elements and then combine them together in structured ways with ease. For example, this is the code for the same whiskey sour in ksonnet:

Log team:
logTailer::
  util.mapContainers(
    function(podContainer)
      podContainer +
      container.volumeMounts([
        logTailerVolumeMount
      ])
  ) +
  deployment.mixin.podSpec.volumes(
    logTailerVolume)
App Team:
local nginxContainer =
  container.default(
    “nginx”, “nginx:1.13.0”) +
  container.ports(
    containerPort.named(“http”, 80));
 
deployment.default(
  “nginx”, nginxContainer) +
deployment.mixin.spec.replicas(3) +
sidecar.logTailer
Here is output:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: nginx
  namespace: default
spec:
  replicas: 3
  template:
    spec:
      containers:
        – image: ‘nginx:1.13.0’
          name: nginx
          ports:
            – containerPort: 80
              name: http
          volumeMounts:
            – mountPath: /var/applogs
              name: logTailerVolume
      volumes:
        – name: logTailer
          persistentVolumeClaim:
            claimName: logTailerVolumeClaim

 

Beyond the Whiskey Sour: Box

Box was a very early adapter of Kubernetes. As its use of Kubernetes has expanded, it got much harder to manage all the configuration, Ghods said. Box recently launched their own infrastructure project: the kube-applier. The company’s engineers leaped at the chance to work with Heptio and are thrilled with ksonnet.

“At Box our value is to provide software,” he said. “Our customers want us to run on their preferred service and Kubernetes gives us that flexibility to allow Box to run on any platform.” And ksonnet is making it easier for developers to make that happen.

Because Kubernetes can be run anywhere, the specifications are very robust and using objects can be overwhelming for new users, he explained. Ksonnet makes composing Kubernetes objects much easier, which makes it a lot easier to get started and to use in general.

As you have more and more Kubernetes objects running your infrastructure, Ghods explained, the complication becomes exponential. Ksonnet abstracts the complications away and creates reusable code.

“This makes it way easier for application developers to write and manage the specifications for Kubernetes architecture,” he said. “It’s helping us start to develop a standard for developing Kubernetes objects in a way that’s a lot more usable than it is today.”

For the first time, he explained, a developer can write one specification in ksonnet and have that app work on any cloud Kubernetes runs on. “It doesn’t matter where the app is located, in AWS, bare metal, IBM Cloud, Google Cloud, Open Stack, it doesn’t matter.”

Declarative Configuration

“The pipeline and toolchain is being developed as we speak,” Ghods said.

Box launched the kube-applier just last month, which brings declarative configuration to Kubernetes. It basically takes Kubernetes objects and synchronizes them to the Kubernetes API server. And that actually works hand-in-hand with ksonnet.

The new flow is a developer writes and generate specifications from JSON in ksonnet, then kube-applier can pick up the JSON language and apply it to the API server so it can run it wherever it needs to be run.

“So it makes it really easy for developers to write specs and deploy them to the API server,” said Ghods. “All the pieces are falling into place.”

The Cloud Native Computing Foundation is a sponsor of The New Stack.

Feature image via Pixabay.


A digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.