template-operator

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

README

Template Operator

Simple, reconciliation-based runtime templating

The Template Operator is for platform engineers needing an easy and reliable way to create, copy and update kubernetes resources.

Design principles

  • 100% YAMLTemplates are valid YAML and IDE validation and autocomplete of k8s resources works as normal.
  • Simple – Easy to use and quick to get started.
  • Reconciliation based – Changes are applied quickly and resiliently (unlike webhooks) at runtime.
Alternatives

There are alternative templating systems in use by the k8s community – each has valid use cases and noting the downsides for runtime templating is not intended as an indictment – all are excellent choices under the right conditions.

Alternative Downside for templating
crossplane Complex due to design for infrastructure composition
kyverno Webhook based
Designed as a policy engine
helm Not 100% YAML
Not reconciliation based (build time)

Installation

API documentation available here.

Prerequisites

This guide assumes you have either a kind cluster or minikube cluster running, or have some other way of interacting with a cluster via kubectl.

Install
export VERSION=0.2.0
# For the latest release version: https://github.com/flanksource/template-operator/releases

# Apply the operator
kubectl apply -f https://github.com/flanksource/template-operator/releases/download/v${VERSION}/operator.yml

Other examples

An example replicating the functionality of https://github.com/pusher/quack

apiVersion: templating.flanksource.com/v1
kind: Template
metadata:
  name: dynamic-ingress-hostnames
spec:
  onceoff: true # need to set this flag as otherwise it will trigger an endless loop appending the domain to iteself.
  namespaceSelector:
     quack.pusher.com/enabled: "true"
  objectSelector:
    - apiVersion: extensions/v1beta1
      kind: Ingress
  patches:
    - spec:
        rules:
            # append a dynamic domain specified in a configmap to the domain specified in the ingress
          - host: "{{.source.spec.rules[0].host}}.{{-   kget "cm/quack/quack-config" "data.domain" -}}"
            tls:
              hosts:
                -  "{{.source.spec.rules[0].host}}.{{-   kget "cm/quack/quack-config" "data.domain" }}"

An example replicating https://github.com/redhat-cop/namespace-configuration-operator

apiVersion: templating.flanksource.com/v1
kind: Template
metadata:
  name: dcp-on-demand
  namespace: kube-system
spec:
  labelSelector:
    matchLabels:
      owner: dh-dcp
  resources:
    - kind: RoleBinding
      apiVersion: rbac.authorization.k8s.io/v1
      metadata:
        name: creator
      subjects:
        - kind: Group
          name: Owner
          apiGroup: rbac.authorization.k8s.io
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: namespace-admin

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1
Package v1 contains API Schema definitions for the templating.flanksource.com v1 API group +kubebuilder:object:generate=true +groupName=templating.flanksource.com
Package v1 contains API Schema definitions for the templating.flanksource.com v1 API group +kubebuilder:object:generate=true +groupName=templating.flanksource.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL