Skip to content

[Feature request] Strongly-typed fields for CRD #45

@ItalyPaleAle

Description

@ItalyPaleAle

Currently, the CRD used by this operator has a single property "value" which accepts anything (any JSON-serializable option).

We would like to propose a new version of the CRD (possibly v1alpha2 or v2alpha1?) which lists the allowed fields explicitly, including most (though not all) options that are allowed by the Dapr Helm chart today.

The proposed schema (which is based on Dapr 1.11 and is missing a few fields for 1.12):

spec:
  # Dapr version
  version: 'string; required'

  images:
    registry: 'string; defaults to "ghcr.io/dapr"'
    tag: 'string; defaults to the .version property'
    # For control-plane services and sidecars
    imagePullPolicy: 'string (ImagePullPolicy); defaults to "IfNotPresent"'
    imagePullSecrets: 'string'
  
  # Options for injected Dapr sidecars
  sidecars:
    # Full name of the Docker image for the Dapr sidecar.
    # This is used to override the default image when deploying sidecars, and it's useful for debugging.
    # Specifying a value here changes the ImagePullPolicy for sidecars to "Always". Otherwise, the sidecars' ImagePullPolicy is set to the same as `global.imagePullPolicy` (`IfNotPresent` by default).
    sidecarImage: 'string'
    runAsNonRoot: 'boolean; defaults to "true"'
    readOnlyRootFilesystem: 'boolean; defaults to "true"'
    # When enabled, the sidecar container has `securityContext.capabilities.drop: ["ALL"]`.
    dropAllCapabilities: 'boolean; defaults to "false"'
  
  # Options for the Dapr control plane
  controlPlane:
    logLevel: 'string; defaults to "info"'
    logAsJSON: 'boolean; defaults to "false"'
    os: 'string; defaults to "linux"'
    arch: 'string; defaults to "amd64"'
    enableMetrics: 'boolean; defaults to "true"'
    metricsPort: 'boolean; defaults to "9090"'
    tolerations: 'array of corev1.Toleration'
    seccompProfile: 'string'
    runAsNonRoot: 'boolean; defaults to "true"'
    operator:
      replicaCount: 'int; defaults to "1"'
      resources: 'kuberentes resources object'
      enableServiceReconciler: 'boolean; defaults to "false"'
    sentry:
      replicaCount: 'int; defaults to "1"'
      resources: 'kuberentes resources object'
      tokenAudience: 'string'
      trustDomain: 'string'
    placement:
      # If true, enables high-availability mode with 3 replicas.
      # Otherwise, a single replica is used.
      ha: 'boolean; defaults to "false"'
      resources: 'kuberentes resources object'
      # Only for HA mode
      cluster:
        inMemoryLog: 'boolean; defaults to "true"'
        logStorePath: 'string'
        logStorePathWindows: 'string'
      # Unused when HA mode is used and cluster.inMemoryLog is true
      volumeClaims: 
        storageSize: 'string'
        storageClassName: 'string'

  # Needs to be updated for Dapr 1.12
  mTLS:
    enabled: 'boolean; defaults to "true"'
    workloadCertTTL: 'string'
    allowedClockSkew: 'string'

  dnsSuffix: 'string; defaults to ".cluster.local"'

  # Additional options passed to Helm as-is.
  # Each option is passed as "--set" to Helm.
  # These are passed after any option built from the spec.
  additionalHelmOptions: 'array of strings'

The reconciler would then generate the Helm --set flags based on the values defined above in the CRD.

A benefit of using a CRD with strictly-defined fields is that it allows catching errors when the resource is deployed on K8s, before the reconciler is invoked. It also allows auto-completion in code editors, among other things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions