Code Monkey home page Code Monkey logo

discovery's Introduction

Discovery API

This is Work in Progress.

Install

ko apply -f ./config

DuckType.discovery.knative.dev

The goal is to have a custom type that is use installable to help a developer, cluster admin, or tooling to better understand the duck types that are installed in the cluster. This information could be used to understand which Kinds could fulfill a role for another resource.

example.yaml

apiVersion: discovery.knative.dev/v1alpha1
kind: DuckType
metadata:
  name: addressable.duck.knative.dev
spec:
  # selectors is a list of CRD label selectors to find CRDs that have been
  # labeled as the given duck type.
  selectors:
    - selector: "duck.knative.dev/addressable=true"

  # refs allows for adding native types, or crds directly as the ducks via
  # Group/Version/Kind/Resource
  refs:
    - version: v1
      resource: services
      kind: Service

  # Names allows us to give a short name to the duck type.
  names:
    plural: addressables
    singular: addressable

  # additionalPrinterColumns is intended to understand what printer columns
  # should be used for the custom objects.
  additionalPrinterColumns:
    - name: Ready
      type: string
      JSONPath: ".status.conditions[?(@.type=='Ready')].status"
    - name: Reason
      type: string
      JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
    - name: URL
      type: string
      JSONPath: .status.address.url
    - name: Age
      type: date
      JSONPath: .metadata.creationTimestamp

  # schema is the partial schema of the duck type.
  schema:
    openAPIV3Schema:
      properties:
        status:
          type: object
          properties:
            address:
              type: object
              properties:
                url:
                  type: string

After applying this, you can fetch it:

$  kubectl get ducktypes addressable.duck.knative.dev
NAME                           SHORT NAME    DUCKS   READY   REASON
addressable.duck.knative.dev   addressable   11      True

And get the full DuckType addressable.duck.knative.dev resource:

$ kubectl get ducktypes addressable.duck.knative.dev -oyaml
apiVersion: discovery.knative.dev/v1alpha1
kind: DuckType
metadata:
  generation: 1
  name: addressable.duck.knative.dev
spec:
  additionalPrinterColumns:
  - JSONPath: .status.conditions[?(@.type=='Ready')].status
    name: Ready
    type: string
  - JSONPath: .status.conditions[?(@.type=='Ready')].reason
    name: Reason
    type: string
  - JSONPath: .status.address.url
    name: URL
    type: string
  - JSONPath: .metadata.creationTimestamp
    name: Age
    type: date
  names:
    plural: addressables
    singular: addressable
  refs:
  - kind: Service
    resource: services
    version: v1
  schema:
    openAPIV3Schema:
      properties:
        status:
          properties:
            address:
              properties:
                url:
                  type: string
              type: object
          type: object
  selectors:
  - selector: duck.knative.dev/addressable=true
status:
  conditions:
  - lastTransitionTime: "2020-01-16T22:13:24Z"
    status: "True"
    type: Ready
  duckCount: 11
  ducks:
  - group: eventing.knative.dev
    kind: Broker
    resource: brokers
    version: v1alpha1
  - group: flows.knative.dev
    kind: Parallel
    resource: parallels
    version: v1alpha1
  - group: flows.knative.dev
    kind: Sequence
    resource: sequences
    version: v1alpha1
  - group: messaging.knative.dev
    kind: Channel
    resource: channels
    version: v1alpha1
  - group: messaging.knative.dev
    kind: InMemoryChannel
    resource: inmemorychannels
    version: v1alpha1
  - group: messaging.knative.dev
    kind: Parallel
    resource: parallels
    version: v1alpha1
  - group: messaging.knative.dev
    kind: Sequence
    resource: sequences
    version: v1alpha1
  - group: n3wscott.com
    kind: Task
    resource: tasks
    version: v1alpha1
  - kind: Service
    resource: services
    version: v1
  - group: serving.knative.dev
    kind: Route
    resource: routes
    version: v1alpha1
  - group: serving.knative.dev
    kind: Service
    resource: services
    version: v1alpha1
  observedGeneration: 1

Knative Duck Types

If the ./condif/knative directory is applied, a quick view of the duck types that are on the cluster becomes easier to get:

$ kubectl get ducktypes
NAME                                 SHORT NAME     DUCKS   READY   REASON
addressable.duck.knative.dev         addressable    11      True
binding.duck.knative.dev             binding        2       True
podspecable.duck.knative.dev         podspecable    7       True
source.duck.knative.dev              source         7       True
subscribable.messaging.knative.dev   subscribable   2       True

discovery's People

Contributors

matzew avatar n3wscott avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.