Skip to content

Provide actual schema for Kubernetes CustomResourceDefinition of TridentBackendConfig #964

@ergonben

Description

@ergonben

Thanks for working on NetApp Trident.

Currently, the CustomResourceDefinition for kind TridentBackendConfig has no actual schema:

schema:
  openAPIV3Schema:
    type: object # That is, anything goes.
    x-kubernetes-preserve-unknown-fields: true

As I understand, this is to accommodate for the variety of backend storage platforms.

However, it should be possible to express this variety in OpenAPI, using constructs such as anyOf, array, enum, etc.

The benefits would be a precise documentation of the config (addressing #861) and automatic validation, promoting the Kubernetes integration.

Describe the solution you'd like

A CustomResourceDefinition with a schema along these lines (obviously not ready but you get the idea):

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tridentbackendconfigs.trident.netapp.io
spec:
  versions:
    - name: v1
      schema:
        openAPIV3Schema:
          type: object
          properties:
            apiVersion:
              type: string
            kind:
              type: string
            metadata:
              type: object
            spec:
              type: object
              properties:
                version:
                  type: integer
                storageDriverName:
                  type: string
                backendName:
                  type: string
                managementLIF:
                  type: string
                dataLIF:
                  type: string
                svm:
                  type: string
                autoExportPolicy:
                  type: boolean
                autoExportCIDRs:
                  type: array
                  items:
                    type: string
                credentials:
                  type: object
                  properties:
                    name:
                      type: string

Describe alternatives you've considered

As an alternative, the schema could be partially refined. Meaning some fields may still be intentionally left flexible using type: object if an OpenAPI specification is not possible or too complex.

Additional context

On a tangent, having a schema would support the use of the official Terraform Kubernetes provider. Without a schema, the provider tries to replace TridentBackendConfigs on every Terraform apply operation, even if nothing has changed. Such a replacement does does not terminate (unless there are no PersistentVolumes on the TridentBackend), forcing the user to abort the apply operation, which leaves the TridentBackendConfig in state "Deleting" – clearly undesired. For more details about this symptom, see hashicorp/terraform-provider-kubernetes#1382.

More about CustomResourceDefinition.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions