
ArgoCD sits between your version control system (such as GitHub) and your Kubernetes or OpenShift clusters and is used to create resources (such as deployments, pods, services, routes, config maps and secrets) in a particular namespace in your Kubernetes or OpenShift clusters. Almost always, this means you will have YAML files for your various Kubernetes or OpenShift resources in your version control system, such as YAML files for your Kubernetes or OpenShift deployments, YAML files for your Kubernetes or OpenShift secrets, YAML files for your Kubernetes or OpenShift services, et cetera, and ArgoCD will create the corresponding resources in your Kubernetes or OpenShift clusters using the YAML files in your version control system. ArgoCD will also ensure the resources on your Kubernetes or OpenShift clusters remain in sync with their corresponding YAML files in your version control system.

When attempting to create an application in a specific namespace on a specific Kubernetes or OpenShift cluster, you may need to configure the namespace with the argocd.argoproj.io/managed-by=<the namespace ArgoCD is in> label. Supposedly this is needed to allow ArgoCD to manage resources such as deployments, pods, services, et cetera in namespaces outside of the namespace ArgoCD is in.
This can be done:
- Create the application using a YAML file and include the argocd.argoproj.io/managed-by label
- Using the oc label namespace command
For example, let's say you have the following YAML file. Notice in this example that the YAML includes the argocd.argoproj.io/managed-by label.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
labels:
app.kubernetes.io/part-of: argocd
namespace: my-namespace
name: my-app
namespace: openshift-gitops
spec:
destination:
name: onprem-dev
namespace: my-namespace
project: my-project
source:
path: my-files
repoURL: https://github.com/foo/bar.git
targetRevision: main
syncPolicy:
managedNamespaceMetadata:
labels:
argocd.argoproj.io/managed-by: openshift-gitops
syncOptions:
- CreateNamespace=true
Or the kubectl (Kubernetes) or oc (OpenShift) label command can be used to label the namespace. In this example openshift-gitops is used because ArgoCD is in the openshift-gitops namespace.
~]$ oc label namespace my-project argocd.argoproj.io/managed-by=openshift-gitops
namespace/my-project labeled
The kubectl (Kubernetes) or oc (OpenShift) describe namespace command can be used to determine if the namespaces on your target Kubernetes or OpenShift cluster has been configured to be managed by ArgoCD.
~]$ oc describe namespace my-project
Name: my-project
Labels: argocd.argoproj.io/managed-by=openshift-gitops
kubernetes.io/metadata.name=my-project
pod-security.kubernetes.io/audit=baseline
pod-security.kubernetes.io/audit-version=v1.24
pod-security.kubernetes.io/warn=baseline
pod-security.kubernetes.io/warn-version=v1.24
Did you find this article helpful?
If so, consider buying me a coffee over at