Repositories
v1v
Published by: Kubernetes2Updated

Extend Resources - v1 provides a CustomResourceDefinition (CRD) template to extend Kubernetes with custom resource types. This template enables users to define and manage CRDs efficiently, allowing seamless integration with the Kubernetes API. Built on a flexible, facet-based design with dynamic variable population, it simplifies CRD creation and lifecycle management while supporting diverse extension scenarios in Kubernetes environments

v1
|

Authentication

Add API authentication details

HEADERS
X-APIKEY
string
Send X-APIKEY in Header

Readme

User instructions for this resource

The CustomResourceDefinition (CRD) template in ConfigFacets is designed to facilitate the creation and management of Kubernetes CRDs, which are a powerful feature for extending Kubernetes with custom resources.

  1. Core Structure

The main section includes essential CRD fields:

{
  "kind": "CustomResourceDefinition",
  "spec": {
    "group": "{{ __CRD_ID__.spec.group }}",
    "names": {
      "kind": "{{ __CRD_ID__.spec.names.kind }}",
      "plural": "{{ __CRD_ID__.spec.names.plural }}",
      "singular": "{{ __CRD_ID__.spec.names.singular }}"
    },
    "scope": "{{ __CRD_ID__.spec.scope }}",
    "versions": "{{ __CRD_ID__.spec.versions }}"
  },
  "facets": ["master"],
  "metadata": "{{ __CRD_ID__.metadata }}",
  "apiVersion": "apiextensions.k8s.io/v1"
}

This core structure defines the API group, resource names, scope, and versions of the custom resource. These are crucial for integrating the new resource type into the Kubernetes API.

  1. Optional Features

The template includes separate sections for optional CRD features:

  • Short names: Allows defining aliases for the resource, making it easier to use in kubectl commands.

  • Conversion strategy: Useful when dealing with multiple versions of a CRD, enabling data conversion between versions.

  • Preserving unknown fields: Important for backward compatibility and extensibility of the custom resource.

  • Categories: Allows grouping custom resources with built-in resources for better organization.

  • List kind: Defines how lists of the custom resource should be named.

  1. Flexibility and Reusability

The __CRD_ID__ variable allows for dynamic population of CRD fields, making the template reusable for different custom resources.

  1. Modularity

The facet-based design allows users to include only the necessary components for their specific CRD, reducing complexity for simple use cases while allowing for advanced configurations when needed.

Examples

Check Request Body tab section to play around with interactive examples.

Install(Example)

The Curl tab in the request section below provides the curl command for your resource.

curl -s -X POST "https://configfacets.com/apis/repos/kubernetes/extend-resources/v1/resources/collections/customresourcedefinition/exec?format=json" -d '{"facets":["master"],"values":{"basic_crd":{"spec":{"group":"example.com","names":{"kind":"Widget","plural":"widgets","singular":"widget","shortNames":["wg"]},"scope":"Namespaced","versions":[{"name":"v1","schema":{"openAPIV3Schema":{"type":"object","properties":{"spec":{"type":"object","properties":{"size":{"type":"integer"},"color":{"type":"string"}}}}}},"served":true,"storage":true}]},"metadata":{"name":"widgets.example.com"}}},"globalvars":{"__CRD_ID__":"basic_crd"}}' | kubectl apply -f -
POST/apis/repos/kubernetes/extend-resources/v1/resources/collections/customresourcedefinition/exec
REQUEST
QUERY-STRING PARAMETERS
format
string
No sources available.
API Server https://configfacets.com
API Key
Not set
RESPONSES
No content available.