Skip to content

Error whenever creating new secretStore (namespaced one) #3520

@pedrocrc

Description

@pedrocrc
  • Using version ghcr.io/external-secrets/external-secrets:v0.9.18

Every time I try to create a SecretStore (namespaced one), I get the error

admission webhook "validate.secretstore.external-secrets.io" denied the request: namespace not allowed with namespaced SecretStore

As an example, one yaml I've tried to apply was:

apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
  name: <name>
  namespace: <namespace1>
spec:
  provider:
    kubernetes:
      auth:
        serviceAccount:
          name: external-secrets-sa
          namespace: <namespace1>
      remoteNamespace: <namespace2>
      server:
        caProvider:
          key: ca.crt
          name: kube-root-ca.crt
          namespace: <namespace1>
          type: ConfigMap
        url: 'https://kubernetes.default'

I've checked that it is raised due to the following lines:

// ValidateSecretSelector just checks if the namespace field is present/absent
// depending on the secret store type.
// We MUST NOT check the name or key property here. It MAY be defaulted by the provider.
func ValidateSecretSelector(store esv1beta1.GenericStore, ref esmeta.SecretKeySelector) error {
clusterScope := store.GetObjectKind().GroupVersionKind().Kind == esv1beta1.ClusterSecretStoreKind
if clusterScope && ref.Namespace == nil {
return errRequireNamespace
}
if !clusterScope && ref.Namespace != nil {
return errNamespaceNotAllowed
}
return nil
}

The line 374 seems to me as a bug, since clusterScope will be false whenever the resource type is namespaced, and therefore it should have a related namespace.

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