Skip to content

Source Hydrator not respecting namespace #25478

@Elyytscha

Description

@Elyytscha

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

if source hydrator is enabled, it somehow does not respect the namespace or better said used the argocd namespace

To Reproduce

  1. create a repo
  2. add this files
# apps/rancher-ui/chart.yaml

apiVersion: v2
name: rancher
version: 0.1.0

dependencies:
  - name: rancher
    version: 2.12.1
    repository: "https://releases.rancher.com/server-charts/stable"
    values:
      - values.yaml
# apps/rancher-ui/values.yaml
# Default values for rancher-ui.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
rancher:
  # # Override names to ensure RBAC resources are named correctly
  # # The Rancher chart expects the service account to be named 'rancher'
  # fullnameOverride: rancher
  
  # # Override namespace for RBAC subjects - required when using ArgoCD sourceHydrator
  # # because .Release.Namespace picks up 'argocd' instead of the destination namespace
  # namespaceOverride: cattle-system
  
  hostname: rancher.example.com
  1. use app like this
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: rancher-ui
  namespace: argocd
spec:
  destination:
    namespace: cattle-system
    server: https://kubernetes.default.svc
  project: default
  sourceHydrator:
    drySource:
      path: apps/rancher-ui
      repoURL: https://github.com/<your-repo>.git
      targetRevision: main
    syncSource:
      path: apps/rancher-ui
      targetBranch: env/prod
  syncPolicy:
    automated:
      enabled: true
      prune: true
      selfHeal: true
  syncOptions:
    createNamespace: true
  1. This will result in the following

branch: env/prod
file: apps/rancher-ui/manifest.yaml

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    app: rancher-ui
    chart: rancher-2.12.1
    heritage: Helm
    release: rancher-ui
  name: rancher-ui
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: rancher-ui
    namespace: argocd # <--------- expected cattle-system
---
...
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: rancher-ui
    chart: rancher-2.12.1
    heritage: Helm
    release: rancher-ui
  name: rancher-ui
spec:
  replicas: 3
  selector:
    matchLabels:
      app: rancher-ui
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: rancher-ui
        release: rancher-ui
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/os
                    operator: NotIn
                    values:
                      - windows
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values:
                        - rancher-ui
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - args:
            - --http-listen-port=80
            - --https-listen-port=443
            - --add-local=true
          env:
            - name: CATTLE_NAMESPACE
              value: argocd # <--------- expected cattle-system
...
---
apiVersion: v1
kind: ServiceAccount
metadata:
  annotations:
    helm.sh/hook: pre-upgrade
    helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
    helm.sh/hook-weight: "-1"
  labels:
    app: rancher-ui
    chart: rancher-2.12.1
    heritage: Helm
    release: rancher-ui
  name: rancher-ui-pre-upgrade
  namespace: argocd  # <--------- expected cattle-system

https://github.com/devops-magic/argo-cd-hydration-test/blob/bugreport/source-hydrator-not-respecting-namespace/apps/rancher-ui/manifest.yaml#L53

Expected behavior

namespace=cattle-system

Screenshots

Version

v3.3.0+0e68458.dirty

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponent:hydratorIssue related to the Source Hydrator and commit servertriage/pendingThis issue needs further triage to be correctly classified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions