Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide actual schema for Kubernetes CustomResourceDefinition of TridentBackendConfig #964

Open
ergonben opened this issue Jan 20, 2025 · 0 comments

Comments

@ergonben
Copy link

ergonben commented Jan 20, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant