argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.55k stars 5.35k forks source link

Namespace "x" for Object "y" is not managed. #9893

Open flightofthunder opened 2 years ago

flightofthunder commented 2 years ago

Checklist:

Describe the bug

I am setting up an ArgoCD server (using the ArgoCD operator on OpenShift) with multiple clusters. I currently only have a single app that is deployed to two namespaces via two ArgoCD applications. The app health is stuck in a Missing status, sync status is Unknown , and the app conditions report 1 error.

Namespace "x" for Object "y" is not managed.

The namespaces have the appropriate labels, e.g. argocd.argoproj.io/managed-by.

To Reproduce

As far as I know, I am using ArgoCD as designed. I was able to deploy to similar namespaces on a seperate instance with a near identical setup.

Expected behavior

Screenshots

image

Version

argocd: v2.3.4+unknown
  BuildDate: 2022-05-16T13:41:14Z
  GitCommit: 
  GitTreeState: clean
  GoVersion: go1.17.7
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.3.4+unknown
  BuildDate: 2022-05-16T13:41:14Z
  GitCommit: 
  GitTreeState: clean
  GoVersion: go1.17.7
  Compiler: gc
  Platform: linux/amd64
crenshaw-dev commented 2 years ago

I could be way, way off here, but I think I recall seeing that error message when I had a cluster configured to manage a certain list of namespaces, and an Application had a resource which wasn't in that list. I fixed it by editing the cluster secret via the UI to include the target namespace.

flightofthunder commented 2 years ago

Hi @crenshaw-dev, thanks for your reply. Unfortunately this did not help as I am unable to modify the cluster secret via the UI.

What did help was modifying the cluster URL. I have configured multiple clusters with the same URL, this is because of the way ArgoCD manages clusters (e.g. 1 cluster = 1 secret, 1 credential), and these mutiple clusters are configured with different credentials to access different namespaces on the same cluster. So unfortunately I guess there was some sort of confusion on the cluster level, even bugging out the UI because the main identifier URL (so it would randomly switch which cluster I was looking at every second).

Anyways, I ended up making the URL "unique" by adding some URL parameters, in my case I did:

https://cluster.com:port?__ns=mynamespace1
https://cluster.com:port?__ns=mynamespace2
https://cluster.com:port?__ns=mynamespace3

and so forth.

The issue still stands as the documentation is inadequate.

wtam2018 commented 2 years ago

There is some more documentation. https://argocd-operator.readthedocs.io/en/latest/usage/custom_roles/ Do you see any errors from the Argo CD UI?

Alceatraz commented 2 years ago

I ran into this issue, But If I use another cluster, Everything just find. But most wired is, There are two already deployed namespace can sync with argo, But anyothers will show this error. How to provide logs to help solve this issue ?

cheqrouni commented 5 months ago

Hello any update for this issue. Thank you!

Invincibear commented 2 months ago

In my case, I needed to add a label to the Namespace which was created outside of Argo CD.

apiVersion: v1
kind: Namespace
metadata:
  labels:
    argocd.argoproj.io/managed-by: argocd
    kubernetes.io/metadata.name: my-namespace
  name: my-namespace
# https://registry.terraform.io/providers/alekc/kubectl
resource "kubernetes_namespace" "revelator_sales" {
  depends_on = [azurerm_kubernetes_cluster.foundation]

  metadata {
    name = "my-namespace"

    labels = {
      "argocd.argoproj.io/managed-by" = kubectl_manifest.argocd.namespace # resolves to "argocd"
    }
  }
}