foo-binding

module
v0.0.0-...-4dab0f8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: Apache-2.0

README

Experimental FooBinding type

This repo contains a proof-of-concept controller that uses Knative duck-typing to perform "binding" akin to Service Bindings in Cloud Foundry.

This repository defines a trivial FooBinding CRD, which looks like:

apiVersion: bindings.mattmoor.dev/v1alpha1
kind: FooBinding
metadata:
  name: test-binding
spec:
  # This defines the target resource into which we will inject the binding.
  target:
    apiVersion: apps/v1
    kind: Deployment
    name: debug

  # This defines the trivial payload that we will inject.
  value: OMFG it works

This will direct the binding controller to inject an environment variable as-if the user had written the following in their K8s deployment:

env:
- name: FOO
  value: OMFG it works

Extensibility

This controller works with any resource that implements the "pod speccable" duck type, which means it follows the common shape of embedding a pod spec at .spec.template.spec. To enable it on new types you first must give the binding controller access by expanding the aggregated cluster role:

# This piece of the aggregated cluster role enables us to bind to
# Knative serving resources
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: binding-system-knative-serving
  labels:
    bindings.mattmoor.dev/controller: "true"
rules:
  - apiGroups: ["serving.knative.dev"]
    resources: ["services", "configurations"]
    verbs: ["get", "list", "patch", "watch"]

After that, you can start to use bindings with the new resource types:

apiVersion: bindings.mattmoor.dev/v1alpha1
kind: FooBinding
metadata:
  name: test-binding
spec:
  # This defines the target resource into which we will inject the binding.
  target:
    apiVersion: serving.knative.dev/v1
    kind: Service
    name: runtime

  # This defines the trivial payload that we will inject.
  value: OMFG it works with Knative Services too!!!!1!!

TODO

  • Teach the webhook to Do() the transformations so they are applied before the initial mutation lands in etcd.

  • Use this (in another repo) to implement a non-trivial binding, e.g. Sink injection akin to the knative/eventing ContainerSource.

Directories

Path Synopsis
cmd
pkg
apis/bindings/v1alpha1
+k8s:deepcopy-gen=package +groupName=bindings.mattmoor.dev
+k8s:deepcopy-gen=package +groupName=bindings.mattmoor.dev
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/bindings/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/bindings/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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