Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
feat: add-example-custom-crd and update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul committed Jul 19, 2021
1 parent 77b1279 commit e4588a6
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 3 deletions.
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
# template-operator
# Template Operator

<!-- markdownlint-disable-next-line MD036 -->
**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

An example replicating the functionality of https://github.com/pusher/quack
- **100% YAML**`Templates` 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][crossplane] | Complex due to design for infrastructure composition |
| [kyverno][kyverno] | Webhook based<br />Designed as a policy engine |
| [helm][helm] | Not 100% YAML<br />Not reconciliation based (build time) |

[crossplane]: https://crossplane.io/ "Crossplane"
[kyverno]: https://kyverno.io/ "Kyverno"
[helm]: https://helm.sh/ "Helm"

## Installation

API documentation available [here](https://pkg.go.dev/github.com/flanksource/template-operator/api/v1).

### Prerequisites

This guide assumes you have either a [kind cluster](https://kind.sigs.k8s.io/docs/user/quick-start/) or [minikube cluster](https://minikube.sigs.k8s.io/docs/start/) running, or have some other way of interacting with a cluster via [kubectl](https://kubernetes.io/docs/tasks/tools/).

### Install

```bash
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>

```yaml
apiVersion: templating.flanksource.com/v1
Expand All @@ -27,7 +69,8 @@ spec:
- "{{.source.spec.rules[0].host}}.{{- kget "cm/quack/quack-config" "data.domain" }}"
```
An example replicating https://github.com/redhat-cop/namespace-configuration-operator
An example replicating <https://github.com/redhat-cop/namespace-configuration-operator>
```yaml
apiVersion: templating.flanksource.com/v1
kind: Template
Expand Down
59 changes: 59 additions & 0 deletions examples/tutorial-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file is for use by blogposts and examples
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: tutorialservices.tutorial.tutorial
spec:
group: tutorial.tutorial
names:
kind: TutorialService
listKind: TutorialServiceList
plural: tutorialservices
singular: tutorialservice
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: TutorialService is the Schema for the tutorialservices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: TutorialServiceSpec defines the desired state of TutorialService
properties:
domain:
type: string
image:
type: string
replicas:
type: integer
required:
- domain
- image
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

0 comments on commit e4588a6

Please sign in to comment.