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

Make KOS able to handle resources without namespaces #1114

Closed
wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 29, 2023

Sometimes customers need to deploy resources that are cluster-scoped, which do not have namespaces. Currently these resources result in a kubectl get <kind> <name> -n command being sent, which is invalid because the namespace argument -n must have a value.

This PR fixes this issue by filtering out the resources that are cluster-scoped. When we have cluster-scoped resources, we exclude them from the KOS and do not show them to the customer. Instead we note them down in the task log, and tell the customer that those are not checked against.

Assuming we are using this YAML which deploys a cluster-scoped resource:
Screenshot 2023-08-29 at 3 00 33 PM

Before

Screenshot 2023-08-29 at 3 32 27 PM

After

Screenshot 2023-08-29 at 4 29 13 PM

@ghost ghost force-pushed the yihao/fix-no-namespace branch from 6b9b157 to 59cea76 Compare August 29, 2023 06:38

// Filter out cluster-wide resources
definedResources = definedResources
.Where(resource => !string.IsNullOrEmpty(resource.Namespace) && !nonNamespacedDefinedResources.Contains(new ResourceIdentifier(resource.Kind, resource.Name, string.Empty)))
Copy link
Author

@ghost ghost Aug 29, 2023

Choose a reason for hiding this comment

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

If either the namespace on the identifier itself is empty, or the namespace from the resource response is empty, we consider it cluster-scoped.

The namespace on the identifier itself can be empty if the identifier is created by parsing the response of an apply command directly, which is the case when using batch apply with glob patterns.

@ghost ghost force-pushed the yihao/fix-no-namespace branch from 115ee96 to 78b4ce6 Compare August 29, 2023 07:16
@ghost ghost force-pushed the yihao/fix-no-namespace branch from 78b4ce6 to 62627c8 Compare August 29, 2023 07:28
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Yihao seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@APErebus APErebus closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants