TL;DR: Templating in Kubernetes is an important topic and is in the process of being standardized.
In Kubernetes you've got a powerful way of expressing the desired state, be it for applications or global resources such as network attached volumes. These documents, typically written in YAML, declare what you want and by using kubectl
you can submit them to the API Server, which in turn takes care of reconciling the current state with what you desire. After this mouthful, let's have a look at a concrete example of a deployment spec:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: sise-deploy
spec:
replicas: 2
template:
metadata:
labels:
app: sise
spec:
containers:
- name: sise
image: mhausenblas/simpleservice:0.5.0
ports:
- containerPort: 9876
env:
- name: SIMPLE_SERVICE_VERSION
value: "0.9"
As you can see in above listing, there are certain values that you may wish to change, depending on the environment or stage you're in. For example, rather than hard-coding the value 0.9
for the environment variable SIMPLE_SERVICE_VERSION
in the YAML file, you might want to override it when you execute kubectl apply
or let Kubernetes fill it in automatically. This is a limitation of the current way specs (and kubectl
) work.
The community has realized this limitation—cf. Issue 11492—and is working on a solution. An important step in this direction is the design proposal Templates+Parameterization: Repeatedly instantiating user-customized application topologies and Issue 23896.
In the meantime, various groups and companies were working hard to come up with a few solutions on their own, including but not limited to (in alphabetical order, both templating languages and tooling):
- Ansible Kubernetes module
- Helm Charts, initially mainly by Bitnami and Deis (now: Microsoft)
- Forge by Datawire.io
- k8comp by cststack
- kedge by Red Hat
- kdeploy by Flexiant
- kpm by Coreos (note: no longer developed or maintained)
- ksonnet/kubecfg by Bitnami and Heptio
- ktmpl by InQuicker
- kubeapps.com by the Kubernetes community
- kubegen by Ilya Dmitrichenko of Weaveworks
- OpenCompose by Red Hat
- OpenShift Templates by Red Hat
- Puppet Kubernetes modul by Gareth Rushgrove of Puppet
- Yipee.io by Yipee.io
If you're interested in contributing I'd like to encourage you to join us in the Apps Special Interest Group to share your use case, your criticism and feedback to what has been achieved so far, and help shape the final outcome.
Kudos to my colleague Mike Hepburn who provided valuable input for this post as well as Antoine Legrand whose Apps SIG mailing list post I've used as the starting point for this blog post. Last but not least, thanks to Brian Grant who pointed out his listing of tools in the context of Issue 23896.
About the author
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit