The Argo CD namespace operator helps creating the namespace for an Argo CD Application
CR.
Annotations on the Application
CR allow defining labels and annotations for the Namespace
CR. Special support is included for the Rancher field.cattle.io/projectId
label and annotation to define a namespace as part of a Rancher project.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: cert-manager
annotations:
argocd-namespace.topicus.nl/label: "certmanager.k8s.io/disable-validation: true"
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: cert-manager
server: https://kubernetes.default.svc
...
This Application
CR automatically created the following namespace:
apiVersion: v1
kind: Namespace
metadata:
name: cert-manager
labels:
certmanager.k8s.io/disable-validation: "true"
The Namespace Configuration Operator uses a (label)selector to select namespaces to which to apply its configuration. These labels can be supplied with the Argo CD namespace operator from the Application
CR.
See the T-shirt sized quotas example of the Namespace Configuration Operator.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-large-project
annotations:
argocd-namespace.topicus.nl/label: "size: large"
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: large-project
server: https://kubernetes.default.svc
...
The field.cattle.io/projectId
label and annotation binds a namespace to a Rancher project. The full Rancher project ID (including the cluster ID) can be supplied with the cattle.topicus.nl/projectId
annotation.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-project
annotations:
cattle.topicus.nl/projectId: c-xxxxx:p-yyyyy
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: rancher-project-namespace
server: https://kubernetes.default.svc
...
This creates the required Rancher label and annotation as follows:
apiVersion: v1
kind: Namespace
metadata:
name: rancher-project-namespace
annotations:
field.cattle.io/projectId: c-xxxxx:p-yyyyy
labels:
field.cattle.io/projectId: p-yyyyy