Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling cross-namespace references #549

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Jan 26, 2022

Introduce the flag --no-cross-namespace-refs (defaults to false) for allowing cluster admins to disable cross-namespace references to sources.

When the controller is run with --no-cross-namespace-refs=true and a Kustomization.spec.sourceRef.namespace refers to a GitRepository or Bucket in a different namespace than the Kustomization object, the reconciliation will fail with the AccessDenied reason.

On access denied errors the controller logs and sends an event e.g.:

can't access 'GitRepository/my-other-namespace/my-source', cross-namespace references have been blocked

And the Kustomization status Ready condition it set to:

status:
  conditions:
  - lastTransitionTime: "2022-01-26T07:26:48Z"
    message: "can't access 'GitRepository/my-other-namespace/my-source', cross-namespace references have been blocked"
    reason: AccessDenied
    status: "False"
    type: Ready

Part of: fluxcd/flux2#2337

@stefanprodan stefanprodan added the enhancement New feature or request label Jan 26, 2022
Copy link
Member

@somtochiama somtochiama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested that the flag disables cross namespace references.
Logs from the controller:

{"level":"error","ts":"2022-01-26T14:29:08.655Z","logger":"controller.kustomization","msg":"AccessDenied","reconciler group":"kustomize.toolkit.fluxcd.io",
"reconciler kind":"Kustomization","name":"podinfo","namespace":"flux-system","error":"can't access 'default/podinfo', cross-namespace references have been blocked"}

Introduce the flag `--no-cross-namespace-refs` (defaults to false) for allowing cluster admins to disable cross-namespace references to sources.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Copy link
Member

@makkes makkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's brilliant. Should we add a link to RFC 0002 somewhere for posterity?

@stefanprodan
Copy link
Member Author

@makkes after we implement this flag in all controllers and we release flux 0.26.0, I'll update RFC-0002 and RFC-0003.

@stefanprodan stefanprodan merged commit 09e6c29 into main Jan 27, 2022
@stefanprodan stefanprodan deleted the no-cross-namespace-refs branch January 27, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants