Open kingdonb opened 2 years ago
Right now for flux logs, there are two namespace flags. --flux-namespace
(where the flux system is installed) and --namespace
flag (the namespace filter for the logs from objects).
When you configure FLUX_SYSTEM_NAMESPACE
(affects only --namespace), it serves as the default namespace filter, giving you logs from only objects in the namespace. If we are to default both flags to the FLUX_SYSTEM_NAMESPACE
,
It means that it will look for the flux-system components in that namespace AND still filter logs by that namespace
When you do:
export FLUX_SYSTEM_NAMESPACE=operator
flux logs
You will still no logs in the output if you don't have any flux custom resources in the operator
namespace. (the command, in this case, is getting the logs but filtering them out - maybe we should return an error if there are no pods).
@kingdonb is this the intended behaviour? I wanted to call it out before making any changes.
I think that FLUX_SYSTEM_NAMESPACE
should only affect the namespace where flux is installed. In other words, from your description I think it was implemented backwards. (Either that, or it should affect both namespaces.)
I think there might be some workshopping to do in order to make sure this works well, based on your reply. I wouldn't expect anyone to put their Flux custom resources in the operators
namespace, so the change I think I'm asking for will probably not fix everything without a bit more help.
Let's not change anything right away, as your reply helps clarify the issue for me 👍
I think it's OK to work towards a single variable that will work with flux bootstrap in a different namespace, rather than try to conform to how OperatorHub users might experience Flux if they use OLM and don't have OpenShift to manage the install so it winds up in the flux-system namespace.
Fundamentally that's probably 0.2% of users, if it even registers. I think that FLUX_SYSTEM_NAMESPACE
should probably change both, so if someone's Flux installation was in the operators
namespace and they put their flux-system there too, it would work for them. I'm not in favor adding a second variable because it seems unnecessarily complicated. But if we think about how people will use this in multi-tenant Flux environments, there might be some cases where my gotk-components are in flux-system
and my workloads are in tenant-ns
, and you'd want to be able to set up some environment variables so that flux logs
returned relevant information for you. I don't know how you can get there without making it two variables.
Here's some better debugging information. If I set FLUX_SYSTEM_NAMESPACE=operators
and run flux bootstrap
, I should get reasonable behavior from flux logs
after that.
It only works if I call it like: flux logs --flux-namespace operators
That seems broken. It's also something else interesting, I noticed that it doesn't just change the namespace, when you set FLUX_SYSTEM_NAMESPACE
before bootstrap, it also changes the name of the gitrepository and kustomization to match
So I got a Kustomization called operators
in my operators
namespace, and a gitrepository called operators
I would have expected those to remain called flux-system
– the secret is still called flux-system
$ export FLUX_SYSTEM_NAMESPACE=operators
$ flux bootstrap github --interval 10s --owner kingdonb --personal --repository bootstrap-repo --branch staging --path=clusters/demo-cluster-1
Please enter your GitHub personal access token (PAT):
► connecting to github.com
► cloning branch "staging" from Git repository "https://github.com/kingdonb/bootstrap-repo.git"
✔ cloned repository
► generating component manifests
✔ generated component manifests
✔ component manifests are up to date
✔ reconciled components
► determining if source secret "operators/flux-system" exists
✔ source secret up to date
► generating sync manifests
✔ generated sync manifests
✔ sync manifests are up to date
► applying sync manifests
✔ reconciled sync configuration
◎ waiting for Kustomization "operators/operators" to be reconciled
✔ Kustomization reconciled successfully
► confirming components are healthy
✔ helm-controller: deployment ready
✔ kustomize-controller: deployment ready
✔ notification-controller: deployment ready
✔ source-controller: deployment ready
✔ all components are healthy
Describe the bug
When Flux is installed from the Operator Hub installation instructions, it lands in the namespace
operators
by default.The
flux logs
command accepts--flux-namespace
which works, butFLUX_SYSTEM_NAMESPACE
being exported in the shell does not have the same effect.Steps to reproduce
On a new cluster (
kind
is OK, I used k3s and vcluster) you can follow the 2-step directions to install OLM, and install a Flux operator "subscription" which is located in theoperators
namespace.(Note that I have done this after the "expected behavior" steps below, so I am certain there are already some logs to capture.)
Expected behavior
Calling
flux logs
with theflux-namespace
option gets the desired results:The content of the logs above is not important, the fact that they are successfully recovered is the expected behavior.
You should get the same results by setting
FLUX_SYSTEM_NAMESPACE=operators
and exporting it in the shell environment but it does not.There is no output, unless you call it with the
--flux-namespace
option as above.Screenshots and recordings
No response
OS / Distro
MacOS 10.15.7
Flux version
v0.34.0
Flux check
Git provider
N/A
Container Registry provider
N/A
Additional context
No response
Code of Conduct