faros
faros copied to clipboard
Add Namespace defaulting
If we parse a file that has no namespace set, it should default to the namespace that the controller is running in (if restricted to a namespace) or to the default
namespace if Faros is running cluster wide
To accommodate this I would recommend adding an optional field like defaultNamespace
to the GitTrack
spec. If defaultNamespace
is not specified then the resource should not apply. That said, the philosophy of the GitOps pattern is to apply exactly what is in git
to the cluster without modification. I would not want the default behavior to start applying resources in the current (or default
) namespace.
To accommodate this I would recommend adding an optional field like
defaultNamespace
to theGitTrack
spec.
I don't think this is necessary as there is a --namespace
flag for the controller itself which would define the behaviour. If the --namespace
flag is empty then the controller operates across all namespaces and would default resources with namespace: ""
to namespace: "default"
(this is the behaviour of kubectl
.
If the controller --namespace
flag is set, then this is the same as setting the default context for kubectl
, and so it would default resources with namespace: ""
to whichever namespace is set by the flag.
In the GitOps model this shouldn't be necessary as people should be setting the namespace
field in their YAML but it could be a nice feature to have (to match kubectl behaviour).
That said, the philosophy of the GitOps pattern is to apply exactly what is in
git
to the cluster without modification.
I'm not sure I entirely agree with this, most GitOps controllers I have seen fork out to kubectl
for applying resources to clusters, leveraging kubectl apply
s three way merging. In this case, the namespace defaulting would occur anyway.
I would not want the default behavior to start applying resources in the current (or
default
) namespace.
I think it would be best to make this the default behaviour at the controller level but have a flag that could disable it and cause namespaces with no namespace
to be considered invalid
Thanks for the detailed response. I think you made a strong case for --namespace
being sufficient.