kedacore / charts

Helm charts for KEDA
Apache License 2.0
178 stars 242 forks source link

No matches for kind "ClusterTriggerAuthentication" if this CRD is referenced in extraObjects #513

Open abdul-jabbar01 opened 1 year ago

abdul-jabbar01 commented 1 year ago

If I am referring ClusterTriggerAuthentication with extraObjects, it gives following error

Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "ClusterTriggerAuthentication" in version "keda.sh/v1alpha1"

It works with following workaround:

But this is not the ideal workaround. It makes automation difficult (installing via pipelines)

Expected Behavior

It should first install CRDs and then run 99-extra-manifests.yaml for extraObjects

Actual Behavior

It is installing extraObjects first before installing CRDs

Steps to Reproduce the Problem

  1. Download KEDA chart 2.11.0 from here
  2. Update keda/values.yaml to include following
    extraObjects:
    - apiVersion: v1
    kind: Secret
    metadata:
      name: keda-datadog-secrets
      namespace: keda
    type: Opaque
    data:
      apiKey: "xxxxxx"
      appKey: "xxxxxx"
      datadogSite: "xxxxxx"
    - apiVersion: keda.sh/v1alpha1
    kind: ClusterTriggerAuthentication
    metadata:
      name: keda-cluster-trigger-auth-datadog
    spec:
      secretTargetRef:
        - parameter: apiKey
          name: keda-datadog-secrets
          key: apiKey
        - parameter: appKey
          name: keda-datadog-secrets
          key: appKey
        - parameter: datadogSite
          name: keda-datadog-secrets
          key: datadogSite
    1. Then install keda with helm upgrade --install keda kedacore/keda -f values.yaml --namespace keda
    2. Then it should give above mentioned error.

Specifications

pierluigilenoci commented 1 year ago

FYI https://github.com/helm/helm/issues/12653

noizo commented 1 month ago

Hi @abdul-jabbar01

I used terraform helm_resource and depends_on where first one is Keda helm charts, and second is only a TriggerAuthentication definition.

resource "helm_release" "keda" {
  name       = "keda"
  repository = "https://kedacore.github.io/charts"
  chart      = "keda"
  version    = var.keda_version
  namespace  = var.namespace
  wait       = true
}

And i created a custom helm chart with only datadog-auth definition:

resource "helm_release" "trigger_authentication" {
  depends_on = [helm_release.keda, kubernetes_secret.datadog]
  name       = "datadog-auth"
  namespace  = var.namespace
  chart      = "${path.module}/extras/datadog-auth"
  values = [
    yamlencode({
      namespace   = var.namespace
      secret_name = local.secret_name
    })
  ]
}

Module has this structure:

├── README.md
├── data.tf
├── extras
│   └── datadog-auth
│       ├── Chart.yaml
│       ├── templates
│       │   └── trigger-auth.yaml
│       └── values.yaml
├── irsa.tf
├── kubernetes.tf
├── locals.tf
├── main.tf
└── variables.tf

And this custom chart template looks like that:

---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: {{ .Chart.Name }}
  namespace: {{ .Values.namespace }}
spec:
  secretTargetRef:
    - parameter: apiKey
      name: {{ .Values.secret_name }}
      key: api-key
    - parameter: appKey
      name: {{ .Values.secret_name }}
      key: app-key
    - parameter: datadogSite
      name: {{ .Values.secret_name }}
      key: dd-site

Of course it's not a solution to initial problem mentioned by @pierluigilenoci , but it will allow you to install everything in one run with ci/cd tools.