Slides used for the introduction to my Birds of a Feather session at KubeCon EU in Berlin. A discussion of various approaches to using programming languages to configure Kubernetes rather than writing the raw data.
Gareth Rushgrove Brian Grant, Google, Kubernetes Config SIG “We've had a few complaints that YAML is ugly, error prone, hard to read, etc. Are there any other alternatives we might want to support?
The language to represent the data should be a simple, data-only format such as JSON or YAML, and programmatic modification of this data should be done in a real programming language Gareth Rushgrove Borg, Omega, and Kubernetes, ACM Queue, Volume 14, issue 1 http://queue.acm.org/detail.cfm?id=2898444 “
(without introducing more risk) Gareth Rushgrove A REPL for Kubernetes $ ./kubeplay kubeplay (namespace="*")> pods # list pods in the cluster
kubeplay (namespace="*")> @pod = _.any # pick a random pod from the list kubeplay (namespace="*")> puts @pod.to_json # output the pod definition { "metadata": { ... }, "spec": { ... "containers": [ {
(without introducing more risk) Gareth Rushgrove Ruby based DSL @metadata = replicasets("*/").to_ruby.items.map do |k,v| v.metadata end @metadata.each do |i| puts "Name:\t#{i.name}" puts "Labels:\t#{i.labels}" puts end
(without introducing more risk) Gareth Rushgrove Terraform provider resource "kubernetes_resource" "mypod" { # Required, must link on the corresponding "kubernetes_cluster" data s cluster = "${data.kubernetes_cluster.main.cluster}" collection = "pods" name = "mypod" labels { a = "b" } }