Skip to content

Enhance defaulting of spec.dataSinkRef #30

@maximiliantech

Description

@maximiliantech

Description

With #27 @mirzakopic introduced the configurability of a data sink (e.g. Dynatrace) via the DataSink CRD that serves kind of like Crossplane's ProviderConfig.

The deployed DataSink CR can be referenced via the spec.dataSinkRef field in the respective metric CRDs of the api/v1alpha1/ package. This field is always an optional field, see

// DataSinkRef specifies the DataSink to be used for this metric.
// If not specified, the DataSink named "default" in the operator's
// namespace will be used.
// +optional
DataSinkRef *DataSinkReference `json:"dataSinkRef,omitempty"`

The controller already resolves the defaulting behaviour of dataSinkRef automatically in code, see

// Determine DataSink name
dataSinkName := "default"
if dataSinkRef != nil && dataSinkRef.Name != "" {
dataSinkName = dataSinkRef.Name
}

Problem

For me as an end user who just uses the API/CRDs, I don't see this defaulting behaviour right from the beginning. It would be nice to see the defaulting mechanism also reflected in the applied CR.

Example

After applying the following resource via kubectl apply -f ...

apiVersion: metrics.cloud.sap/v1alpha1
kind: Metric
metadata:
  name: basic-total-pods
spec:
  name: pods-metric-total
  description: Pods
  target:
    kind: pod
    group: ""
    version: v1
  interval: 1m

the kube apiserver should default spec.dataSinkRef automatically like so:

apiVersion: metrics.cloud.sap/v1alpha1
kind: Metric
metadata:
  name: basic-total-pods
spec:
  name: pods-metric-total
  description: Pods
  target:
    kind: pod
    group: ""
    version: v1
  interval: 1m
  dataSinkRef:
    name: default # spec.dataSinkRef gets automatically defaulted

Proposal

Using Kubebuilders CRD Validation mechanism to automatically default spec.dataSinkRef while applying one of the metric CRs at a K8s cluster.

Metadata

Metadata

Assignees

Labels

area/providerAll Provider related issuesenhancementNew feature or requestgood first issueNew to this repo? This is a good place to startkind/feature-requestFeature request from any stakeholder

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions